Compare commits

...

3 Commits

3 changed files with 28 additions and 16 deletions

View File

@ -237,7 +237,7 @@ func (c *Client) breathe(selector string, breathe Breathe) (*Response, error) {
return resp, nil return resp, nil
} }
func (c *Client) setStates(selector string, states States) (*Response, error) { func (c *Client) setStates(states States) (*Response, error) {
var ( var (
err error err error
j []byte j []byte

View File

@ -163,6 +163,10 @@ func (c RGBColor) ColorString() string {
return fmt.Sprintf("rgb:%d,%d,%d", c.R, c.G, c.B) return fmt.Sprintf("rgb:%d,%d,%d", c.R, c.G, c.B)
} }
func (c RGBColor) String() string {
return c.ColorString()
}
func (c RGBColor) Hex() string { func (c RGBColor) Hex() string {
return fmt.Sprintf("#%x%x%x", c.R, c.G, c.B) return fmt.Sprintf("#%x%x%x", c.R, c.G, c.B)
} }
@ -184,6 +188,10 @@ func (c HSBKColor) ColorString() string {
return strings.Join(s, " ") return strings.Join(s, " ")
} }
func (c HSBKColor) String() string {
return c.ColorString()
}
func (c HSBKColor) MarshalText() ([]byte, error) { func (c HSBKColor) MarshalText() ([]byte, error) {
return []byte(c.ColorString()), nil return []byte(c.ColorString()), nil
} }
@ -196,6 +204,10 @@ func (c NamedColor) ColorString() string {
return string(c) return string(c)
} }
func (c NamedColor) String() string {
return c.ColorString()
}
func (c *Client) ValidateColor(color Color) (Color, error) { func (c *Client) ValidateColor(color Color) (Color, error) {
var ( var (
err error err error

View File

@ -51,7 +51,7 @@ type (
Group Selector `json:"group"` Group Selector `json:"group"`
Location Selector `json:"location"` Location Selector `json:"location"`
Product Product `json:"product"` Product Product `json:"product"`
LastSeen time.Time `json:"last_seen"` LastSeen *time.Time `json:"last_seen,omitempty"`
SecondsLastSeen float64 `json:"seconds_last_seen"` SecondsLastSeen float64 `json:"seconds_last_seen"`
} }
@ -156,14 +156,14 @@ func (c *Client) FastSetState(selector string, state State) (*LifxResponse, erro
return c.SetState(selector, state) return c.SetState(selector, state)
} }
func (c *Client) SetStates(selector string, states States) (*LifxResponse, error) { func (c *Client) SetStates(states States) (*LifxResponse, error) {
var ( var (
err error err error
s *LifxResponse s *LifxResponse
resp *Response resp *Response
) )
if resp, err = c.setStates(selector, states); err != nil { if resp, err = c.setStates(states); err != nil {
return nil, err return nil, err
} }
defer resp.Body.Close() defer resp.Body.Close()