Much improved hallway handling

This commit is contained in:
MasseR committed 2026-11-03 14:47:01 +02:00
1 parent 95fcc61c4f
commit 6e35445090
9 files changed
+354 -100

No files matched your search

+15
View File
@@ -6,11 +6,13 @@ module Support
, runHASS
, runHASSTimed
, services
, values
, fakeRequest
, sec
, stateEvent
, buttonEvent
, withTestLogEnv
, clock
) where
import Control.Exception (bracket)
@@ -75,9 +77,14 @@ runHASSTimed m = go (runMealy m interp)
case runAcc (stepAuto w (Request t utc nil "test") a) [] of
((b, w'), svcs) -> (b, svcs) : go w' as
-- To observe external effects
services :: [(b, [Service])] -> [[Service]]
services = map snd
-- To observe intermediary steps
values :: [(b, [Service])] -> [b]
values = map fst
-- | Build a state-trigger payload matching `entityChangeEvent'` / `entityBool'`
-- lenses. The subscribe_trigger websocket event wraps the trigger datum under
-- `event.variables.trigger`, with `entity_id` and `to_state.state` fields.
@@ -106,3 +113,11 @@ buttonEvent entityId eventType = object
]
]
]
-- runHASSTimed builds its request with the UTC zone, so a UTCTime given as
-- seconds-of-day reads back as exactly that local time of day
clock :: Int -> Int -> UTCTime
clock h m = sec (fromIntegral (h * 60 + m) * 60)