Skip to content

Commit 0984a31

Browse files
authored
Merge pull request #31 from saml-dev/adaptive-lighting
add adaptive lighting service
2 parents 05131fa + 65672dc commit 0984a31

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package services
2+
3+
import (
4+
ws "saml.dev/gome-assistant/internal/websocket"
5+
)
6+
7+
/* Structs */
8+
9+
type AdaptiveLighting struct {
10+
conn *ws.WebsocketWriter
11+
}
12+
13+
/* Public API */
14+
15+
// Set manual control for an adaptive lighting entity.
16+
func (al AdaptiveLighting) SetManualControl(entityId string, enabled bool) error {
17+
req := NewBaseServiceRequest("")
18+
req.Domain = "adaptive_lighting"
19+
req.Service = "set_manual_control"
20+
req.ServiceData = map[string]any{
21+
"entity_id": entityId,
22+
"manual_control": enabled,
23+
}
24+
25+
return al.conn.WriteMessage(req)
26+
}

internal/services/services.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
)
77

88
func BuildService[
9-
T AlarmControlPanel |
9+
T AdaptiveLighting |
10+
AlarmControlPanel |
1011
Climate |
1112
Cover |
1213
Light |

service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
)
77

88
type Service struct {
9+
AdaptiveLighting *services.AdaptiveLighting
910
AlarmControlPanel *services.AlarmControlPanel
1011
Climate *services.Climate
1112
Cover *services.Cover
@@ -31,6 +32,7 @@ type Service struct {
3132

3233
func newService(conn *ws.WebsocketWriter) *Service {
3334
return &Service{
35+
AdaptiveLighting: services.BuildService[services.AdaptiveLighting](conn),
3436
AlarmControlPanel: services.BuildService[services.AlarmControlPanel](conn),
3537
Climate: services.BuildService[services.Climate](conn),
3638
Cover: services.BuildService[services.Cover](conn),

0 commit comments

Comments
 (0)