mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-10 18:07:23 -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)
|
||||
}
|
||||
Reference in New Issue
Block a user