diff --git a/src/HomeAssistant/Controller/Bedroom.hs b/src/HomeAssistant/Controller/Bedroom.hs index a94f94c..aa1574a 100644 --- a/src/HomeAssistant/Controller/Bedroom.hs +++ b/src/HomeAssistant/Controller/Bedroom.hs @@ -129,6 +129,9 @@ bedroomButtonController = proc x -> do callService "scene.makuuhuone_keski" (activateScene "scene.makuuhuone_keski") -< () Event (Masse (OnButton LongClick)) -> do callService "scene.makuuhuone_kirkas" (activateScene "scene.makuuhuone_kirkas") -< () + Event (Masse (OffButton LongClick)) -> do + callService "Lights off" (light [AreaId "makuuhuone"] Off) -< () + callService "Hallway lights off" (light [EntityId "light.hallway_lights"] Off) -< () Event (Masse (OffButton _)) -> do callService "Lights off" (light [AreaId "makuuhuone"] Off) -< () Event (Enishen (OnButton ShortRelease)) -> do @@ -137,6 +140,9 @@ bedroomButtonController = proc x -> do callService "scene.makuuhuone_keski" (activateScene "scene.makuuhuone_keski") -< () Event (Enishen (OnButton LongClick)) -> do callService "scene.makuuhuone_kirkas" (activateScene "scene.makuuhuone_kirkas") -< () + Event (Enishen (OffButton LongClick)) -> do + callService "Lights off" (light [AreaId "makuuhuone"] Off) -< () + callService "Hallway lights off" (light [EntityId "light.hallway_lights"] Off) -< () Event (Enishen (OffButton _)) -> do callService "Lights off" (light [AreaId "makuuhuone"] Off) -< () _ -> returnA -< () diff --git a/test/BedroomSpec.hs b/test/BedroomSpec.hs index fa09837..b7cacdd 100644 --- a/test/BedroomSpec.hs +++ b/test/BedroomSpec.hs @@ -195,6 +195,14 @@ buttonSpec = describe "bedroomButtonController" $ do concat (services (runHASS bedroomButtonController [masseButton "2_short_release"])) `shouldContain` [light [area] Off] + it "Masse long off click also turns the hallway lights off" $ + concat (services (runHASS bedroomButtonController [masseButton "2_long_press"])) + `shouldContain` [light [EntityId "light.hallway_lights"] Off] + + it "Masse short off click leaves the hallway lights alone" $ + concat (services (runHASS bedroomButtonController [masseButton "2_short_release"])) + `shouldNotContain` [light [EntityId "light.hallway_lights"] Off] + it "Enishen single click turns on her nightstand scene (lowest)" $ concat (services (runHASS bedroomButtonController [enishenButton "1_short_release"])) `shouldContain` [activateScene "scene.makuuhuone_jemina"] @@ -211,6 +219,10 @@ buttonSpec = describe "bedroomButtonController" $ do concat (services (runHASS bedroomButtonController [enishenButton "2_short_release"])) `shouldContain` [light [area] Off] + it "Enishen long off click also turns the hallway lights off" $ + concat (services (runHASS bedroomButtonController [enishenButton "2_long_press"])) + `shouldContain` [light [EntityId "light.hallway_lights"] Off] + it "ignores the initial press (scene only fires on release)" $ services (runHASS bedroomButtonController [masseButton "1_initial_press"]) `shouldBe` [[]]