Multi / long press transformation profile for rocker switch

logo

Transform button presses on a rocker switch to a detailed String.
Handle multi press, or long press.

See sample actions and resulting commands :

  • “button1” press and immediately release —> “button1.1”
  • “button1” press and release three times in rapid succession —> “button1.3”
  • “button2” press and release four times in rapid succession → “button2.4”
  • etc…
  • Press “button1” during two seconds, then release → “button1.0” + “button1.0” + “button1.0” + “button1.0” (one command with “0” suffix, every 500 milliseconds)|

Changelog

Version 0.1

  • initial release for openHAB 3.3.0

Resources

I didn’t really succeed in using the profile. After installing I can only select the standard profiles for all channels of my switches
Maybe I’m missing some necessary conditions? Is it only applicable for a certain kind of binding (e.g. EnOcean) or a certain channel like a rawToggle or a rawButton? Unfortunately all my light switches (where I wanted to use it) only provide a state channel by the binding. Could you please give me a hint?

Yes indeed, it is applicable to a rocker switch only. I use it for my EnOcean switch, I don’t know if any other manufacturer has a “RawRocker” channel on their device.
Basically, the profile needs two events sent by the device : a “press” and a “release” events.
If there is other devices who provide this kind of events (even with a different name), I could probably add it ?
But I don’t think a “basic” light switches send these kind of commands. (Sometimes they directly send Increase/Decrease command when long pressed, but no details on the press and release timestamp)

Anyway, what is your use case ? Multi press, long press, both ?

(I edited the open post to mention that a documentation is available with the source code)

My use case would be to get double or triple clicks from a remote control (it controls shutters and some lights).
Your profile would be much more elegant than handling that with a rule
You’re right that it doesn’t transfer a release event, only ON and OFF.

Would love to see this expanded to a more generic translation to be used on switch, contact, or button items.

My use case would be returning a long-press status from keypads to handle dimming - this could be accomplished by a while-loop in rules that changed dim % up or down as long as a button was being pressed.

Great idea!! Hope to one day use it at my house!

I could, maybe, expand this transformation profile for all kind of buttons, but ONLY for the multi press functionnality.

The long press requires the hardware to send a “press” and a “release” event, and if I’m not mistaken, it’s not very common. There is no simple way to know if a button is currently pressed otherwise.

Oh sorry, I let this message pass through without responding !
I will try to implement this. I have to do a new version anyhow, for the next major openHAB release (4.0)

Hey! Just saw your reply!

Thankfully in my case the keypads do sent press/release. Theres a flag on the item to control this behavior.

Looking forward to trying this out! Thank you again for contributing to the OH project <3