Update tests
This commit is contained in:
@@ -55,8 +55,7 @@ runController bus (Controller _name machine) = do
|
||||
go inbound f = do
|
||||
msg <- atomically (readTChan inbound)
|
||||
uuid <- UUID.V4.nextRandom
|
||||
-- (_, f') <- step (channelHassEval bus) f (Event msg)
|
||||
(_, f') <- step (dryRunHassEval (busGen bus)) uuid f (Event msg)
|
||||
(_, f') <- step (channelHassEval bus) uuid f (Event msg)
|
||||
go inbound f'
|
||||
|
||||
defaultMain :: IO ()
|
||||
|
||||
@@ -97,6 +97,16 @@ encodeService callId Service{..} = object $
|
||||
, "type" .= ("call_service" :: T.Text)
|
||||
, "domain" .= serviceDomain
|
||||
, "service" .= serviceName
|
||||
, "target" .= object [ "entity_id" .= [e | EntityId e <- serviceTarget]
|
||||
, "area_id" .= [a | AreaId a <- serviceTarget]]
|
||||
] <> maybe [] (\d -> ["data" .= d]) serviceData
|
||||
, "target" .= targetObject serviceTarget
|
||||
] <> maybe [] (\d -> ["service_data" .= d]) serviceData
|
||||
|
||||
-- | A single target encodes as a scalar; multiple encode as a list. Empty
|
||||
-- lists are omitted so Home Assistant receives only populated keys.
|
||||
targetObject :: [Target] -> Value
|
||||
targetObject targets = object $ entityPart <> areaPart
|
||||
where
|
||||
entityPart = emit "entity_id" [e | EntityId e <- targets]
|
||||
areaPart = emit "area_id" [a | AreaId a <- targets]
|
||||
emit _ [] = []
|
||||
emit k [x] = [k .= x]
|
||||
emit k many = [k .= many]
|
||||
|
||||
Reference in New Issue
Block a user