Rename switch to switchService to avoid AFRP name conflict
This commit is contained in:
@@ -27,7 +27,7 @@ module HomeAssistant.Controller
|
|||||||
, debug
|
, debug
|
||||||
, traceEvent
|
, traceEvent
|
||||||
, traceValue
|
, traceValue
|
||||||
, switch
|
, switchService
|
||||||
, Target(..)
|
, Target(..)
|
||||||
, lightBrightnessEvent
|
, lightBrightnessEvent
|
||||||
, lightTemperatureEvent
|
, lightTemperatureEvent
|
||||||
@@ -199,9 +199,8 @@ light targets Off = Service
|
|||||||
, serviceTarget=targets
|
, serviceTarget=targets
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Name conflict with AFRP
|
switchService :: [Target] -> Bool -> Service
|
||||||
switch :: [Target] -> Bool -> Service
|
switchService targets b = Service
|
||||||
switch targets b = Service
|
|
||||||
{ serviceDomain="switch"
|
{ serviceDomain="switch"
|
||||||
, serviceName= bool "turn_off" "turn_on" b
|
, serviceName= bool "turn_off" "turn_on" b
|
||||||
, serviceData=Nothing
|
, serviceData=Nothing
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ bedroomDrawerController :: HASS (Event Value) ()
|
|||||||
bedroomDrawerController = proc x -> do
|
bedroomDrawerController = proc x -> do
|
||||||
st <- drawer >>> traceEvent -< x
|
st <- drawer >>> traceEvent -< x
|
||||||
case st of
|
case st of
|
||||||
Event Open -> callService (switch [entity] True) -< ()
|
Event Open -> callService (switchService [entity] True) -< ()
|
||||||
Event Closed -> callService (switch [entity] False) -< ()
|
Event Closed -> callService (switchService [entity] False) -< ()
|
||||||
_ -> returnA -< ()
|
_ -> returnA -< ()
|
||||||
where
|
where
|
||||||
entity = EntityId "switch.bedroom_drawer_light_masse"
|
entity = EntityId "switch.bedroom_drawer_light_masse"
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ dinnerTableController = proc x -> do
|
|||||||
sleep -< True
|
sleep -< True
|
||||||
_ -> returnA -< ()
|
_ -> returnA -< ()
|
||||||
where
|
where
|
||||||
sleep = callServiceDyn (switch [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"])
|
sleep = callServiceDyn (switchService [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"])
|
||||||
|
|
||||||
kitchenMotionController :: HASS (Event Value) ()
|
kitchenMotionController :: HASS (Event Value) ()
|
||||||
kitchenMotionController = kitchenCeilingController <> dinnerTableController
|
kitchenMotionController = kitchenCeilingController <> dinnerTableController
|
||||||
|
|||||||
+5
-5
@@ -62,18 +62,18 @@ drawerSpec = describe "bedroomDrawerController" $ do
|
|||||||
|
|
||||||
it "turns the drawer light on when the drawer opens" $
|
it "turns the drawer light on when the drawer opens" $
|
||||||
services (runHASS bedroomDrawerController [drawerState "on"])
|
services (runHASS bedroomDrawerController [drawerState "on"])
|
||||||
`shouldBe` [[switch [entity] True]]
|
`shouldBe` [[switchService [entity] True]]
|
||||||
|
|
||||||
it "turns the drawer light off when the drawer closes" $
|
it "turns the drawer light off when the drawer closes" $
|
||||||
services (runHASS bedroomDrawerController [drawerState "off"])
|
services (runHASS bedroomDrawerController [drawerState "off"])
|
||||||
`shouldBe` [[switch [entity] False]]
|
`shouldBe` [[switchService [entity] False]]
|
||||||
|
|
||||||
it "toggles the light as the drawer opens and closes" $
|
it "toggles the light as the drawer opens and closes" $
|
||||||
services (runHASS bedroomDrawerController
|
services (runHASS bedroomDrawerController
|
||||||
[ drawerState "on", drawerState "off", drawerState "on" ])
|
[ drawerState "on", drawerState "off", drawerState "on" ])
|
||||||
`shouldBe` [ [switch [entity] True]
|
`shouldBe` [ [switchService [entity] True]
|
||||||
, [switch [entity] False]
|
, [switchService [entity] False]
|
||||||
, [switch [entity] True]
|
, [switchService [entity] True]
|
||||||
]
|
]
|
||||||
|
|
||||||
it "ignores state events for other entities" $
|
it "ignores state events for other entities" $
|
||||||
|
|||||||
+3
-3
@@ -35,12 +35,12 @@ dinnerTableSpec = describe "dinnerTableController" $ do
|
|||||||
|
|
||||||
it "turns lights on when presence is occupied and light level is low" $ do
|
it "turns lights on when presence is occupied and light level is low" $ do
|
||||||
services (runHASS dinnerTableController [testDinnerLightLevel 10, testDinnerPresence "on"])
|
services (runHASS dinnerTableController [testDinnerLightLevel 10, testDinnerPresence "on"])
|
||||||
`shouldBe` [[switch [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"] True], [switch [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"] False, light [EntityId "light.kitchen_dining_large"] (On def)]]
|
`shouldBe` [[switchService [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"] True], [switchService [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"] False, light [EntityId "light.kitchen_dining_large"] (On def)]]
|
||||||
|
|
||||||
it "turns lights off when presence is unoccupied" $ do
|
it "turns lights off when presence is unoccupied" $ do
|
||||||
services (runHASS dinnerTableController [testDinnerLightLevel 10, testDinnerPresence "off"])
|
services (runHASS dinnerTableController [testDinnerLightLevel 10, testDinnerPresence "off"])
|
||||||
`shouldBe` [[switch [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"] True], []]
|
`shouldBe` [[switchService [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"] True], []]
|
||||||
|
|
||||||
it "does nothing on Tick" $ do
|
it "does nothing on Tick" $ do
|
||||||
services (runHASS dinnerTableController [Tick])
|
services (runHASS dinnerTableController [Tick])
|
||||||
`shouldBe` [[switch [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"] True]]
|
`shouldBe` [[switchService [EntityId "switch.adaptive_lighting_ruokapoydan_valot_sleep_mode"] True]]
|
||||||
|
|||||||
Reference in New Issue
Block a user