add number service

This commit is contained in:
Sam Lewis
2022-11-09 20:31:06 -05:00
parent e5fe752d2c
commit e9f07b9b32
3 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
package services
import (
"context"
"github.com/gorilla/websocket"
ws "github.com/saml-dev/gome-assistant/internal/websocket"
)
/* Structs */
type Number struct {
conn *websocket.Conn
ctx context.Context
}
/* Public API */
func (ib Number) SetValue(entityId string, value int) {
req := NewBaseServiceRequest(entityId)
req.Domain = "number"
req.Service = "set_value"
req.ServiceData = map[string]any{"value": value}
ws.WriteMessage(req, ib.conn, ib.ctx)
}

View File

@@ -18,7 +18,8 @@ func BuildService[
InputDatetime |
InputText |
InputNumber |
Notify,
Notify |
Number,
](conn *websocket.Conn, ctx context.Context) *T {
return &T{conn: conn, ctx: ctx}
}