Fix tests

This commit is contained in:
2026-09-24 10:06:20 +03:00
parent b2a74cbee4
commit 69cac934ec
2 changed files with 41 additions and 27 deletions
+24 -11
View File
@@ -87,17 +87,30 @@ bedroomButtonController = proc x -> do
ev <- bedroomButton >>> traceEvent -< x ev <- bedroomButton >>> traceEvent -< x
-- Any event will cause the sleep mode to be turned off -- Any event will cause the sleep mode to be turned off
case ev of case ev of
Event _ -> sleepMode -< False Event (Masse (OnButton ShortRelease)) -> do
_ -> returnA -< () sleepMode -< False
case ev of callService (activateScene "scene.makuuhuone_masse") -< ()
Event (Masse (OnButton ShortRelease)) -> callService (activateScene "scene.makuuhuone_masse") -< () Event (Masse (OnButton DoubleClick)) -> do
Event (Masse (OnButton DoubleClick)) -> callService (activateScene "scene.makuuhuone_keski") -< () sleepMode -< False
Event (Masse (OnButton LongClick)) -> callService (activateScene "scene.makuuhuone_kirkas") -< () callService (activateScene "scene.makuuhuone_keski") -< ()
Event (Masse (OffButton _)) -> callService (light [AreaId "makuuhuone"] Off) -< () Event (Masse (OnButton LongClick)) -> do
Event (Enishen (OnButton ShortRelease)) -> callService (activateScene "scene.makuuhuone_jemina") -< () sleepMode -< False
Event (Enishen (OnButton DoubleClick)) -> callService (activateScene "scene.makuuhuone_keski") -< () callService (activateScene "scene.makuuhuone_kirkas") -< ()
Event (Enishen (OnButton LongClick)) -> callService (activateScene "scene.makuuhuone_kirkas") -< () Event (Masse (OffButton _)) -> do
Event (Enishen (OffButton _)) -> callService (light [AreaId "makuuhuone"] Off) -< () sleepMode -< False
callService (light [AreaId "makuuhuone"] Off) -< ()
Event (Enishen (OnButton ShortRelease)) -> do
sleepMode -< False
callService (activateScene "scene.makuuhuone_jemina") -< ()
Event (Enishen (OnButton DoubleClick)) -> do
sleepMode -< False
callService (activateScene "scene.makuuhuone_keski") -< ()
Event (Enishen (OnButton LongClick)) -> do
sleepMode -< False
callService (activateScene "scene.makuuhuone_kirkas") -< ()
Event (Enishen (OffButton _)) -> do
sleepMode -< False
callService (light [AreaId "makuuhuone"] Off) -< ()
_ -> returnA -< () _ -> returnA -< ()
where where
sleepMode = callServiceDyn (switch [EntityId "switch.adaptive_lighting_makuuhuoneen_valot_sleep_mode"] ) sleepMode = callServiceDyn (switch [EntityId "switch.adaptive_lighting_makuuhuoneen_valot_sleep_mode"] )
+17 -16
View File
@@ -45,6 +45,7 @@ entitySpec = describe "entities" $ do
`shouldBe` S.fromList `shouldBe` S.fromList
[ "event.bedroom_quick_remote_masse_action" [ "event.bedroom_quick_remote_masse_action"
, "event.bedroom_quick_jemina_action" , "event.bedroom_quick_jemina_action"
, "event.bedroom_remote_action"
] ]
it "bedroomPresenceController subscribes to the presence sensor" $ it "bedroomPresenceController subscribes to the presence sensor" $
@@ -89,36 +90,36 @@ buttonSpec = describe "bedroomButtonController" $ do
let area = AreaId "makuuhuone" let area = AreaId "makuuhuone"
it "Masse single click turns on his nightstand scene (lowest)" $ it "Masse single click turns on his nightstand scene (lowest)" $
services (runHASS bedroomButtonController [masseButton "1_short_release"]) concat (services (runHASS bedroomButtonController [masseButton "1_short_release"]))
`shouldBe` [[activateScene "scene.makuuhuone_masse"]] `shouldContain` [activateScene "scene.makuuhuone_masse"]
it "Masse double click turns on the middle scene" $ it "Masse double click turns on the middle scene" $
services (runHASS bedroomButtonController [masseButton "1_double_press"]) concat (services (runHASS bedroomButtonController [masseButton "1_double_press"]))
`shouldBe` [[activateScene "scene.makuuhuone_keski"]] `shouldContain` [activateScene "scene.makuuhuone_keski"]
it "Masse long click turns on the bright scene" $ it "Masse long click turns on the bright scene" $
services (runHASS bedroomButtonController [masseButton "1_long_press"]) concat (services (runHASS bedroomButtonController [masseButton "1_long_press"]))
`shouldBe` [[activateScene "scene.makuuhuone_kirkas"]] `shouldContain` [activateScene "scene.makuuhuone_kirkas"]
it "Masse off click turns the bedroom lights off" $ it "Masse off click turns the bedroom lights off" $
services (runHASS bedroomButtonController [masseButton "2_short_release"]) concat (services (runHASS bedroomButtonController [masseButton "2_short_release"]))
`shouldBe` [[light [area] Off]] `shouldContain` [light [area] Off]
it "Enishen single click turns on her nightstand scene (lowest)" $ it "Enishen single click turns on her nightstand scene (lowest)" $
services (runHASS bedroomButtonController [enishenButton "1_short_release"]) concat (services (runHASS bedroomButtonController [enishenButton "1_short_release"]))
`shouldBe` [[activateScene "scene.makuuhuone_jemina"]] `shouldContain` [activateScene "scene.makuuhuone_jemina"]
it "Enishen double click turns on the middle scene" $ it "Enishen double click turns on the middle scene" $
services (runHASS bedroomButtonController [enishenButton "1_double_press"]) concat (services (runHASS bedroomButtonController [enishenButton "1_double_press"]))
`shouldBe` [[activateScene "scene.makuuhuone_keski"]] `shouldContain` [activateScene "scene.makuuhuone_keski"]
it "Enishen long click turns on the bright scene" $ it "Enishen long click turns on the bright scene" $
services (runHASS bedroomButtonController [enishenButton "1_long_press"]) concat (services (runHASS bedroomButtonController [enishenButton "1_long_press"]))
`shouldBe` [[activateScene "scene.makuuhuone_kirkas"]] `shouldContain` [activateScene "scene.makuuhuone_kirkas"]
it "Enishen off click turns the bedroom lights off" $ it "Enishen off click turns the bedroom lights off" $
services (runHASS bedroomButtonController [enishenButton "2_short_release"]) concat (services (runHASS bedroomButtonController [enishenButton "2_short_release"]))
`shouldBe` [[light [area] Off]] `shouldContain` [light [area] Off]
it "ignores the initial press (scene only fires on release)" $ it "ignores the initial press (scene only fires on release)" $
services (runHASS bedroomButtonController [masseButton "1_initial_press"]) services (runHASS bedroomButtonController [masseButton "1_initial_press"])