mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-09 12:07:25 -06:00
add climate service
This commit is contained in:
35
internal/services/climate.go
Normal file
35
internal/services/climate.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
ws "saml.dev/gome-assistant/internal/websocket"
|
||||
"saml.dev/gome-assistant/types"
|
||||
)
|
||||
|
||||
/* Structs */
|
||||
|
||||
type Climate struct {
|
||||
conn *ws.WebsocketWriter
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
/* Public API */
|
||||
|
||||
func (c Climate) SetFanMode(entityId string, fanMode string) {
|
||||
req := NewBaseServiceRequest(entityId)
|
||||
req.Domain = "climate"
|
||||
req.Service = "set_fan_mode"
|
||||
req.ServiceData = map[string]any{"fan_mode": fanMode}
|
||||
|
||||
c.conn.WriteMessage(req, c.ctx)
|
||||
}
|
||||
|
||||
func (c Climate) SetTemperature(entityId string, serviceData types.SetTemperatureRequest) {
|
||||
req := NewBaseServiceRequest(entityId)
|
||||
req.Domain = "climate"
|
||||
req.Service = "set_temperature"
|
||||
req.ServiceData = serviceData.ToJSON()
|
||||
|
||||
c.conn.WriteMessage(req, c.ctx)
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
func BuildService[
|
||||
T AlarmControlPanel |
|
||||
Climate |
|
||||
Cover |
|
||||
Light |
|
||||
HomeAssistant |
|
||||
|
||||
Reference in New Issue
Block a user