Update deconz.markdown (#6213)

* Update deconz.markdown

Added a helper app in appdaemon for deconz events

* Update deconz.markdown

changes in variables
This commit is contained in:
Isabella Gross Alström 2018-09-07 10:08:49 +02:00 committed by Fabian Affolter
parent 2bd35c0c12
commit 65e6d11a32

View File

@ -173,6 +173,36 @@ automation:
### {% linkable_title Appdaemon %}
#### {% linkable_title Appdaemon event helper %}
Helper app that creates a sensor `sensor.deconz_event` with a state that represents the id from the last event and an attribute to show the event data.
{% raw %}
```yaml
deconz_helper:
module: deconz_helper
class: DeconzHelper
```
```python
import appdaemon.plugins.hass.hassapi as hass
import datetime
from datetime import datetime
class DeconzHelper(hass.Hass):
def initialize(self) -> None:
self.listen_event(self.event_received, "deconz_event")
def event_received(self, event_name, data, kwargs):
event_data = data["event"]
event_id = data["id"]
event_received = datetime.now()
self.log("Deconz event received from {}. Event was: {}".format(event_id, event_data))
self.set_state("sensor.deconz_event", state = event_id, attributes = {"event_data": event_data, "event_received": str(event_received)})
```
{% endraw %}
#### {% linkable_title Appdaemon remote template %}
{% raw %}