Help with Binary sensor not triggering by automation

Hi Guys,

So im using a Rf Bridge to listen to signals from a cheap RF remote. I added all the buttons+code as a binary sensor:

  - platform: mqtt
    name: "RF remote knop 1"
    state_topic: "home/OpenMQTTGateway/SRFBtoMQTT"
    payload_on: "4276501"
    payload_off: "4276500"
    optimistic: true
    retain: true

When i press the button on the remote, it toggles the sensor in my HA dashboard.

Rf%20remote

So i made a simple test automation to see if my idea works:

  - alias: RF remote Test aan
    hide_entity: false
    trigger:
      platform: state
      entity_id: binary_sensor.rf_stekker_1
      to: "on"
    action:
      - service: light.turn_on
        entity_id: light.trf_kleur_1

  - alias: RF remote Test uit
    hide_entity: false
    trigger:
      platform: state
      entity_id: binary_sensor.rf_stekker_1
      to: "off"
    action:
      - service: light.turn_off
        entity_id: light.trf_kleur_1

When i manual trigger the automation from HA it works great, but when i press the button on the Rf remote nothing happens. Any ideas what could be going wrong? I can see the state of the bin-sensor of the Rf remote change.

EDIT: for info:
Cheap RF remote
Sonoff RF bridge Flashed with OpenMQTTGateway
Tradfri Light

So my automations have single quotes round the on and off. They also have a from and to state. I’ll try and post an example, but I’m on my phone.

- alias: 'Set occupancy Bedroom'
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: light.led_wheeel
      from: 'off'
      to: 'on'
    - platform: state
      entity_id: binary_sensor.esp2_pir
      from: 'off'
      to: 'on'
  condition:
    - condition: state
      entity_id: input_boolean.bedroom_occupancy
      state: 'off'
  action:
    - service: input_boolean.turn_on
      entity_id: input_boolean.bedroom_occupancy
    - service: input_boolean.turn_on
      entity_id: input_boolean.total_occupancy
1 Like

Also worth checking the developer states, under the burger menu, and then the <>
Find it binary sensor and make sure it switches when u press the button. And that it says on or off, I see your running in another language.

Added things from your automation:

  - alias: RF remote Test aan
    hide_entity: false
    trigger:
      platform: state
      entity_id: binary_sensor.rf_stekker_1
      from: 'off'
      to: 'on'
    condition:
      - condition: state
        entity_id: binary_sensor.rf_stekker_1
        state: 'off'
     action:
      - service: light.turn_on
        entity_id: light.trf_kleur_1

  - alias: RF remote Test uit
    hide_entity: false
    trigger:
      platform: state
      entity_id: binary_sensor.rf_stekker_1
      from: 'on'
      to: 'off'
    condition:
      - condition: state
        entity_id: binary_sensor.rf_stekker_1
        state: 'on'
    action:
      - service: light.turn_off
        entity_id: light.trf_kleur_1

No result unfortunately from the changes.

The dev states show the correct state!

EDIT: Stupid me… I changed the names of the entities and i didnt change them in the automation.

Thanks for the help anyway! It now performs alot better thanks to your input!