Runtimes and controllers

This commit is contained in:
2026-08-20 22:34:01 +03:00
parent b3aa4c4991
commit 18e1d68a4f
5 changed files with 56 additions and 17 deletions
+4 -4
View File
@@ -20,7 +20,7 @@ import Data.Aeson (Value)
import qualified Data.Text as T
import Data.Time (getCurrentTime)
import Data.Void (Void, absurd)
import HomeAssistant.Controller (HASS, HASSEff (..), lightController)
import HomeAssistant.Controller (HASS, HASSEff (..), bedroomPresenceController)
import HomeAssistant.Runtime.Bus
import HomeAssistant.Runtime.Connection (readerAction, writerAction)
import HomeAssistant.Runtime.Supervisor (defaultBackoff, supervised)
@@ -35,7 +35,7 @@ step nt (Mealy f) a = do
data Controller = forall b. Controller T.Text (HASS (Event Value) b)
controllers :: [Controller]
controllers = [Controller "light" lightController]
controllers = [Controller "bedroom-presence" bedroomPresenceController]
-- | Steps the machine for every inbound message; service calls go to the
-- bus. A restart re-dups the inbound channel and starts from the machine's
@@ -47,7 +47,8 @@ runController bus (Controller _name machine) = do
where
go inbound f = do
msg <- atomically (readTChan inbound)
(_, f') <- step (channelHassEval bus) f (Event msg)
-- (_, f') <- step (channelHassEval bus) f (Event msg)
(_, f') <- step (dryRunHassEval (busGen bus)) f (Event msg)
go inbound f'
defaultMain :: IO ()
@@ -67,4 +68,3 @@ dryRunHassEval gen = \case
CallService x -> do
callId <- generateCallId gen
print (callId, x)
Pure a -> pure a