-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy paththermostat.go
31 lines (24 loc) · 864 Bytes
/
thermostat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package accessory
import (
"github.com/brutella/hc/service"
)
type Thermostat struct {
*Accessory
Thermostat *service.Thermostat
}
// NewThermostat returns a Thermostat which implements model.Thermostat.
func NewThermostat(info Info, temp, min, max, steps float64) *Thermostat {
acc := Thermostat{}
acc.Accessory = New(info, TypeThermostat)
acc.Thermostat = service.NewThermostat()
acc.Thermostat.CurrentTemperature.SetValue(temp)
acc.Thermostat.CurrentTemperature.SetMinValue(min)
acc.Thermostat.CurrentTemperature.SetMaxValue(max)
acc.Thermostat.CurrentTemperature.SetStepValue(steps)
acc.Thermostat.TargetTemperature.SetValue(temp)
acc.Thermostat.TargetTemperature.SetMinValue(min)
acc.Thermostat.TargetTemperature.SetMaxValue(max)
acc.Thermostat.TargetTemperature.SetStepValue(steps)
acc.AddService(acc.Thermostat.Service)
return &acc
}