refactor: move types out of app.go into types/, renamed module files

This commit is contained in:
2025-08-01 18:08:01 -05:00
parent 3d178ad05e
commit 21358b73e1
13 changed files with 105 additions and 88 deletions

33
types/request.go Normal file
View File

@@ -0,0 +1,33 @@
package types
type NotifyRequest struct {
// Which notify service to call, such as mobile_app_sams_iphone
ServiceName string
Message string
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
}