diff --git a/source/_components/deconz.markdown b/source/_components/deconz.markdown index ae079650aef..0026d0b7f86 100644 --- a/source/_components/deconz.markdown +++ b/source/_components/deconz.markdown @@ -118,9 +118,9 @@ For the IKEA Tradfri remote, 1 is the middle button, 2 is up, 3 is down, 4 is le ## {% linkable_title Examples %} -### {% linkable_title Step up and step down input number with wireless dimmer %} +### {% linkable_title YAML %} -#### YAML +#### {% linkable_title Step up and step down input number with wireless dimmer %} {% raw %} ```yaml @@ -171,15 +171,17 @@ automation: ``` {% endraw %} -#### Appdaemon +### {% linkable_title Appdaemon %} + +#### {% linkable_title Appdaemon remote template %} {% raw %} ```yaml -remote_control_living_room: +remote_control: module: remote_control class: RemoteControl event: deconz_event - id: dimmer_switch_3 + id: dimmer_switch_1 ``` ```python @@ -204,3 +206,53 @@ class RemoteControl(hass.Hass): self.log('Button off') ``` {% endraw %} + +#### {% linkable_title Appdaemon remote template %} + +Community app from Teachingbirds. This app uses an Ikea Tradfri remote to control Sonos speakers with play/pause, volume up and down, next and previous track. + +{% raw %} +```yaml +sonos_remote_control: + module: sonos_remote + class: SonosRemote + event: deconz_event + id: sonos_remote + sonos: media_player.sonos +``` +{% endraw %} + +{% raw %} +```python +import appdaemon.plugins.hass.hassapi as hass + +class SonosRemote(hass.Hass): + + def initialize(self): + self.sonos = self.args['sonos'] + if 'event' in self.args: + self.listen_event(self.handle_event, self.args['event']) + + def handle_event(self, event_name, data, kwargs): + if data['id'] == self.args['id']: + if data['event'] == 1002: + self.log('Button toggle') + self.call_service("media_player/media_play_pause", entity_id = self.sonos) + + elif data['event'] == 2002: + self.log('Button volume up') + self.call_service("media_player/volume_up", entity_id = self.sonos) + + elif data['event'] == 3002: + self.log('Button volume down') + self.call_service("media_player/volume_down", entity_id = self.sonos) + + elif data['event'] == 4002: + self.log('Button previous') + self.call_service("media_player/media_previous_track", entity_id = self.sonos) + + elif data['event'] == 5002: + self.log('Button next') + self.call_service("media_player/media_next_track", entity_id = self.sonos) +``` +{% endraw %}