Remote_receiver RF 433

I’m having trouble with the code for the following situation:

I want to implement gate control using remote_receiver. In this case, I’ll have several remotes and only one switch as an implementation, without creating dozens of binary_sensors.

my code for a control:

binary_sensor:
  - platform: remote_receiver
    id: RC1
    name: "RC1"
    rc_switch_raw:
      code: "0000101000010110110101110101" #Intelbras novo
      protocol: 6
    filters:
      delayed_off: 300ms
    on_state:
      - while:
          condition:
            binary_sensor.is_on: RC1
          then:
            - switch.turn_on: portao
            - delay: 500ms
            - switch.turn_off: portao
            - delay: 500ms
switch:
  - platform: gpio
    name: "Portao"
    id: portao
    pin: GPIO15
    icon: mdi:bell

How can I compare several remote codes in the same sensor_binary?

Hello Joao Carlos Martins,

Thanks for coming here and asking a question.
Would you be so kind as to adjusting the format of your code so that we can read it properly & check the YAML spacing, etc. Editing your original is the preferred way. It is very hard for us to tell what is what when the text formatter jumbles everything like that.
You can use the </> button like this… How to format your code in forum posts
OR… Here is an example of how to fix formatting from the site FAQ Page.
How to help us help you - or How to ask a good question.

Done, thank you !

What do you mean by “Compare” , do you want a binary_sensor with i.e a drop-down list to choose from ?
or “Conditions” i.e ( if binary-codes first 10 digit is/is_not ) ?

Do you want ON/OFF-Switch to receive other codes than turn_on/turn_off
or
Do you want the same Binary_sensor to control several On/Of Switches

You don’t need binary sensor at all. Move your automation directly to remote receiver.

remote_receiver:
  on_rc_switch:
    then:
      - if:
          condition:
            or:
              - lambda: 'return x.code == 10579317;'  # whatever you captured from receiver
              - lambda: 'return x.code == 10579318;'  
          then:
            - switch.turn_on:
                id: portao
            - delay: 500ms
            - switch.turn_off:
                id: portao

Sorry for the confusing term, it would be more accurate to say “insert” several control codes.

1 Like

That worked, thank you!
Final code:


remote_receiver:
  pin: GPIO5
  dump:
    - rc_switch # Settings to optimize recognition of RF devices
  tolerance: 50%
  filter: 250us
  idle: 4ms
  buffer_size: 2kb # only for ESP8266
  on_rc_switch:
    then:
     - if:
          condition:
            or:
              - lambda: 'return x.code == 10579317;'  # Intelbras novo Btn Principal
              - lambda: 'return x.code == 10579318;'  
          then:
            - switch.turn_on:
                id: portao
            - delay: 500ms
            - switch.turn_off:
                id: portao

You’re welcome.