Hi.
I´m trying to make a switch turn on when my fibaro motion sensor activates.
My config look like this (made by gui).
alias: Pollare på vid rörelse
description: ''
trigger:
- entity_id: sensor.rorelse_entre_burglar
platform: state
to: '8'
condition: []
action:
- alias: ''
data:
entity_id:
- switch.fonster_kok
service: switch.turn_on
When there is a motion my automation triggers but doenst turn on the light.
I can see under automations that “last triggered” Changes when there is motion.
If I manually presses the trigger button in automaions the lights turn on…
I dont understand why ?
Can you see if there is something wrong with the code ?
If you manually trigger the automation it will skip the trigger and conditions and it goes directly to your action.
Your indentation is incorrect at the beginning and the alias in the action part is not needed/valid. If you have no conditions you can completely leave out the condition part and your action can be simplified as seen below in my example. Try to change it to this:
alias: Pollare på vid rörelse
description: ''
trigger:
platform: state
entity_id: sensor.rorelse_entre_burglar
to: '8'
action:
service: switch.turn_on
entity_id: switch.fonster_kok
Do you see the sensor.rorelse_entre_burglar change to 8 when there is motion really quickly or with some delay?
Another thing, I think you might to change how the Fibaro motion sensor reports motion. Probably you have 8 for motion, 0 for no motion and 3 for tamper/vibration, however it would be better to have a binary sensor that reports on if there is motion and off if there is no motion. Maybe this topic may help you set this up:
I´ve used the ui for making the automation and I think thats why the codes isnt clean.
However…I´ve tried your celanup code and it doesnt work.
The trigger works because the last trigger time updates when there is motion.
I mean, thats the strange part…The trigger time updates when there is a motion but the light doesnt turn on.
When I trigger the automation manually the light turns on
When I included the sensor there was a entity thats called binary sensor.
It goes on and off when there is motion but many times it stays “on” and wont switch of.
Therefore I think that burgler sensor is more stable than the binary sensor…
How long does the binary sensor stay “on” once it has been triggered? Most motion sensors work this way, when no motion is detected the sensor stays on for a certain amount of time. For some motion sensors you can change this time. I don’t know if your motion sensor supports this.
And does the sensor behave differently? Does it not stay on “8” for the same time as the binary sensor stays “on”?
Can you please post the code? And the same code without the delay doesn’t work? I don’t understand how this is possible.
This issue was a range problem and it didnt work as expected because it didnt update the sensor sometimes.
So I modified the locations of the sensor and now it works as it should.