Beispiel #1
0
// 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}
}
Beispiel #2
0
// 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}
}