mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-08 04:07:18 -06:00
add zwavejs service
This commit is contained in:
@@ -25,7 +25,8 @@ func BuildService[
|
|||||||
Number |
|
Number |
|
||||||
Scene |
|
Scene |
|
||||||
TTS |
|
TTS |
|
||||||
Vacuum,
|
Vacuum |
|
||||||
|
ZWaveJS,
|
||||||
](conn *ws.WebsocketWriter, ctx context.Context) *T {
|
](conn *ws.WebsocketWriter, ctx context.Context) *T {
|
||||||
return &T{conn: conn, ctx: ctx}
|
return &T{conn: conn, ctx: ctx}
|
||||||
}
|
}
|
||||||
|
|||||||
29
internal/services/zwavejs.go
Normal file
29
internal/services/zwavejs.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
ws "saml.dev/gome-assistant/internal/websocket"
|
||||||
|
)
|
||||||
|
|
||||||
|
/* Structs */
|
||||||
|
|
||||||
|
type ZWaveJS struct {
|
||||||
|
conn *ws.WebsocketWriter
|
||||||
|
ctx context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Public API */
|
||||||
|
|
||||||
|
// ZWaveJS bulk_set_partial_config_parameters service.
|
||||||
|
func (zw ZWaveJS) BulkSetPartialConfigParam(entityId string, parameter int, value any) {
|
||||||
|
req := NewBaseServiceRequest(entityId)
|
||||||
|
req.Domain = "zwave_js"
|
||||||
|
req.Service = "bulk_set_partial_config_parameters"
|
||||||
|
req.ServiceData = map[string]any{
|
||||||
|
"parameter": parameter,
|
||||||
|
"value": value,
|
||||||
|
}
|
||||||
|
|
||||||
|
zw.conn.WriteMessage(req, zw.ctx)
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ type Service struct {
|
|||||||
Scene *services.Scene
|
Scene *services.Scene
|
||||||
TTS *services.TTS
|
TTS *services.TTS
|
||||||
Vacuum *services.Vacuum
|
Vacuum *services.Vacuum
|
||||||
|
ZWaveJS *services.ZWaveJS
|
||||||
}
|
}
|
||||||
|
|
||||||
func newService(conn *ws.WebsocketWriter, ctx context.Context, httpClient *http.HttpClient) *Service {
|
func newService(conn *ws.WebsocketWriter, ctx context.Context, httpClient *http.HttpClient) *Service {
|
||||||
@@ -49,5 +50,6 @@ func newService(conn *ws.WebsocketWriter, ctx context.Context, httpClient *http.
|
|||||||
Scene: services.BuildService[services.Scene](conn, ctx),
|
Scene: services.BuildService[services.Scene](conn, ctx),
|
||||||
TTS: services.BuildService[services.TTS](conn, ctx),
|
TTS: services.BuildService[services.TTS](conn, ctx),
|
||||||
Vacuum: services.BuildService[services.Vacuum](conn, ctx),
|
Vacuum: services.BuildService[services.Vacuum](conn, ctx),
|
||||||
|
ZWaveJS: services.BuildService[services.ZWaveJS](conn, ctx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user