Create a button fromm YAML

Hello,

I hope my question is in the right place , if not please advise where to ask.

I have a Kerui sirene/flash light with a remote control configured on 433mHZ (RFLink)
I managed to get the remote buttons read out and tested in developer-tools/service.
My problem is that both action is a allon.
Any advise how to get this in a button with current state?

Sirene On:

service: rflink.send_command
data:
  command: allon
  device_id: ev1527_

Sirene Off:

service: rflink.send_command
data:
  command: allon
  device_id: eurodomest_

Define a switch with the two states/actions of the sirene. Then you can use the switch in a button.

Tried to add:

  - platform: template
    switches:
      sirene:
        value_template: "{{ is_state('switch.source', 'on') }}"
        turn_on:
          - service: rflink.send_command
            target:
              entity_id: "lev1527_084194_08"
            data:
              command: allon
        turn_off:
          - service: rflink.send_command
            target:
              entity_id: "eurodomest_07be6b_06"
            data:
              command: allon

But this results in an error when i trie to validate,

Invalid config for [switch.template]:
not a valid value for dictionary value @ data[‘switches’][‘sirene’][‘turn_off’][0][‘target’][‘entity_id’]. Got ‘eurodomest_07be6b_06’
not a valid value for dictionary value @ data[‘switches’][‘sirene’][‘turn_on’][0][‘target’][‘entity_id’]. Got ‘lev1527_084194_08’. (See ?, line ?).

Entity id should be something like sensor.rflink_device

I’m not familiar with rflink, but I found a possibility to define rflink switches.

Managed to get the switches assigned.
switch.sirene_aan doesnt work, switch.sirene_uit is

now need to find a way to get the switch.sirene working
When i use the switch from the template i get the folling error:
Failed to call the service/switch.turn_on: extra keys not allowed @ data [‘device_id’]

switch:
      lev1527_:
        name: "sirene_aan"
      eurodomest_:
        name: "sirene_uit"

  - platform: template
    switches:
      sirene:
        value_template: "{{ is_state('switch.source', 'on') }}"
        turn_on:
          - service: rflink.send_command
            target:
              entity_id: switch.sirene_aan
            data:
              command: "allon"
        turn_off:
          - service: rflink.send_command
            target:
              entity_id: switch.sirene_uit
            data:
              command: "allon"

I guess the command should be smth like

        turn_off:
          - service: rflink.send_command
            data:
              command: "allon"
              device_id: 'lev1527_084194_08'

and smth similar for turn_on.
You may expriement under Developer Tools->Services

Managed to get it to work with the following:

switch:
  - platform: rflink
    devices:
      ev1527_084194_08:
        name: "sirene_aan"
      eurodomest_07be6b_06:
        name: "sirene_uit"

  - platform: template
    switches:
      sirene:
        value_template: "{{ is_state('switch.source', 'allon') }}"
        turn_on:
          - service: rflink.send_command
            data:
              command: "allon"
              device_id: 'ev1527_084194_08'
        turn_off:
          - service: rflink.send_command
            data:
              command: allon
              device_id: eurodomest_07be6b_06

Thank you very much for thinking with me…

I’m glad you sorted it out.