diff --git a/src/HomeAssistant/Controller.hs b/src/HomeAssistant/Controller.hs index aeb06bb..d76781a 100644 --- a/src/HomeAssistant/Controller.hs +++ b/src/HomeAssistant/Controller.hs @@ -40,7 +40,7 @@ module HomeAssistant.Controller , activateScene , activateSceneWith , ikeaBoxRemote - , IkeaController(..) + , IkeaRemoteAction(..) , LightAttributes(..) , Brightness(..) , formatLightAttributes @@ -301,28 +301,28 @@ ikeaQuickButton entityId = where eventType v = v ^? key "event" . key "variables" . key "trigger" . key "to_state" . key "attributes" . key "event_type" . _String . to toIkeaQuickButton . traversed -data IkeaController - = ControllerOn -- Short press on - | ControllerOff -- Short press off - | ControllerBrighnessUp -- Turn brightness up - | ControllerBrighnessDown -- Turn brighness down - | ControllerArrowRight -- Turn brighness down - | ControllerArrowLeft -- Turn brighness down - | ControllerBrighnessStop +data IkeaRemoteAction + = RemoteOn -- Short press on + | RemoteOff -- Short press off + | RemoteBrightnessUp -- Turn brightness up + | RemoteBrightnessDown -- Turn brightness down + | RemoteArrowRight -- Arrow right + | RemoteArrowLeft -- Arrow left + | RemoteBrightnessStop deriving Show -toIkeaController :: T.Text -> Maybe IkeaController +toIkeaController :: T.Text -> Maybe IkeaRemoteAction toIkeaController = \case - "on" -> Just ControllerOn - "off" -> Just ControllerOff - "brightness_move_up" -> Just ControllerBrighnessUp - "brightness_move_down" -> Just ControllerBrighnessDown - "brightness_stop" -> Just ControllerBrighnessStop - "arrow_right_click" -> Just ControllerArrowRight - "arrow_left_click" -> Just ControllerArrowLeft + "on" -> Just RemoteOn + "off" -> Just RemoteOff + "brightness_move_up" -> Just RemoteBrightnessUp + "brightness_move_down" -> Just RemoteBrightnessDown + "brightness_stop" -> Just RemoteBrightnessStop + "arrow_right_click" -> Just RemoteArrowRight + "arrow_left_click" -> Just RemoteArrowLeft _ -> Nothing -ikeaBoxRemote :: T.Text -> HASS (Event Value) (Event IkeaController) +ikeaBoxRemote :: T.Text -> HASS (Event Value) (Event IkeaRemoteAction) ikeaBoxRemote entityId = entityChangeEvent' entityId >>| arr (maybe (Left ()) Right . eventType) >>> toEvent diff --git a/src/HomeAssistant/Controller/Bedroom.hs b/src/HomeAssistant/Controller/Bedroom.hs index 6d5fd0f..a0ebda2 100644 --- a/src/HomeAssistant/Controller/Bedroom.hs +++ b/src/HomeAssistant/Controller/Bedroom.hs @@ -85,7 +85,7 @@ bedroomPresenceController = proc x -> do data BedroomControls = Masse (IkeaButton IkeaGesture) | Enishen (IkeaButton IkeaGesture) - | Central IkeaController + | Central IkeaRemoteAction deriving Show