Trying to turn on light according to binary sensor

Hi,
What am I doint wrong here? why it says that the state is not allowed, if the state is available on the binary sensor?

Replace “state:” by “to:” and it will work.
HA will trigger when a state changes, so you have to select either a “from” or a “to” (or both) states to trigger.

platform: state
entity_id:
  - binary_sensor.your_sensor
to: 'on'

Thanks, that worked, but I want the light to run on whenever the state is ON even if it was already on, not just at the moment it changes its status from off to on. How can I achieve this? maybe a loop check?

state triggers trigger when state changes. Try describing exactly what you are trying to do.

1 Like

You can add a time based trigger, or when HA starts (to force checking the state on the sensor) and a condition to only run when the binary sensor is on.

?

If the binary sensor changes its state to on and you only define a turn_on action the light stays on.

1 Like