mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-05 23:15:07 -06:00
34 lines
645 B
Go
34 lines
645 B
Go
package services
|
|
|
|
import (
|
|
"github.com/Xevion/go-ha/internal/connect"
|
|
)
|
|
|
|
type Switch struct {
|
|
conn *connect.HAConnection
|
|
}
|
|
|
|
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)
|
|
}
|