mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-06 03:15:14 -06:00
38 lines
690 B
Go
38 lines
690 B
Go
package services
|
|
|
|
import (
|
|
ws "github.com/Xevion/gome-assistant/internal/websocket"
|
|
)
|
|
|
|
/* Structs */
|
|
|
|
type Switch struct {
|
|
conn *ws.WebsocketWriter
|
|
}
|
|
|
|
/* Public API */
|
|
|
|
func (s Switch) TurnOn(entityId string) error {
|
|
req := NewBaseServiceRequest(entityId)
|
|
req.Domain = "switch"
|
|
req.Service = "turn_on"
|
|
|
|
return s.conn.WriteMessage(req)
|
|
}
|
|
|
|
func (s Switch) Toggle(entityId string) error {
|
|
req := NewBaseServiceRequest(entityId)
|
|
req.Domain = "switch"
|
|
req.Service = "toggle"
|
|
|
|
return s.conn.WriteMessage(req)
|
|
}
|
|
|
|
func (s Switch) TurnOff(entityId string) error {
|
|
req := NewBaseServiceRequest(entityId)
|
|
req.Domain = "switch"
|
|
req.Service = "turn_off"
|
|
|
|
return s.conn.WriteMessage(req)
|
|
}
|