I have two enocean buttons (FT55) which are configured with the right IDs.
I wanted to have an automation that fires when an down button is pressed.
after some testing I came up with the below code as I don’t understant why the event trigger is firred for different datasets (up/down and push/relase) which in the event tracker show different data.
The data set in the event_data section is only valid for down pressed (not released, not up pressed/released) but it fires even for my second enocean swith with another id!
This automation
- id: '1575181929836'
alias: enocean_action
description: ''
trigger:
- event_data:
data:
id:
- 254
- 242
- 255
- 31
onoff: 1
pushed: 1
which: 0
event_type: button_pressed
platform: event
condition: []
action:
service: notify.telegram
data_template:
message: >-
{% if ((trigger.event.data.pushed == 1) and (trigger.event.data.onoff == 1)) %} down pressed
{% elif ((trigger.event.data.pushed == 0) and (trigger.event.data.onoff == 1)) %} down released
{% elif ((trigger.event.data.pushed == 1) and (trigger.event.data.onoff == 0)) %} up pressed
{% elif ((trigger.event.data.pushed == 0) and (trigger.event.data.onoff == 0)) %} up released
{%endif %}
I assume that the long id under “context” is the unique identifier of your switch. Try to incorporate this is your trigger. (Can’t help right now as I’m on the phone)
thanks for the hints, I think I did almost the same as explained in the first post you mentioned.
My problem just is how to see which of the switches has fired (so the ones with different FT55 id).
At the moment the automation fires each time I press any button on any of my two switches. The result with pressed / released and up / down is working fine although I thought the trigger.event would check the data of the event and I would not have to double check with 4 if statements.
May be I just did not understand the trigger.event right.
I thought:
there is event 1(e.g. button_pressed) with data set [a, b,c, d] --> trigger only automation that has this data in the event_data block and is referring to a button_pressed event.
there is event 2 (also button_pressed) with data set [a, b, e, f] --> trigger only automation that has this data and is referring to a button_pressed event
At the moment it looks like the trigger is firing on button_pressed, what ever data set is coming.
So this would be just a great misinterpretation on my side and would explain the results as I see them.
So, what would be the right trigger for my intended use case then?
Or do I just have to write a lengthy if elif statement, possibly nested as seen in one of the threads Taras has mentioned?
If so, why do I have to give the event_data in the automation if it’s basically given to the trigger in the background???
Still not absolutely clear but willing to understand what the logic is that has to be used.
event_data in the trigger is actually data in the event. Yeah, confusing.
Also, the way the event trigger works is, whatever you specify, if it’s present in the event, then it must match. But it doesn’t have to be present. So since you (unknowingly) specified data.data...