From 3695c23d7dce0c6b6eff1c7c402b3c92f53fadd1 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Wed, 8 Mar 2017 10:17:48 +0100 Subject: [PATCH] binary_sensor.enocean: document button events (#2145) * binary_sensor.enocean: document button events Add documentation for the generated button_press events of the switch. * binary_sensor.enocean: add example automation * binary_sensor.enocean: avoid template rendering --- .../binary_sensor.enocean.markdown | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/source/_components/binary_sensor.enocean.markdown b/source/_components/binary_sensor.enocean.markdown index 0eac8e25db1..d817fd1ea22 100644 --- a/source/_components/binary_sensor.enocean.markdown +++ b/source/_components/binary_sensor.enocean.markdown @@ -29,3 +29,28 @@ Configuration variables: - **id** (*Required*): The ID of the device. This is the 4 bytes long number written on the dimmer. - **name** (*Optional*): An identifier for the switch in the frontend. - **device_class** (*Optional*): The [type/class](/components/binary_sensor/) of the sensor to set the icon in the frontend. + +EnOcean binary sensors only generate 'button_pressed' events. The event data has follwing four fields: + + - **id**: The ID of the device (see configuration). + - **pushed**: `1` for a button press, `0` for a button release. + - **which**: Always `0` when using the single rocket. `0` or `1` when using the dual rocket switch. + - **onoff**: `0` or `1` for either side of the rocket. + +Sample automation to switch lights on and off: + +```yaml +# Example automation to turn lights on/off on button release +automation: + - alias: hall light switches + trigger: + platform: event + event_type: button_pressed + event_data: + id: [0xYY, 0xYY, 0xYY, 0xYY] + pushed: 0 + action: + service_template: "{% raw %}{% if trigger.event.data.onoff %} light.turn_on {% else %} light.turn_off {%endif %}{% endraw %}" + data_template: + entity_id: "{% raw %}{% if trigger.event.data.which == 1 %} light.hall_left {% else %} light.hall_right {%endif %}{% endraw %}" +```