I have a few ZWave Aeotec WallMote devices that are ZWave remotes with 4 touch sensitive pads, when directly grouped with ZWave devices these have tap, swipe and long hold options which work well.
When using with ZWaveJS i have 4 trigger options, [blank], KeyPressed, KeyHeldDown, KeyReleased. Ideally i would like to have different functions when the key is pressed vs key held down. e.g. Key Pressed toggles the bedroom light and Key Held Down triggers a night time routine. The problem is KeyHeldDown also triggers the KeyPressed event.
I have a similar thing working for a ceiling fan but i cheated and made KeyHeldDown turn the fan on and off and then KeyPressed toggles the speed (only if the fan is on).
Any ideas how i distinguish between a KeyPressed and KeyHeldDown to make sure that KeyPressed isn’t triggered all the time?
This is a cut down version of my automation thus far for button #1:
Looking at a trace shows that the button_1_long doesn’t get triggered because the automation is running for button_1_press already. If i change to queue or parallel the automation gets run once for each case.
Has anyone come across this or worked out a workaround where the Held option can be triggered without the Press?
When holding the key, in my setup I can see in the Trigger Debug Trace that the press part of the Trigger is not triggered by KeyPress but by KeyReleased (value: 1).
Don’t know how to fix this though. Perhaps we can have a condition based on the event data where we can check the value or raw_value of trigger.event.data?
I actually worked around this by using the KeyReleased too. It seems that short press (KeyPressed) is not triggered when held now. I don’t know if something changed in a version of ZWaveJS2MQTT or HA but my automation for short and long press seems to work using KeyPressed and KeyReleased respectively.
KeyHeldDown didn’t seem to work for me how ever i tried, i suspect there could have been an issue with the automation already running though causing issues.
Good to hear you worked it out. I did some testing, and I think the KeyPressed is working though, but it is the UI that is messing things up.
When first setting a Trigger to the value KeyPressed, the trigger is saved correctly to trigger on value: 0. When you close and re-open the automation, the drop-down value field is empty in the UI. If you click save then, the value: 0 condition in the automation.yaml disappears. Now the trigger that would have only fired on KeyPressed, fires on all values, including KeyHeldDown and KeyReleased, so that would explain the behaviour you and I saw.
I was looking how to report this issue, and found two issues already:
I guess we’ll have to wait until those are resolved. Until then I have be careful to (re)select the correct value everytime you use the Central Scene with KeyPressed.
That explains a lot. I setup the automation again when changing to KeyReleased and set the values to KeyPressed.
I’ll make sure to set the values if/when I change the automation again.
I did notice the automation showed blank values but didn’t think much of it, when this was broken I must have saved the blank values.