mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-06 09:15:12 -06:00
38 lines
698 B
Go
38 lines
698 B
Go
package services
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/gorilla/websocket"
|
|
ws "saml.dev/gome-assistant/internal/websocket"
|
|
)
|
|
|
|
/* Structs */
|
|
|
|
type InputDatetime struct {
|
|
conn *websocket.Conn
|
|
ctx context.Context
|
|
}
|
|
|
|
/* Public API */
|
|
|
|
func (ib InputDatetime) Set(entityId string, value time.Time) {
|
|
req := NewBaseServiceRequest(entityId)
|
|
req.Domain = "input_datetime"
|
|
req.Service = "set_datetime"
|
|
req.ServiceData = map[string]any{
|
|
"timestamp": fmt.Sprint(value.Unix()),
|
|
}
|
|
|
|
ws.WriteMessage(req, ib.conn, ib.ctx)
|
|
}
|
|
|
|
func (ib InputDatetime) Reload() {
|
|
req := NewBaseServiceRequest("")
|
|
req.Domain = "input_datetime"
|
|
req.Service = "reload"
|
|
ws.WriteMessage(req, ib.conn, ib.ctx)
|
|
}
|