Triggers instead of full state events
This commit is contained in:
+32
-1
@@ -2,7 +2,8 @@
|
||||
|
||||
module BedroomSpec (spec) where
|
||||
|
||||
import AFRP (Event (..))
|
||||
import AFRP (Event (..), entities)
|
||||
import qualified Data.Set as S
|
||||
import qualified Data.Text as T
|
||||
import Data.Aeson (Value)
|
||||
import HomeAssistant.Controller
|
||||
@@ -21,9 +22,39 @@ drawerState = Event . stateEvent "binary_sensor.bedroom_nightstand_drawer_sensor
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Bedroom" $ do
|
||||
entitySpec
|
||||
drawerSpec
|
||||
buttonSpec
|
||||
|
||||
entitySpec :: Spec
|
||||
entitySpec = describe "entities" $ do
|
||||
it "entityChangeEvent' registers its entity id" $
|
||||
entities (entityChangeEvent' "sensor.foo")
|
||||
`shouldBe` S.singleton "sensor.foo"
|
||||
|
||||
it "entityRead / entityBool inherit the entity id" $ do
|
||||
entities (entityRead @Double "sensor.bar") `shouldBe` S.singleton "sensor.bar"
|
||||
entities (entityBool "binary_sensor.baz") `shouldBe` S.singleton "binary_sensor.baz"
|
||||
|
||||
it "bedroomDrawerController subscribes to the drawer sensor" $
|
||||
entities bedroomDrawerController
|
||||
`shouldBe` S.singleton "binary_sensor.bedroom_nightstand_drawer_sensor_masse_contact"
|
||||
|
||||
it "bedroomButtonController subscribes to both remote event entities" $
|
||||
entities bedroomButtonController
|
||||
`shouldBe` S.fromList
|
||||
[ "event.bedroom_quick_remote_masse_action"
|
||||
, "event.bedroom_quick_jemina_action"
|
||||
]
|
||||
|
||||
it "bedroomPresenceController subscribes to the presence sensor" $
|
||||
entities bedroomPresenceController
|
||||
`shouldBe` S.singleton "binary_sensor.presence_sensor_bedroom_occupancy"
|
||||
|
||||
it "humidifierController subscribes to the door sensor" $
|
||||
entities humidifierController
|
||||
`shouldBe` S.singleton "binary_sensor.makuuhuone_ovi_contact"
|
||||
|
||||
drawerSpec :: Spec
|
||||
drawerSpec = describe "bedroomDrawerController" $ do
|
||||
let entity = EntityId "switch.bedroom_drawer_light_masse"
|
||||
|
||||
Reference in New Issue
Block a user