Fix the ambience mode
This commit is contained in:
+12
-1
@@ -4,6 +4,7 @@ module Support
|
||||
( Acc(..)
|
||||
, interp
|
||||
, runHASS
|
||||
, runHASSTimed
|
||||
, services
|
||||
, fakeRequest
|
||||
, sec
|
||||
@@ -16,7 +17,7 @@ import Data.Aeson (Value, object, (.=))
|
||||
import qualified Data.Text as T
|
||||
import Data.Time (UTCTime (..), utc)
|
||||
import Data.UUID (nil)
|
||||
import AFRP (Mealy (..), Request (..), stepAuto)
|
||||
import AFRP (Mealy (..), Request (..), stepAuto, Event (..))
|
||||
import HomeAssistant.Controller (HASSEff (..), Service)
|
||||
|
||||
fakeRequest :: Request
|
||||
@@ -56,6 +57,16 @@ runHASS m = go (runMealy m interp)
|
||||
case runAcc (stepAuto w fakeRequest a) [] of
|
||||
((b, w'), svcs) -> (b, svcs) : go w' as
|
||||
|
||||
-- | Run a HASS arrow over a list of (time, input) pairs, collecting per-step
|
||||
-- emitted services. Each step uses a fresh Request with the given UTCTime.
|
||||
runHASSTimed :: Mealy HASSEff (Event a) b -> [(UTCTime, Event a)] -> [(b, [Service])]
|
||||
runHASSTimed m = go (runMealy m interp)
|
||||
where
|
||||
go _ [] = []
|
||||
go w ((t, a) : as) =
|
||||
case runAcc (stepAuto w (Request t utc nil "test") a) [] of
|
||||
((b, w'), svcs) -> (b, svcs) : go w' as
|
||||
|
||||
services :: [(b, [Service])] -> [[Service]]
|
||||
services = map snd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user