Example #1
0
func getThermostat(name string, dev gogadgets.Message, g Gadget, accessories []*accessory.Accessory) []*accessory.Accessory {
	info := accessory.Info{
		Name:         name,
		Manufacturer: "gogadgets",
	}
	s := accessory.NewThermostat(info, 70.0, 0.0, 90.0, 0.1)
	connect(s, g, name)
	return append(accessories, s.Accessory)
}
Example #2
0
func setupHomeKit() {
	aInfo := accessory.Info{
		Name:         "Hive Bridge",
		Manufacturer: "British Gas PLC",
	}
	a := accessory.New(aInfo, accessory.TypeBridge)

	tInfo := accessory.Info{
		Name:         "Heating",
		Manufacturer: "British Gas PLC",
	}
	t := accessory.NewThermostat(tInfo, 20.0, hive.MinTemp, hive.MaxTemp, 0.5)
	t.Thermostat.TargetTemperature.OnValueRemoteUpdate(targetTempChangeRequest)
	thermostat = t

	bInfo := accessory.Info{
		Name:         "Heating Boost",
		Manufacturer: "British Gas PLC",
	}
	b := accessory.NewSwitch(bInfo)
	b.Switch.On.OnValueRemoteUpdate(heatingBoostStateChangeRequest)
	heatingBoostSwitch = b

	sInfo := accessory.Info{
		Name:         "Hot Water",
		Manufacturer: "British Gas PLC",
	}
	h := accessory.NewSwitch(sInfo)
	h.Switch.On.OnValueRemoteUpdate(hotWaterStateChangeRequest)
	hotWaterSwitch = h

	config := hap.Config{
		Pin: pin,
	}

	var err error
	transport, err = hap.NewIPTransport(config, a, t.Accessory, b.Accessory, h.Accessory)
	if err != nil {
		log.Fatal(err)
	}
}