Skip to content

Commit

Permalink
feat(device): add media player controller for TerncySD01
Browse files Browse the repository at this point in the history
related to #377
  • Loading branch information
xaviml committed Oct 28, 2021
1 parent 89faa1a commit fefc989
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
22 changes: 20 additions & 2 deletions apps/controllerx/cx_devices/terncy.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions docs/_data/controllers/TERNCY-SD01.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fefc989

Please sign in to comment.