I have an automation that works but has a an issue I am not sure how to resolve.
I have a Qubino Flush Relay 1 controlling a light in my Foyer between sunset and sunrise.
It has two triggers. One being an AEOTEC MS6 sensor where I get it to sense motion. This would be someone walking down the stairs to the foyer at night. The other is a door/window sensor that detects if my front door is open or closed. I want it to switch the light on on at night when we open the door.
A delay action keeps the light on for 5 minutes
Currently
if someone walks down the stairs to the foyer at night the light switches on.
If someone opens the door at night the light switches on.
However if someone walks down the stairs, the light switches on and then opens the door within a short time the light switches off.
The outcome that I want is:
between sunset and sunrise
when motion is detected on the stairwell switch the light on
when door is opened at night, switch light on
for the light to stay on for the 5 minutes after being switched on, the switch off.
Can anyone please enlighten me on how to achieve this outcome.
I have used the Automations proforma to generate this code
- id: '1573809638998'
alias: Foyer Lighting at night
description: Turn on Foyer Light after door switch is opened or MS6 detects motion
trigger:
- entity_id: sensor.aeon_labs_zw120_door_window_sensor_gen5_access_control_2
from: '23'
platform: state
to: '22'
- entity_id: sensor.aeon_labs_zw100_multisensor_6_burglar
from: '0'
platform: state
to: '8'
condition:
- condition: or
conditions:
- after: sunset
condition: sun
- before: sunrise
condition: sun
action:
- data:
entity_id: switch.qubino_foyer_relay_switch
service: switch.turn_on
- delay: 00:05:00
- data:
entity_id: switch.qubino_foyer_relay_switch
service: switch.turn_off
It’s may seem like strange behaviour, but it is normal. When you walk down the stairs, the automation is triggered. Because there is a delay in it, it is still “running” when you open the door. The automation is triggered again, however due to the automation still being “running” it skips all delays in the action section, therefore it turns off.
To overcome this, you can add an additional AND condition that the light needs to be off. This way the automation will not trigger when you open the door shortly after you walked down the stairs, because the light is already on.
Thank you very much.
It is obvious when you explained it. I was not aware that the automation was still running in that sense.
Changes made and code below. I only had a minute or two to test as the sun was just rising but got one test in and it seemed to work.
I will test more after sunsets tonight.
alias: Foyer Lighting at night
description: Turn on Foyer Light after door switch is opened or MS6 detects motion
trigger:
- entity_id: sensor.aeon_labs_zw120_door_window_sensor_gen5_access_control_2
from: '23'
platform: state
to: '22'
- entity_id: sensor.aeon_labs_zw100_multisensor_6_burglar
from: '0'
platform: state
to: '8'
condition:
- condition: or
conditions:
- after: sunset
condition: sun
- before: sunrise
condition: sun
- condition: and
conditions:
- condition: state
entity_id: switch.qubino_foyer_relay_switch
state: 'off'
action:
- data:
entity_id: switch.qubino_foyer_relay_switch
service: switch.turn_on
- delay: 00:05:00
- data:
entity_id: switch.qubino_foyer_relay_switch
service: switch.turn_off
Something else, you should use the binary_sensor for the Aeotec Multisensor, not the burglar level sensor. The binary_sensor shows “on”,if there’s motion and “off”, if there’s no motion. In case you don’t see a binary_senor you need to change the mode of the multisensor in the Z-Wave configuration to report binary state.
I am not sure which entity you are referring to in the MS6 so have listed them all in this screen dump.
I have highlighted the one that has “binary” in its name.
May be that your multisensor is not configured to report in the mode “binary sensor report”.
To check this go to Configuration -> Z-Wave -> Select your multisensor in the section “Z-Wave Node Management” -> Scroll Down to the section “Node Config Options” and select the config parameter “5: Command Options”
Does it show this
or is the “Config Value” set to “Basic Set”?
I noticed that your wake up interval was set at 900. Mine is set at the default of 3600. I am assuming these are seconds?
Does shortened wake up interval reflect in better performance but reduced battery life?
The wakeup interval is for the reporting of temp, humidity, etc. and yes it is in seconds. My multisensors are usb powered, that’s why I set it lower. A shortened interval will reduce battery life.
The parameter “3: On time” sets how long the motion sensor will stay on after it detected motion.
Ok Thanks for that.
I reckon I will leave it at the 3600 or hourly reporting as mine are battery powered (no GPO close to it).
I also took your AND condition and added it to another light switch which is designed to come on when a line crossing is detected in one of my HIKVision cameras.
Good logic tip!
Getting there slowly.
My next project is to install a WiFi card in my Daikin Air Conditioner in my Office-IT room.
I have the card and now I need a good time to install. Been too hot (34 Celsius) to turn off A/C.