add climate service

This commit is contained in:
Sam Lewis
2023-05-01 00:53:52 -04:00
parent eb6718a796
commit 1dd8eaa58d
4 changed files with 62 additions and 0 deletions

View File

@@ -7,3 +7,27 @@ type NotifyRequest struct {
Title string
Data map[string]any
}
type SetTemperatureRequest struct {
Temperature float32
TargetTempHigh float32
TargetTempLow float32
HvacMode string
}
func (r *SetTemperatureRequest) ToJSON() map[string]any {
m := map[string]any{}
if r.Temperature != 0 {
m["temperature"] = r.Temperature
}
if r.TargetTempHigh != 0 {
m["target_temp_high"] = r.TargetTempHigh
}
if r.TargetTempLow != 0 {
m["target_temp_low"] = r.TargetTempLow
}
if r.HvacMode != "" {
m["hvac_mode"] = r.HvacMode
}
return m
}