Why does not this automation based on press on a dimmer wheel work reliably?

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! :joy:

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

You have a 2 hour delay in there. That can be interrupted by a lot of things. Delays over a few minutes are not recommended.

While it is possible to wait long periods of time in a wait or delay, it is generally not recommended. This is because HA restarts and many other possible things can happen which interrupt this 'wait’ and then it hangs as you describe.

The suggested method is have a trigger or an automation for turning it on, and another trigger or another automation for turning it off.

Thanks, but no. That’s not it. You are right that a two hour wait is not smart, and I will change that. But quote from my message up there:

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.

So this is just a sideshow and can be overlooked. It has never hanged because of this simply because that has never been used, I have not let it stay two hours after turning on the boolean. The main thing here is to turn on and off the boolean with the Z-Wave knob dimmer, and that’s what I’m asking for help with.

1 Like

Oh no… I trusted an old post here (can’t find it now) that said that the value 38 was only updated when the dimmer wheel was pressed. That’s not true. It is also updated when the on/off/dimming is called in another way (an automation, directly on a light in Hass and so on). Damn… Back to the drawing board. Maybe somebody here has an idea how to do this? If you do, please chime in!

I think there is a difference in the from value when the knob is used. This is what I see in the log when turned on with the knob:

2026-01-29 07:57:23.482 INFO Z-WAVE: [Node 050] Value updated: 38-0-duration 0s => 0s
2026-01-29 07:57:23.482 CNTRLR   [Node 050] [~] [Multilevel Switch] targetValue: 255 => 99         [Endpoint 0]
2026-01-29 07:57:23.483 INFO Z-WAVE: [Node 050] Value updated: 38-0-targetValue 255 => 99

And this is when turning on the light from Hass:

2026-01-29 07:58:10.331 INFO Z-WAVE: [Node 050] Value updated: 38-0-duration 0s => 0s
2026-01-29 07:58:10.332 CNTRLR   [Node 050] [~] [Multilevel Switch] targetValue: 0 => 99           [Endpoint 0]
2026-01-29 07:58:10.332 INFO Z-WAVE: [Node 050] Value updated: 38-0-targetValue 0 => 99
2

But it doesn’t get triggered when I set targetValue updated from 255. Weird.

What does your device’s Activity show when you push the button?

I use triggers like this:

  - trigger: state
    not_from: unavailable
    not_to: unavailable
    entity_id:
    - event.craft_fan_switch_scene_001
    - event.craft_fan_switch_scene_002

and then test state_attr(trigger.entity_id,"event_type").

BTW – how about adding a DS18B20 to the tub? Then you can announce when the tub is ready and then flash the lights when the temp drops too much…

Thanks for answering! This may be interesting… When I use Hass to turn on and off, it says “turned off by action light: turn off”, and when the motion sensor light i used, it says “turned off triggered by automation motion sensor light”. But when I use the physical dimmer button it just says “turned off”. The same goes for turning on. So if it was possible to filter the trigger so only the one saying “turned off” and nothing else came through, I would have somehting. I’ll have a look at this in the evening.

As for the temp sensor I have a few of those laying around, but I think my wife will be suspicious if there is a cable running down into the tub when she wants to get in… :joy:

Edit: No, that doesn’t work, it only accepts the scenes as a trigger, and the scenes are in use. They are from 2 and to 5 presses, there is no scene for one press. But still, if I can filter the trigger as I mentioned above, that could work.

Edit 2: I couldn’t keep myself from trying, but I’m not getting anywhere. I thought this could work, but it doesn’t:

conditions:
  - condition: template
    value_template: "{{ 'triggered by' not in trigger.event.data }}"

And when I tried to send a MQTT as a debug message without the condition, but with {{ trigger.event.data }} as the payload, it doesn’t work. Maybe the syntax is wrong?

Edit 3: This has driftet quite a bit from the original subject of the thread, so I’ll open a new thread about this.

I solved it with the help of @tom_l in this thread. It was similar to your suggestion, but with a series of conditions that filtered out everything but the physical press. :grin:

why are you using the command class when the entity for that dimmer likely exists?

I’m not. That was when I thought I had to use the change in the physical dimmer to trigger the automation, which it turned out I didn’t. The automation is changed since the first version, it looks like this now:

alias: Slå av og på falsk bevegelsessensor i trappa til ytterganga med dimmerhjul
description: ""
triggers:
  - id: ganga
    entity_id:
      - light.dimmer_i_trapp_fra_yttergang_oppe
    not_from:
      - unavailable
      - unknown
    not_to:
      - unavailable
      - unknown
    trigger: state
conditions:
  - condition: template
    value_template: "{{ not is_state('input_select.'~ trigger.id, 'Manual') }}"
  - condition: template
    value_template: "{{ trigger.to_state.context.id != none }}"
  - condition: template
    value_template: "{{ trigger.to_state.context.parent_id == none }}"
  - condition: template
    value_template: "{{ trigger.to_state.context.user_id == none }}"
actions:
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
    enabled: true
  - action: mqtt.publish
    metadata: {}
    data:
      evaluate_payload: false
      qos: 0
      retain: false
      topic: eventdatatest
    enabled: false
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ is_state('light.dimmer_i_trapp_fra_yttergang_oppe', 'on') }}"
        sequence:
          - action: input_boolean.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: >-
                input_boolean.bryter_for_falsk_bevegelsessensor_i_trappa_ned_til_ytterganga_oppe
        alias: Hvis lyset er på etter fem sekunder
      - conditions:
          - condition: template
            value_template: "{{ is_state('light.dimmer_i_trapp_fra_yttergang_oppe', 'off') }}"
        sequence:
          - action: input_boolean.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: >-
                input_boolean.bryter_for_falsk_bevegelsessensor_i_trappa_ned_til_ytterganga_oppe
        alias: Hvis lyset er av etter fem sekunder
  - action: timer.start
    metadata: {}
    target:
      entity_id: timer.sla_pa_igjen_bevegelsesaktivert_lys_etter_en_time
    data: {}
    enabled: false
mode: single

Sorry, I assumed that the “press on a dimmer” was activating a scene controller.

No, but I understand the confusion. It often is.

Yeah, but you have to admit the temperature probe in the tub is a great idea. “Honey, why is there an electrical wire in the bathtub?”

1 Like

I totally get the attitude of the spousal unit. Unfortunately, I cannot abide by it.

I would suggest that if she is going to take a bath, she press a button that means it’s bath time and when she’s done, she presses the button again to indicated bath time is over.

There’s a joke about the one-wish genie. They guy asks for a bridge to Hawaii. The genie whines that that request is pretty tough and pleads for another. The guy then wishes to understand women. The genie’s response, “How many lanes do you want on that bridge?”

:joy: Good one! And I just have to abide by it. My wife’s from Kirkenes up in Finnmark, which is Norway’s Alaska. And they are TOUGH up there. If she has made up her mind that she does not want anything but the one button to use, you couldn’t change her mind with a nuke. Luckily I have gotten it to work now!

Having dated a woman from Alaska, I know and appreciate your motivation :slight_smile:

1 Like

30 plus years of marriage has probably domesticated me a little bit…