Use case: In the bathroom the light is controlled by a group of motion sensors (two regular, one door sensor defined as a motion sensor), set to turn off the light three minutes after motion. Usually that is not a problem, but a few times a week my wife likes to take a long bath. And there’s not much motion in that tub, I can tell you. I doubt I could be that still if you used zipties on my arms and legs! ![]()
Solution: Makin a false/virtual motion sensor, simply a boolean helper that’s included in the motion sensor group, so as long as the boolean helper is on, the motion sensor group is on.
Problem: With my wife the simplest approach is not only the best, but usually the only one she’ll tolerate. “Going into a web page to take a bath? Forget it!” My wife is not only not interested in automation (even though she usually loves the motion sensor lights and the door opening when her phone comes into range and the door bell button is pressed), she’s a veritable Bermuda Triangle for it! If there is any chance at all that something can go wrong, it WILL happen when she uses it.
Best solution: Using the press on the dimmer wheel outside the bathroom as a trigger and then check after five seconds if the light is on or off to choose to turn on or off the boolean. That way the light will be on until it’s turned off with the wheel again. I have added a two hour wait and then automatic turn off of the boolean as well, but that should really only be neessary if she forgets the light.
But: I can’t get it to work reliably. I use zwave_js.value_updated.value with command class 38, which is changes on the multilevel switch. Only it only works to turn on the boolean some of the time, and it never turns it off. Is there something in the value update that I don’t know about, is there a logical fault in my automation or what?
I have translated the Norwegian names to English, so there may be an error in translation of names, btw. But there is no error in the names on the actual automation, Spook reacts if that’s the case.
alias: Turn on and off virtual motion sensor with dimmer knob
description: ""
triggers:
- device_id: "dimmer device ID"
domain: zwave_js
type: zwave_js.value_updated.value
trigger: device
command_class: 38
property: currentValue
conditions: []
actions:
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- choose:
- conditions:
- condition: template
value_template: >-
{{ is_state('light.dimmer_for_ceiling_spots_in_the_upstairs_bathroom',
'on') }}
sequence:
- action: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.switch_for_virtual_motion_sensor_in_upstairs_bathroom
alias: If light is on after five seconds
- conditions:
- condition: template
value_template: >-
{{ is_state('light.dimmer_for_ceiling_spots_in_the_upstairs_bathroom',
'off') }}
sequence:
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.switch_for_virtual_motion_sensor_in_upstairs_bathroom
alias: If the light is off after five seconds
- delay:
hours: 2
minutes: 0
seconds: 0
milliseconds: 0
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.switch_for_virtual_motion_sensor_in_upstairs_bathroom
mode: single