mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-06 01:15:10 -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,7 +1,6 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -12,12 +11,11 @@ import (
|
||||
|
||||
type InputDatetime struct {
|
||||
conn *ws.WebsocketWriter
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
/* Public API */
|
||||
|
||||
func (ib InputDatetime) Set(entityId string, value time.Time) {
|
||||
func (ib InputDatetime) Set(entityId string, value time.Time) error {
|
||||
req := NewBaseServiceRequest(entityId)
|
||||
req.Domain = "input_datetime"
|
||||
req.Service = "set_datetime"
|
||||
@@ -25,12 +23,12 @@ func (ib InputDatetime) Set(entityId string, value time.Time) {
|
||||
"timestamp": fmt.Sprint(value.Unix()),
|
||||
}
|
||||
|
||||
ib.conn.WriteMessage(req, ib.ctx)
|
||||
return ib.conn.WriteMessage(req)
|
||||
}
|
||||
|
||||
func (ib InputDatetime) Reload() {
|
||||
func (ib InputDatetime) Reload() error {
|
||||
req := NewBaseServiceRequest("")
|
||||
req.Domain = "input_datetime"
|
||||
req.Service = "reload"
|
||||
ib.conn.WriteMessage(req, ib.ctx)
|
||||
return ib.conn.WriteMessage(req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user