mirror of
https://github.com/Xevion/go-ha.git
synced 2026-01-31 12:24:25 -06:00
Return Service errors
Additionally, removed the context that gets passed into the Services but isn't used in one of them. The websockets APIs also don't have any use for context.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
ws "saml.dev/gome-assistant/internal/websocket"
|
||||
)
|
||||
|
||||
@@ -10,37 +8,36 @@ import (
|
||||
|
||||
type InputBoolean struct {
|
||||
conn *ws.WebsocketWriter
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
/* Public API */
|
||||
|
||||
func (ib InputBoolean) TurnOn(entityId string) {
|
||||
func (ib InputBoolean) TurnOn(entityId string) error {
|
||||
req := NewBaseServiceRequest(entityId)
|
||||
req.Domain = "input_boolean"
|
||||
req.Service = "turn_on"
|
||||
|
||||
ib.conn.WriteMessage(req, ib.ctx)
|
||||
return ib.conn.WriteMessage(req)
|
||||
}
|
||||
|
||||
func (ib InputBoolean) Toggle(entityId string) {
|
||||
func (ib InputBoolean) Toggle(entityId string) error {
|
||||
req := NewBaseServiceRequest(entityId)
|
||||
req.Domain = "input_boolean"
|
||||
req.Service = "toggle"
|
||||
|
||||
ib.conn.WriteMessage(req, ib.ctx)
|
||||
return ib.conn.WriteMessage(req)
|
||||
}
|
||||
|
||||
func (ib InputBoolean) TurnOff(entityId string) {
|
||||
func (ib InputBoolean) TurnOff(entityId string) error {
|
||||
req := NewBaseServiceRequest(entityId)
|
||||
req.Domain = "input_boolean"
|
||||
req.Service = "turn_off"
|
||||
ib.conn.WriteMessage(req, ib.ctx)
|
||||
return ib.conn.WriteMessage(req)
|
||||
}
|
||||
|
||||
func (ib InputBoolean) Reload() {
|
||||
func (ib InputBoolean) Reload() error {
|
||||
req := NewBaseServiceRequest("")
|
||||
req.Domain = "input_boolean"
|
||||
req.Service = "reload"
|
||||
ib.conn.WriteMessage(req, ib.ctx)
|
||||
return ib.conn.WriteMessage(req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user