I just started with HA and where some automations work perfectly I keep having trouble with my motion sensor activated lights.
Occasionally two specific lights are turned back on by: turned on triggered by service light.turn_off
which really makes no sense to me.
If it happens, it’s always directly after the automation or when I manually turned the lights off. Sometimes I have to turn the lights off up to 5 times before they will stay off.
Using sonoff zbmini switches, tuya motion sensors, EwelinkZigbee 3.0 USB Dongle E’s (one as a director and one flashed as a router).
Stepped away from the blueprint automations and created new ones like this:
Triggers
Verlichting sens bureau werkplaats Iaszone started detecting motion
Verlichting sens bureau werkplaats Iaszone stopped detecting motion
Perform an action if: When triggered by Sensor bureau start detecting
When triggered by Sensor bureau start detecting
Turn on Verlichting kantoor werkplaats bureau Light
Perform an action if: When triggered by Sens stopped detecting
Turn off Verlichting kantoor werkplaats bureau Light
I set the mode in the automations to restart which seemed to improve stability a little bit.
I’m using ZHA as everything was recognized and installed perfectly out of the box (at least so it seems).
This is the yaml of the light that comes back on the most:
alias: Desk lights new
description: Desk lights new
trigger:
This automation will send a new turn_on to your lights every time your sensor detect presence, even if before it turns the light off, which shouldn’t be an issue.
One possibility is your motion sensor going to unknown/unavaikable state for some reason (an issue on your Zigbee mesh?) and the when it comes back to life it will turn your lights on or off.
If that is the case you probably will improve by using a from: state in your trigger.
Take a look on the history of your motion sensor for those unknown/unavailable states and take a look at your signal quality for this sensor.
By the way, you will find some nice tested blueprints to do exactly what you are trying to do. If you create your automation from a blueprint you most likely already have one available.
And you can simplify your automation lot like this:
alias: Desk lights new
description: Desk lights new
mode: single
trigger:
- platform: state
entity_id:
- binary_sensor.verlichting_sens_bureau_werkplaats_iaszone
from: "off"
to: "on"
- platform: state
entity_id:
- binary_sensor.verlichting_sens_bureau_werkplaats_iaszone
from: "on"
to: "off"
for:
minutes: 5
condition: []
action:
- service: light.turn_{{ trigger.to_state.state }}
target:
entity_id: light.verlichting_kantoor_werkplaats_bureau_light
And will help a lot if you format your code properly when sharing…
Thanks a lot for the suggestions. I’ve copied your YAML and past it as a new automation to try if it will help. I certainly agree it looks a lot cleaner then what I had hahaha.
I checked the sensors history and it doesnt show anything like unknown/ unavailable. I don’t expect anything network related as the ones with the most issues are the closest ones to the bridge.
This is what the history of the switch shows when it behaves strange and keeps turning it self back on again:
It only does this when it needs to go to an off state.
Unfortunately using the state didn’t help. Today I installed a extension usb cable to move the bridge away from the pc, as I read that could improve network performance. Hopefully that will help, otherwise I will exchange the ZBmini switch. Who knows, maybe it’s just two bad units as the other ones seem to work fine.
In case anyone else finds this, I’ve also had this problem with the zbmini. I’ve used Deconz and now Z2m and have exactly the same issue. I have a few in operation, and every now and again I get a new one with this problem and immediately return.
It’s a shame because when they work, they are brilliant little switches.