Detecting Z-Wave Switch press

First time posting. I have OpenHab 2.5 running on a Raspberry Pi. I’ve installed a Leviton DZ6HD Z-Wave dimmer switch. Switch works great, I can change it’s level through OH, etc. I think what I’m trying to do is simple, but I’m have a hard time finding a solution.

Here is what I’m trying to accomplish:
If the lights controlled by the Leviton dimmer are already at 100%, and the switch is pressed “ON” again, I’d like to trigger a rule in OH (even though the state of the actual lights won’t change).

My current understanding:
I’m under the impression that OH only receives State Changes from the switch, these can only trigger rules either by:
- Item xxxx changed (triggers anytime the actual output state of the dimmer changes)
- Item xxxx received update (triggers anytime the dimmer is touched even if the output state doesn’t change)

A few questions:
1 - Are these the only way to detect and react to a button press from a Z-Wave device? (particularly if the button press doesn’t cause a change to the dimmer output).
2 - If yes to above - then it seems that the “received update” event is the only way to capture a button press where the dimmer’s actual output doesn’t change. If so, I can’t seem to figure out how to test within this rule to see if the state actually changed (previousState variable is not available).

Any advice would be most appreciated. Thank you for your time!!

I think this is possible. I trigger a rule based on a single tap on a switch and get the received update for the scene. But this is with a Homeseer switch that supports central scene. I also use some GE/Jasco switches that support central scene. I don’t know if the Leviton you mention can do this or has some other way to do it. Below is a bit of code I’ve used to start a timer on the switch tap.

rule "Handle Switch Tap"
    Item Window_Seat_Dimmer_Scene received update
    logInfo("Handle Switch Tap", "update is: " + Window_Seat_Dimmer_Scene.toString)
    if ((Window_Seat_Dimmer_Scene.state == 1) || (Window_Seat_Dimmer_Scene.state == 2)) {
        // no need to turn off or on - it's already in the correct state after the tap
        // 1.0 is single top tap, 2.0 is single bottom tap (usually means off)
        logInfo("Handle Switch Tap", "found 1 or 2")
        if(overrideTimer === null) {
            logInfo("Handle Switch Tap", "starting long timer")
            overrideTimer = createTimer(now.plusMinutes(LONGTIMEOUT), [|

Thank you John,
I appreciate your time, and this code sample is helpful.
Unfortunately, I think that the Leviton switch does not support sending scenes. I looked at the Z-Wave data dictionary for it on, and it looks like it only supports one association channel - no scenes :frowning:
Without this, I don’t think I can detect what input was sent unless the state of the dimmer switch actually changed. I think I’ll either have to replace the Levitons with a different switch (like the Homeseer or Jasco you mentioned) or give up the dream of complicated scene triggers :slight_smile:
Thank you!!

Device database says it provides a channel scene_number, what is that doing? Might be no help here.

You are at the mercy of the product manufacturer as to what they send when.

It is tricky to pick out “received update but didn’t change”.
You have to keep your own record somehow, easiest is a ‘global’ variable if using DSL rules from file.

Beware that zwave devices may send unsolicited periodic reports, which would also look like “received update but didn’t change”.

Thank you rossko57 - I appreciate your time.

I hooked the scene_number up to an item, and setup a quick logging rule (below) and tried every incantation I could with the dimmer (single tap, double tap, log tap, triple tap, tap dance). Unfortunately, the rule never caught anything. I think I can set that channel from OH, but I don’t think the Leviton triggers any changes on it.

rule "testtap5"
	Item LivingRoomWestDimmer_SceneNumber received update
	logInfo("Testing", "caught a scene!")

I see your good point about random updates from the Z-Wave device, unless I can tell what triggered the update it doesn’t do me any good to even try to capture it that way.

I think you’re right - I’m at the mercy of Leviton, and their dimmer just isn’t that advanced compared to some of the others out there. I’ll either have to change them out to something with more association channels, try to do something tricky with % of output, or give up on using the dimmers to trigger scenes.

Thank you again for your time, I’m grateful for this community of support!

In my experience, you are better off going with a double tap. I’ve never seen

received update

do anything with a scene number that doesn’t change. Make your rule

	Item LivingRoomWestDimmer_SceneNumber changed

and see what the log captures. Or bring up the scene_number in Main UI and see if it changes. Many moons I’ve stood in front of a switch with an iPad in hand testing scene numbers.

Here is an example of a double press scene rule for my kitchen dimmer. Triggered on scene change (1.0 is single press, 1.3 is double press). Turns on the TV (if OFF), turn on proxy switch that turns the channel to ABC, and sets receiver volume to 48.

Of course 2.3 is double press OFF on dimmer.

One more thing, the scene number may show 1, but it could be changing from 1.0 to 1.3. Add %.1f

Metadata>State Description.

Hi KJ,
Thank you for your help. That is a pretty cool routine you have there!
I tried this:

rule "testtap5"
	Item LivingRoomWestDimmer_SceneNumber changed
	logInfo("Testing", "caught a scene!")

Unfortunately, nothing new in the log. I’m convinced more than ever that the Leviton dimmer doesn’t send any scene info. Too bad, I have 5 more arriving today! :frowning:
Thank you again!

Then it could be the Leviton dimmer. I’ve used GE/Jasco with positive results. I tested a similar rule:

configuration: {}
  - id: "1"
      itemName: KitchenLightsSceneNumber
    type: core.ItemStateChangeTrigger
conditions: []
  - inputs: {}
    id: "2"
      type: application/vnd.openhab.dsl.rule
      script: logInfo("Testing", "caught a scene!")
    type: script.ScriptAction

and got this in openhab.log

2022-02-07 12:07:56.251 [INFO ] [rg.openhab.core.model.script.Testing] - caught a scene!