Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for E1810 as media player controller #11

Merged
merged 2 commits into from
Jan 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions apps/z2m_ikea_controller/z2m_ikea_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,14 @@ async def previous_track(self):
async def next_track(self):
self.call_service("media_player/media_next_track", entity_id=self.media_player)

@action
async def volume_up(self):
self.call_service("media_player/volume_up", entity_id=self.media_player)

@action
async def volume_down(self):
self.call_service("media_player/volume_down", entity_id=self.media_player)

@action
async def hold(self, direction):
# This variable is responsible to count how many times hold_loop has been called
Expand Down Expand Up @@ -580,6 +588,41 @@ def get_event_actions_mapping(self):
}


class E1810MediaPlayerController(MediaPlayerController):
# Different states reported from the controller:
# toggle, brightness_up_click, brightness_down_click
# arrow_left_click, arrow_right_click, brightness_up_hold
# brightness_up_release, brightness_down_hold, brightness_down_release,
# arrow_left_hold, arrow_left_release, arrow_right_hold
# arrow_right_release

def get_state_actions_mapping(self):
return {
"toggle": self.play_pause,
"brightness_up_click": self.volume_up,
"brightness_down_click": self.volume_down,
"arrow_left_click": self.previous_track,
"arrow_right_click": self.next_track,
"brightness_up_hold": (self.hold, Controller.DIRECTION_UP),
"brightness_up_release": self.release,
"brightness_down_hold": (self.hold, Controller.DIRECTION_DOWN),
"brightness_down_release": self.release,
}

def get_event_actions_mapping(self):
return {
1002: self.play_pause,
2002: self.volume_up,
3002: self.volume_down,
4002: self.previous_track,
5002: self.next_track,
2001: (self.hold, Controller.DIRECTION_UP),
2003: self.release,
3001: (self.hold, Controller.DIRECTION_DOWN),
3003: self.release,
}


class E1743Controller(LightController):
# Different states reported from the controller:
# on, off, brightness_up, brightness_down, brightness_stop
Expand Down