From db1ac7ffd6ee07788dea92c312e84145f62137c6 Mon Sep 17 00:00:00 2001 From: Jordan Hotmann Date: Tue, 7 Nov 2023 15:55:04 -0700 Subject: [PATCH] CallServiceManual --- pkg/homeassistant/rest.go | 4 ++++ pkg/homeassistant/structs.go | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pkg/homeassistant/rest.go b/pkg/homeassistant/rest.go index 3978937..de81e6a 100644 --- a/pkg/homeassistant/rest.go +++ b/pkg/homeassistant/rest.go @@ -33,6 +33,10 @@ func (c *RestClient) GetState(entityId string) (StateData, error) { func (c *RestClient) CallService(entityId string, service string, extras ...map[string]any) error { domain := strings.Split(entityId, ".")[0] + return c.CallServiceManual(domain, entityId, service, extras...) +} + +func (c *RestClient) CallServiceManual(domain string, entityId string, service string, extras ...map[string]any) error { data := map[string]any{ "entity_id": entityId, } diff --git a/pkg/homeassistant/structs.go b/pkg/homeassistant/structs.go index 67da543..a74d154 100644 --- a/pkg/homeassistant/structs.go +++ b/pkg/homeassistant/structs.go @@ -29,15 +29,19 @@ var MessageType = struct { // Home Assistant device domains var Domains = struct { - Light string - Switch string - Lock string - Cover string + Light string + Switch string + Lock string + Cover string + Homeassistant string + Group string }{ - Light: "light", - Switch: "switch", - Lock: "lock", - Cover: "cover", + Light: "light", + Switch: "switch", + Lock: "lock", + Cover: "cover", + Homeassistant: "homeassistant", + Group: "group", } // Home Assistant services