Automation doesn't start if the binary sensor is already in"on" state

Dear all,
I’ve a binary sensor that checks the temperature inside a room and an input boolean to start/stop the relative automation to switch on the fan. The binary sensor works very well and change its state to ON (if temperature is > 25). Unfortunately if i try to start the automation when the binary sensor is already in “on” state it fails to start… i tried to manually change the binary sensor state to off and then to on again and the automation works… how to solve???

The same situation/error occurs if f.e. I reboot HA and the binary sensor is already “ON” without the change of state…
someone could point me to the right direction to solve this problem???

Thanks a lot.

- alias: 005_fan_ON
  trigger:
    - platform: state
      entity_id: binary_sensor.alarm_temperature
      to: 'on'
  action:
    - service: switch.turn_on
      target:
        entity_id: switch.fan
mode: single


Well let’s clear up your thoughts on this being an error. This is not the case. The trigger is working as intended. It triggers when the state changes to ‘on’.

If you want the automation to run if the the binary sensor is on before a restart or reload of automations you can add a couple of other triggers.

- alias: 005_fan_ON
  trigger:
    - platform: state
      entity_id: binary_sensor.alarm_temperature
      to: 'on'
    - platform: homeassistant
      event: start
    - platform: event
      event_type:
        - automation_reloaded

And also add this condition:

condition:
  condition: state
  entity_id: binary_sensor.alarm_temperature
  state: "on"
1 Like