Skip to content

Commit

Permalink
Add separate colored lightbulb accessory
Browse files Browse the repository at this point in the history
  • Loading branch information
brutella committed Jan 27, 2020
1 parent 50499be commit 01b9006
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
23 changes: 23 additions & 0 deletions accessory/colored_lightbulb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package accessory

import (
"github.com/brutella/hc/service"
)

type ColoredLightbulb struct {
*Accessory
Lightbulb *service.ColoredLightbulb
}

// NewLightbulb returns an light bulb accessory which one light bulb service.
func NewColoredLightbulb(info Info) *ColoredLightbulb {
acc := ColoredLightbulb{}
acc.Accessory = New(info, TypeLightbulb)
acc.Lightbulb = service.NewColoredLightbulb()

acc.Lightbulb.Brightness.SetValue(100)

acc.AddService(acc.Lightbulb.Service)

return &acc
}
12 changes: 5 additions & 7 deletions accessory/lightbulb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import (
"github.com/brutella/hc/service"
)

type ColoredLightbulb struct {
type Lightbulb struct {
*Accessory
Lightbulb *service.ColoredLightbulb
Lightbulb *service.Lightbulb
}

// NewLightbulb returns an light bulb accessory which one light bulb service.
func NewColoredLightbulb(info Info) *ColoredLightbulb {
acc := ColoredLightbulb{}
func NewLightbulb(info Info) *Lightbulb {
acc := Lightbulb{}
acc.Accessory = New(info, TypeLightbulb)
acc.Lightbulb = service.NewColoredLightbulb()

acc.Lightbulb.Brightness.SetValue(100)
acc.Lightbulb = service.NewLightbulb()

acc.AddService(acc.Lightbulb.Service)

Expand Down

0 comments on commit 01b9006

Please sign in to comment.