Add target exclusions to service calls
Services can now carry excluded targets, encoded as target.exclude in the WebSocket payload. The children's bedroom lights-off calls skip lights labelled 'decoration'.
This commit is contained in:
1 parent
383143024a
commit
9c89504399
15 files changed
+115
-86
No files matched your search
+15
-15
@@ -85,18 +85,18 @@ drawerSpec = describe "bedroomDrawerController" $ do
|
||||
|
||||
it "turns the drawer light on when the drawer opens" $
|
||||
services (runHASS bedroomDrawerController [drawerState "on"])
|
||||
`shouldBe` [[switchService [entity] True]]
|
||||
`shouldBe` [[switchService [entity] [] True]]
|
||||
|
||||
it "turns the drawer light off when the drawer closes" $
|
||||
services (runHASS bedroomDrawerController [drawerState "off"])
|
||||
`shouldBe` [[switchService [entity] False]]
|
||||
`shouldBe` [[switchService [entity] [] False]]
|
||||
|
||||
it "toggles the light as the drawer opens and closes" $
|
||||
services (runHASS bedroomDrawerController
|
||||
[ drawerState "on", drawerState "off", drawerState "on" ])
|
||||
`shouldBe` [ [switchService [entity] True]
|
||||
, [switchService [entity] False]
|
||||
, [switchService [entity] True]
|
||||
`shouldBe` [ [switchService [entity] [] True]
|
||||
, [switchService [entity] [] False]
|
||||
, [switchService [entity] [] True]
|
||||
]
|
||||
|
||||
it "ignores state events for other entities" $
|
||||
@@ -146,12 +146,12 @@ presenceSpec = describe "bedroomPresenceController" $ do
|
||||
let later = 305 `addUTCTime` now
|
||||
services (runHASSTimed bedroomPresenceController
|
||||
[ (now, presenceSensor "on"), (now, presenceSensor "off"), (later, Tick) ])
|
||||
`shouldBe` [ [], [], [light bedroomLightTargets Off] ]
|
||||
`shouldBe` [ [], [], [light bedroomLightTargets [] Off] ]
|
||||
|
||||
it "restores the last snapshot when re-entering after sleep" $ do
|
||||
now <- getCurrentTime
|
||||
let later = 350 `addUTCTime` now
|
||||
let masseRestored = light [EntityId "light.bedroom_masse"] (On def
|
||||
let masseRestored = light [EntityId "light.bedroom_masse"] [] (On def
|
||||
{ lightBrightness = Just (BrightnessAbsolute 140)
|
||||
, lightColorTemperature = Just 2700
|
||||
})
|
||||
@@ -167,9 +167,9 @@ presenceSpec = describe "bedroomPresenceController" $ do
|
||||
, []
|
||||
, [sleepScene]
|
||||
, []
|
||||
, [ light [EntityId "light.bedroom_ceiling"] Off
|
||||
, light [EntityId "light.bedroom_jemina"] Off
|
||||
, light [EntityId "light.bedroom_led_switch"] Off
|
||||
, [ light [EntityId "light.bedroom_ceiling"] [] Off
|
||||
, light [EntityId "light.bedroom_jemina"] [] Off
|
||||
, light [EntityId "light.bedroom_led_switch"] [] Off
|
||||
, masseRestored
|
||||
]
|
||||
, []
|
||||
@@ -193,15 +193,15 @@ buttonSpec = describe "bedroomButtonController" $ do
|
||||
|
||||
it "Masse off click turns the bedroom lights off" $
|
||||
concat (services (runHASS bedroomButtonController [masseButton "2_short_release"]))
|
||||
`shouldContain` [light [area] Off]
|
||||
`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]
|
||||
`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]
|
||||
`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"]))
|
||||
@@ -217,11 +217,11 @@ buttonSpec = describe "bedroomButtonController" $ do
|
||||
|
||||
it "Enishen off click turns the bedroom lights off" $
|
||||
concat (services (runHASS bedroomButtonController [enishenButton "2_short_release"]))
|
||||
`shouldContain` [light [area] Off]
|
||||
`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]
|
||||
`shouldContain` [light [EntityId "light.hallway_lights"] [] Off]
|
||||
|
||||
it "ignores the initial press (scene only fires on release)" $
|
||||
services (runHASS bedroomButtonController [masseButton "1_initial_press"])
|
||||
|
||||
Reference in new issue
Block a user