Multiple entity_id in automation trigger and service_template, help needed

Hi All,

I’m trying to configure my KERUI D026 door/window sensor to work with HA through rflink component.
Ultimately I need an entity that reflects window’s state - open/closed (on/off) so its state change could be picked up by alarm panel to react upon.

So far the easiest way was to create an input_boolean switch:
input_boolean:
1st_floor_window_detector:
name: “1st floor window detector”
initial: off
icon: mdi:window-closed

make rflink fire event every time it receives a command from the sensor, and in automation that catches these events switch the 1st_floor_window_detector accordingly.
However, I have two problems here.

  1. My sensor sends two different commands on close so I need to catch events from 3 different entities (one for open and 2 for close). I hoped that the following trigger section will work, but it does not:
    • id: catch_1st_floor_window_detector_closed_event
      hide_entity: true
      trigger:
    • platform: event
      event_type: button_pressed
      event_data:
      entity_id: switch.1st_floor_window_closed_detector_1, switch.1st_floor_window_closed_detector_2

I also tried this with the same result:
trigger:
- platform: event
event_type: button_pressed
event_data:
entity_id:
- switch.1st_floor_window_closed_detector_1
- switch.1st_floor_window_closed_detector_2

It just doesn’t match apparently as I can see no action performed.
But if I separate it into pieces it does work:
trigger:
- platform: event
event_type: button_pressed
event_data:
entity_id: switch.1st_floor_window_closed_detector_1
- platform: event
event_type: button_pressed
event_data:
entity_id: switch.1st_floor_window_closed_detector_2

The question is, is it possible to have multiple entity_id at all?

  1. I want to turn my input_boolean on when an open event arrives from switch.1st_floor_window_opened_detector, and off when a close one does from either switch.1st_floor_window_closed_detector_1 or switch.1st_floor_window_closed_detector_2.
    I tried something like
    service_template: >
    {% if {{ trigger.event.data[‘entity_id’] == switch.1st_floor_window_opened_detector }} %}
    input_boolean.turn_on
    {% else %}
    input_boolean.turn_off
    {% endif %}
    entity_id: input_boolean.1st_floor_window_detector

but it didn’t work, apparently a comparison should be done differently.
Could not find the right way to do that, any ideas how to put it right?

And any suggestion in general to my approach are much appreciated as I’m new to all this Python/HA/rflink stuff and haven’t got the whole picture of things yet :wink:

Update: solved the 2nd problem:
service_template: >
{% if trigger.event.data[‘entity_id’] == ‘switch.1st_floor_window_opened_detector’ %}
input_boolean.turn_on
{% else %}
input_boolean.turn_off
{% endif %}
entity_id: input_boolean.1st_floor_window_detector

Could you share your final config/setup

Cheers

Sorry for the long delay.
Are you still interested?
I still have something working, but I’m migrating from RFLink because it’s not reliable.

@AhmadK

Yes, Still interested in the final outcome if you got it working.

I am starting t migrate to zigbee myself, but still have some of these devices around

Well, I still have my RFLink device but it’s mostly used to receive readings from temperature/humidity sensors.
For contacts and PIRs I currently use OMG RF.

Actually, my initial post has answers to both questions, namely:

  1. in event trigger you cannot combine event_data but it works fine separately
  2. when comparing trigger.event.data.entity_id, you need to enclose switch.1st_floor_window_opened_detector in quotes as entity_id is always a string.

Feel free to ask if you need more details.