[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?

I've been trying to figure out how to use WebCore with my button for a year or so now (first in ST and now in HE). Would love a helping hand. I see events exactly like the ones in the original post when I single, double, triple, etc tap on my button. How do I translate those to triggers in WebCore? I get the same comparison thing with a field to enter a value...I'm just struggling to wrap my head around how this works with these buttons. FWIW my button is a "Zooz Remote Switch Zen34". After trying in WebCore for a while back in the ST days, I was able to open the device in ST and program the taps using the ST UI. Can't find that sort of thing in HE either. Appreciate any help!

This is one of my pistons for controlling buttons with HE

Screen Shot 2022-06-16 at 2.17.42 PM

The if at line 20 checks if button 2 was pushed

The if at line 30 checks for button 4 pushed.

The actual device event is attribute pushed, value 4 as far as the event. If you enable logging on your piston it will show you what events it receives.

In this case there is an if for each button.

  • the event that fires on he is pushed (or held, or double tapped).

When editing the if statement in the webcore IDE, it will show you the options that device supports

In this case my button on does pushed, and held. What the button does depends on the particular device and its driver in HE.

There are more complex ways to write this in webcore, there are tips that discuss that but for basic stuff this is all you need.

1 Like

Thank you very much, really appreciate the help!

Here's the piston that I use for the Zooz 34 remotes. It's simple and I'm sure it can be modified for your needs. But this works perfectly for me.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.