mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-06 01:15:10 -06:00
add number service
This commit is contained in:
26
internal/services/number.go
Normal file
26
internal/services/number.go
Normal 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)
|
||||
}
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user