Hello there,
I have managed to setup a PIR HC-SR 501 motion sensor. Its status gets published on mqtt and it’s read and shown on the main page, but after I added the automation below, it just won’t turn on the light. Here are my config. and automation yaml parts:
Configuration.yaml piece:
sensor 1:
platform: mqtt
state_topic: “home-assistant/fundos/motion”
name: Sensor de Presença (Fundos)
Automation piece:
alias: Ligar luz do quarto
trigger:
platform: state
entity_id: sensor.sensor_de_presenca_fundos
to: ‘Movimento Detectado’
action:
If I got to the logbook, I can see that its logs there and if I click on Trigger, it does turn the light on, but not automatically, as there is movement in the room.
It shows Movimento Detectado in the icon, but nothing happens. If I click the automation and click on TRIGGER, it turns on the light, though.
It’s probably not reading the state precisely… But I cant go any futher than that now…
PS: Sorry for the lack of code brackets. Still getting the hang of it around here!
It may not be the only reason why your code isn’t working, it’s hard to diagnose if you don’t use the code formatting. It’s the </> button in the toolbar. But you should add the initial_state anyways because without it, your automation may not be enabled.