示例#1
0
文件: switch.go 项目: smitterson/hc
// NewSwitch returns a switch service.
func NewSwitch(name string, on bool) *Switch {
	onChar := characteristic.NewOn(on)
	nameChar := characteristic.NewName(name)

	svc := New()
	svc.Type = typeSwitch
	svc.AddCharacteristic(onChar.Characteristic)
	svc.AddCharacteristic(nameChar.Characteristic)

	return &Switch{svc, onChar, nameChar}
}
示例#2
0
文件: light_bulb.go 项目: bahlo/hc
// NewLightBulb returns a light bulb service.
func NewLightBulb(name string, on bool) *LightBulb {
	onChar := characteristic.NewOn(on)
	nameChar := characteristic.NewName(name)
	brightness := characteristic.NewBrightness(100) // 100%
	saturation := characteristic.NewSaturation(0.0)
	hue := characteristic.NewHue(0.0)

	svc := New()
	svc.Type = typeLightBulb
	svc.AddCharacteristic(onChar.Characteristic)
	svc.AddCharacteristic(nameChar.Characteristic)
	svc.AddCharacteristic(brightness.Characteristic)
	svc.AddCharacteristic(saturation.Characteristic)
	svc.AddCharacteristic(hue.Characteristic)

	return &LightBulb{svc, onChar, nameChar, brightness, saturation, hue}
}