Ejemplo n.º 1
0
// NewThermostat returns a thermostat which implements model.Thermostat.
func NewThermostat(info model.Info, temp, min, max, steps float64) *thermostat {
	accessory := New(info)
	t := service.NewThermostat(info.Name, temp, min, max, steps)

	accessory.AddService(t.Service)

	return &thermostat{accessory, t}
}
Ejemplo n.º 2
0
// NewThermostat returns a thermostat which implements model.Thermostat.
func NewThermostat(info model.Info, temp, min, max, steps float64) *thermostat {
	accessory := New(info)
	t := service.NewThermostat(info.Name, temp, min, max, steps)

	accessory.AddService(t.Service)

	ts := thermostat{accessory, t, nil, nil}

	t.TargetTemp.OnConnChange(func(conn net.Conn, c *characteristic.Characteristic, new, old interface{}) {
		if ts.onTargetTempChange != nil {
			ts.onTargetTempChange(t.TargetTemp.Temperature())
		}
	})

	t.TargetMode.OnConnChange(func(conn net.Conn, c *characteristic.Characteristic, new, old interface{}) {
		if ts.onTargetModeChange != nil {
			ts.onTargetModeChange(t.TargetMode.HeatingCoolingMode())
		}
	})

	return &ts
}