[Solved] Hubitat button handling in webcore

Hi all,
I'm in the process of moving my webcore pistons from ST over to HE. So far things have been going smooth however I got a bit stumped by the different button handling on this platform, but I figured it out and wanted to share that:

The button is a samsung zigbee button, which supports those 3 states. It's paired nicely and the device has been made available in webcore. In the log it reports as expected:
image

On ST I would have created an expression as:
"If buttondevice's button gets <pushed|double|held> then do something."
However that doesn't work as the 'gets' comparison does not apply, as value of the button's attributes do not change, i.e. this won't work on HE:

So I had to change my pistons slightly to use the On Event item instead

Last, just to save you the trouble, I tried creating a combined statement as
On event from
button pushed
Or
button doubletapped
Or
button held
Do
some code to decipher/switch which event it was and do appropriate actions

I found out the only system variable which contains anything different between each button action is $currentEventDescription, but considering the string operations one has to do to drill down to what button was pushed, I think the easiest and most lean piston is just making 3 of these statements, one for each of the attributes (pushed button, double tapped button, held button):

Btw, one more thing, not sure if it's a bug in the Webcore IDE/frontend, however once an On-Event statement has been edited, the device cannot be edited, which is why I use a placeholder Device variable. This also goes if you duplicate already created on-event statements.

Hope this is helpful to somebody.

I have found initially I had to recreate the if statement as on ST, a sub device index gets added which is not part of HE. This is specifically the comparison statement of the if - create it new

Here are my tests / production use:

Screen Shot 2020-11-02 at 7.54.46 AM

Screen Shot 2020-11-02 at 7.55.29 AM

@nh.schottfam - thanks, yet curious - what physical button device(s) are you using? Something tells me that there's either multiple ways to skin this cat, or different buttons models may require different handling?

The button model in HE is consistent.

When you import a piston from ST (that was created on ST), there are some 'complier' differences that happened on ST that have to be change on HE. This is the reason for my statement of recreate the if statement (specifically the condition check). As it will then be 'compiled' correctly.

In ST, the button model used device sub-indexes (which do not exist in HE), so the 'compiler' in the IDE put them in automatically. They need to be removed and creating the if statement does this.

Thanks for clarifying, however try as I might I could not get your example working last night. Nothing happens when I do an IF check on 'gets', thus my previous presumotion on the handling. I'll give it another shot, yet so far only the On Event for each state seems to work for me.

Second, I understand Webcore is a community effort here on the HE platform. Could you share who on the forums are involved in said effort?

I just tested those pistons again with webcore on HE and a virtual button device - all worked.

I suggest you clear your browser caches, connect to staging.webcore.co as your dashboard and edit/test again on HE. During this test don't connect to a ST instance. I'm not using ST any more.

As to the history of webcore the webcore note in this forum has information on the webcore port to HE and history. I assume this is what you are running:

Thanks a bunch for the pointers Nh, I'll see if it makes a difference tonight when I get some tinkertime :slight_smile:

Update: So it took a few to get around to testing this. @nh.schottfam - could you elaborate on what the significance of the 'gets' value is? Replicating your example above, I tried with 2 for doubletap and held, however they did not have any effect. Once I changed them to 1 it worked fine. Just trying to understand whats happening with the button?