Scene transitions
This commit is contained in:
@@ -32,6 +32,7 @@ module HomeAssistant.Controller
|
|||||||
, IkeaButton(..)
|
, IkeaButton(..)
|
||||||
, IkeaGesture(..)
|
, IkeaGesture(..)
|
||||||
, activateScene
|
, activateScene
|
||||||
|
, activateSceneWith
|
||||||
, ikeaBoxRemote
|
, ikeaBoxRemote
|
||||||
, IkeaController(..)
|
, IkeaController(..)
|
||||||
) where
|
) 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
|
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 :: T.Text -> Service
|
||||||
activateScene sceneId = Service
|
activateScene sceneId = activateSceneWith sceneId Nothing
|
||||||
|
|
||||||
|
activateSceneWith :: T.Text -> Maybe Value -> Service
|
||||||
|
activateSceneWith sceneId d = Service
|
||||||
{ serviceDomain="scene"
|
{ serviceDomain="scene"
|
||||||
, serviceName= "turn_on"
|
, serviceName= "turn_on"
|
||||||
, serviceTarget= [EntityId sceneId]
|
, serviceTarget= [EntityId sceneId]
|
||||||
, serviceData = Nothing
|
, serviceData = d
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,11 +56,13 @@ bedroomPresenceController = proc x -> do
|
|||||||
Event LightsOff -> do
|
Event LightsOff -> do
|
||||||
callService (light bedroomLights Off) -< ()
|
callService (light bedroomLights Off) -< ()
|
||||||
Event LightsOn -> do
|
Event LightsOn -> do
|
||||||
callService (activateScene "scene.makuuhuone_lights_snapshot") -< ()
|
callService (activateSceneWith "scene.makuuhuone_lights_snapshot" transition) -< ()
|
||||||
Event LightsSleep -> do
|
Event LightsSleep -> do
|
||||||
callService createBedroomScene -< ()
|
callService createBedroomScene -< ()
|
||||||
callService (activateScene "scene.makuuhuone_lepotila") -< ()
|
callService (activateSceneWith "scene.makuuhuone_lepotila" transition) -< ()
|
||||||
_ -> returnA -< ()
|
_ -> returnA -< ()
|
||||||
|
where
|
||||||
|
transition = Just $ object ["transition" .= (5 :: Int)]
|
||||||
|
|
||||||
|
|
||||||
data BedroomControls
|
data BedroomControls
|
||||||
|
|||||||
Reference in New Issue
Block a user