diff --git a/apps/controllerx/cx_devices/terncy.py b/apps/controllerx/cx_devices/terncy.py index dd4c4571..2c2273bb 100644 --- a/apps/controllerx/cx_devices/terncy.py +++ b/apps/controllerx/cx_devices/terncy.py @@ -1,5 +1,5 @@ -from cx_const import DefaultActionsMapping, Light -from cx_core import LightController +from cx_const import DefaultActionsMapping, Light, MediaPlayer +from cx_core import LightController, MediaPlayerController from cx_core.integration import EventData @@ -25,6 +25,24 @@ def get_zha_actions_mapping(self) -> DefaultActionsMapping: "button_triple": Light.ON_MIN_BRIGHTNESS, "button_quadruple": Light.SET_HALF_BRIGHTNESS, "button_quintuple": Light.SET_HALF_COLOR_TEMP, + "rotate_left": Light.CLICK_BRIGHTNESS_DOWN, + "rotate_right": Light.CLICK_BRIGHTNESS_UP, + } + + def get_zha_action(self, data: EventData) -> str: + return data["command"] + + +class TerncySD01MediaPlayerController(MediaPlayerController): + def get_zha_actions_mapping(self) -> DefaultActionsMapping: + return { + "button_single": MediaPlayer.PLAY_PAUSE, + "button_double": MediaPlayer.MUTE, + "button_triple": MediaPlayer.NEXT_TRACK, + "button_quadruple": MediaPlayer.PREVIOUS_TRACK, + "button_quintuple": MediaPlayer.NEXT_SOURCE, + "rotate_left": MediaPlayer.CLICK_VOLUME_DOWN, + "rotate_right": MediaPlayer.CLICK_VOLUME_UP, } def get_zha_action(self, data: EventData) -> str: diff --git a/docs/_data/controllers/TERNCY-SD01.yml b/docs/_data/controllers/TERNCY-SD01.yml index f270b6eb..67d7f465 100644 --- a/docs/_data/controllers/TERNCY-SD01.yml +++ b/docs/_data/controllers/TERNCY-SD01.yml @@ -10,6 +10,20 @@ device_support: - "3 clicks → Minimum brightness" - "4 clicks → 50% brightness" - "5 clicks → 50% color temp" + - "Rotate right → Brightness up (1 step)" + - "Rotate left → Brightness down (1 step)" + - type: Media Player + domain: media_player + controller: TerncySD01MediaPlayerController + delay: 350 + mapping: + - "1 click → Play/Pause" + - "2 clicks → Mute" + - "3 clicks → Next track" + - "4 clicks → Previous track" + - "5 clicks → Next source" + - "Rotate right → Volume up (1 step)" + - "Rotate left → Volume down (1 step)" integrations: - name: ZHA codename: zha