mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-08 08:07:21 -06:00
Added lots of services and fixed bug with ID for websocket calls
This commit is contained in:
35
internal/services/input_text.go
Normal file
35
internal/services/input_text.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
ws "github.com/saml-dev/gome-assistant/internal/websocket"
|
||||
"nhooyr.io/websocket"
|
||||
)
|
||||
|
||||
/* Structs */
|
||||
|
||||
type InputText struct {
|
||||
conn *websocket.Conn
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
/* Public API */
|
||||
|
||||
func (ib InputText) Set(entityId string, value string) {
|
||||
req := NewBaseServiceRequest(entityId)
|
||||
req.Domain = "input_text"
|
||||
req.Service = "set_value"
|
||||
req.ServiceData = map[string]any{
|
||||
"value": value,
|
||||
}
|
||||
|
||||
ws.WriteMessage(req, ib.conn, ib.ctx)
|
||||
}
|
||||
|
||||
func (ib InputText) Reload() {
|
||||
req := NewBaseServiceRequest("")
|
||||
req.Domain = "input_text"
|
||||
req.Service = "reload"
|
||||
ws.WriteMessage(req, ib.conn, ib.ctx)
|
||||
}
|
||||
Reference in New Issue
Block a user