コード例 #1
0
ファイル: thermostat.go プロジェクト: tjbx/X10Bridge
// 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}
}
コード例 #2
0
ファイル: thermostat.go プロジェクト: kemathy/hc
// 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
}