From f4c82df96856f45e76c6cc90a3f50a645dd190e9 Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Tue, 29 Sep 2026 18:05:51 +0300 Subject: [PATCH] Scene transitions --- src/HomeAssistant/Controller.hs | 8 ++++++-- src/HomeAssistant/Controller/Bedroom.hs | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/HomeAssistant/Controller.hs b/src/HomeAssistant/Controller.hs index 7c65cd4..afccba9 100644 --- a/src/HomeAssistant/Controller.hs +++ b/src/HomeAssistant/Controller.hs @@ -32,6 +32,7 @@ module HomeAssistant.Controller , IkeaButton(..) , IkeaGesture(..) , activateScene + , activateSceneWith , ikeaBoxRemote , IkeaController(..) ) where @@ -259,9 +260,12 @@ ikeaBoxRemote entityId = entityChangeEvent' entityId eventType v = v ^? key "event" . key "variables" . key "trigger" . key "to_state" . key "attributes" . key "event_type" . _String . to toIkeaController . traversed activateScene :: T.Text -> Service -activateScene sceneId = Service +activateScene sceneId = activateSceneWith sceneId Nothing + +activateSceneWith :: T.Text -> Maybe Value -> Service +activateSceneWith sceneId d = Service { serviceDomain="scene" , serviceName= "turn_on" , serviceTarget= [EntityId sceneId] - , serviceData = Nothing + , serviceData = d } diff --git a/src/HomeAssistant/Controller/Bedroom.hs b/src/HomeAssistant/Controller/Bedroom.hs index 29a2d1b..75afcb7 100644 --- a/src/HomeAssistant/Controller/Bedroom.hs +++ b/src/HomeAssistant/Controller/Bedroom.hs @@ -56,11 +56,13 @@ bedroomPresenceController = proc x -> do Event LightsOff -> do callService (light bedroomLights Off) -< () Event LightsOn -> do - callService (activateScene "scene.makuuhuone_lights_snapshot") -< () + callService (activateSceneWith "scene.makuuhuone_lights_snapshot" transition) -< () Event LightsSleep -> do callService createBedroomScene -< () - callService (activateScene "scene.makuuhuone_lepotila") -< () + callService (activateSceneWith "scene.makuuhuone_lepotila" transition) -< () _ -> returnA -< () + where + transition = Just $ object ["transition" .= (5 :: Int)] data BedroomControls