RFLINK use a remote to perform an action

Hello,

I’ve a RFLink integration, which can detect my small (433Mhz) remotes
The remote comes with 4 button of wich i want to use 2
(1 with an lock symbol and 1 with an unlocked symbol)

When i monitor the logger details is see the followoing information

For Button 1 (unlocked):
2020-08-17 13:46:55 DEBUG (MainThread) [rflink.protocol] received data: 20;06;TriState;
2020-08-17 13:46:55 DEBUG (MainThread) [rflink.protocol] received data: ID=XXYY51;SWITCH=0;CMD=O
2020-08-17 13:46:55 DEBUG (MainThread) [rflink.protocol] received data: FF;
2020-08-17 13:46:55 DEBUG (MainThread) [rflink.protocol] got packet: 20;06;TriState;ID=XXYY51;SWITCH=0;CMD=OFF;
2020-08-17 13:46:55 DEBUG (MainThread) [rflink.protocol] decoded packet: {‘node’: ‘gateway’, ‘protocol’: ‘tristate’, ‘id’: ‘XXYY51’, ‘switch’: ‘0’, ‘command’: ‘off’}
2020-08-17 13:46:55 DEBUG (MainThread) [rflink.protocol] got event: {‘id’: ‘tristate_XXYY51_0’, ‘command’: ‘off’}
2020-08-17 13:46:55 DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {‘id’: ‘tristate_XXYY51_0’, ‘command’: ‘off’}
2020-08-17 13:46:55 DEBUG (MainThread) [homeassistant.components.rflink] entity_ids: [‘light.tristate_XXYY51_0’]
2020-08-17 13:46:55 DEBUG (MainThread) [homeassistant.components.rflink] passing event to light.tristate_XXYY51_0

For Button2 (Locked):
2020-08-17 13:47:37 DEBUG (MainThread) [rflink.protocol] received data: 20;07;TriState;ID=XXYY5
2020-08-17 13:47:37 DEBUG (MainThread) [rflink.protocol] received data: 0;SWITCH=1;CMD=OFF;
2020-08-17 13:47:37 DEBUG (MainThread) [rflink.protocol] got packet: 20;07;TriState;ID=XXYY50;SWITCH=1;CMD=OFF;
2020-08-17 13:47:37 DEBUG (MainThread) [rflink.protocol] decoded packet: {‘node’: ‘gateway’, ‘protocol’: ‘tristate’, ‘id’: ‘XXYY50’, ‘switch’: ‘1’, ‘command’: ‘off’}
2020-08-17 13:47:37 DEBUG (MainThread) [rflink.protocol] got event: {‘id’: ‘tristate_XXYY50_1’, ‘command’: ‘off’}
2020-08-17 13:47:37 DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {‘id’: ‘tristate_XXYY50_1’, ‘command’: ‘off’}
2020-08-17 13:47:37 DEBUG (MainThread) [homeassistant.components.rflink] entity_ids: [‘light.tristate_XXYY50_1’]
2020-08-17 13:47:37 DEBUG (MainThread) [homeassistant.components.rflink] passing event to light.tristate_XXYY50_

I want to have an automation working when i press button (unlocked) it switchws my alarm off and when i press the second button it switches my alarm on
(As shown by Average Automation - https://www.youtube.com/channel/UCMR_eJdL5P6SVJ2n0kTCjlg)

He uses an tasmoto intgration with differnt info.
The following code is to create a button

- platform: mqtt
    state_topic: "tele/tasmota/RESULT"
    name: 'button1'
    value_template: '{{value_json.RfReceived.Data}}'
    payload_on: '2C4528'
    payload_off: '2C4524'
    device_class: lock

I Understand that i need to change the platform and state_topic.
(but to what value for RFLink devices)
What wonders me the most is that my buttons are shown as light and the both produce an "Off"when pressed.
As listed in the “Developers tools/States” page:
image

I see in RFLINK’s documentation that, by default, it represents everything as a light. However, you can define a binary sensor to represent the received code(s).

RFLINK Binary Sensor

It would represent the two states of your remote (lock/unlock). You could use the binary sensor’s state to trigger an automation to perform a desired action.

Note

I don’t own an RFLINK and my suggestion is based exclusively on what I read in the documentation.

Use the event to trigger actions.

E.g. the door sensor on my backdoor sends
ev1527_00bd30_09 on when closed, and ev1527_00bd30_03 on when opened

So in switch.yaml (or in configuration.yaml under switch:) I have

  - platform: rflink
    device_defaults:
      fire_event: true
      signal_repetitions: 2
    devices:
      ev1527_00bd30_09:
        name: achterdeuroff
      ev1527_00bd30_03:  
        name: achterdeuron

and in automations.yaml :

- id: '1567517699999'
  alias: Achterdeur opened
  trigger:
  - event_data:
      entity_id: switch.achterdeuron
    event_type: button_pressed
    platform: event
  condition: []
  action:
  - service: mqtt.publish
    data:
      payload: 'ON'
      topic: sensor/achterdeur
      retain: true
- id: '1567517199999'
  alias: Achterdeur closed
  trigger:
  - event_data:
      entity_id: switch.achterdeuroff
    event_type: button_pressed
    platform: event
  condition: []
  action:
  - service: mqtt.publish
    data:
      payload: 'OFF'
      topic: sensor/achterdeur
      retain: true