Hi,
I m trying to trigger the sonoff to turn on fan, based on motion. But as i dont want it to keep triggering the automation as it will always sense motion if i m around.
So i m trying to put condition where it will only trigger if the fan is off.
These are my codes, but it doesnt work. got error on indent, cant even save. I double checked the code, it seems correct to me.
- id: Fan on motionHall
alias: Fan On when Hall Movement
trigger:
- entity_id: binary_sensor.motion_sensor_158d000128bd6c
platform: state
to: 'on'
condition: state
entity_id: 'switch.sonoff_10003c390a'
state: 'off'
action:
- service: switch.turn_on
entity_id: switch.sonoff_10003c390a
- service: media_player.alexa_tts
entity_id: media_player.echo_hall
data:
message: Fan turned on.