[DEPRECATED THREAD: visit community.webcore.co for assistance] WebCoRE - Example Pistons

I use a custom DTH I wrote:

5 Likes

Basic piston, but figured I’d share it any way. The key was to put the else if statement with the location mode before the last else if statement. I’m guessing there’s another way to do this with some of the settings in the cog but I can’t figure that out - but the method below does work.

I can see old CoRE habits die hard. If it works it works no need to fix it but you could break all those else ifs into their own ifs.

1 Like

I think I tried that approach last night but it wasn’t getting past the second IF. I’m guessing that’s because I didn’t have the Location Mode IF listed second, it was third and the piston never ran it. It wasn’t until I tried the above method that I also tried putting the Location Mode IF second. Is there benefit to running IF’s instead of Else IF’s?

Hey @ahndee

The Piston works great, the dashboard data is great, the SMS formatting seems to be off. Here is a copy of the piston and my phone message


Thoughts?
Rick

I believe that this is a bug - if you edit the “Send Notification” step and look at the value it evaluates to it is correct.

I alerted @ady624 about this issue In a different thread.

Edit: You have an older version of the piston. in the replace() expression, you should replace \n with \\n

@Ross the location of the IF doesn’t matter ignores you set asynchronous processing (click on each IF, click on the cog icon, under Execution Method change to Asynchronous- donthis on each IF so they can all fire inidpendantly and are not reliant on an IF further up the chain).

Can I also make a suggestion to help you optimise this piston - turn off Command Optimisation (click the piston title, cog, Command Optimisations - Disable). That way if someone changes a light to on/off outside of WebCoRE, WebCoRE doesn’t assume it knows the last state.
One other suggestion for optimising - you have multiple ‘Set level to’ followed by ‘Turn on’. No need for the Turn On - set level does the same thing (see my piston to do a similar job below). Each time your piston effectively is telling you bulbs switch on switch on. Just suggestions for you to ponder

Depending on what @Ross is turning on he might have to use set level first. (But you should test that out to see. Cause more than likely you don’t need the turn on command).

Also since none of his IF statements should be running at the same time because of the time blocks in each if, there is no need for changing to async. That is not holding anything up. Only 1 if should be executing actions at any given time.

Command optimization is s good point. So I do agree with that one.

So as for why ifs versus else ifs. I think it is just proper. We had to use the else IF and when true/false trick in CoRE to be able to create more complex pistons. No longer is this required. I can’t answer why it might not be working without a snapshot of the piston and some logs. But post that in the help thread and either tag me or someone else can help too.

Thank you! I really appreciate the feedback and example.

1 Like

Thanks! I know there are some suggestions in the help thread so I’ll head over there next. :slight_smile: I’ve been waiting all day to get back to this.

Hi @ahndee,

Didn’t seem to help, unless I didn’t apply the change correctly which is very likely

Do you have an updated Piston that I could import? Might be easier


Rick

1 Like

Been hesitant to switch mines over from CoRE. I see you’ve done the work so I will just copy yours! Looks very similar to what I have in CoRE.

You know what they say about Great Minds :slight_smile:

I’ve been modifying it quite frequently to allow different types of notifications I.E flashing lights, push notifications, voice notifications. I will update the public version once I’ve added more testing

Andreas, replace the \\| with | or |

it appears the expression parser is replacing [ and ] with [ and ] respectively, making that \[ be required. I’ll see if I can fix it, even though it may not need fixing. There are certain characters that need escaping at webCoRE level, [ ] { } so those need to be written as [ to begin with.

It helped some - you no longer see the \n :wink:

The other part is still the same for me - I’ll try @ady624’s suggestion next

Thanks - I’ll try | instead of \\| and see what it does tonight (thanks for the edit :wink: I was a little confused by your original suggestion).

Back when ActionTiles was SmartTiles I created an app that let me use virtual switches to control the FanMode and TheromStatMode. This in turn was helpful when Alexa came around and I could set individual mode states.

I have been going through my IDE to find apps that I can convert to webCoRE. My Thermo-App was the current one I converted over.

I am still deciding to keep the Setpoints separate or eventually merge them with my Thermo-webCoRE piston. Or even having full control in one piston and create another one to show PistonState of the Thermostat itself, but for now, this is my Thermostat Modes controller.

I still like buttons for individual commands and this keeps them in sync.

Also if someone has a better method, I would appreciate a piston code share.

Ok - got it to work using \| (| didn’t work and got the same result as \\|).

Thanks!

I updated the piston in the original posting - either adjust the replace() to match what is in that screen shot or import again. The updated piston now correctly removes all formatting from the push notification.

This was a helpful start.

I modified the piston to turn a bunch or lights on and off, but I’m planning to use it for a group of locks and rollup doors.

Does ST time out? Because one of my devices is very stubborn and it stays on? any ideas on dealing with that issue? The problem is that you can’t hit the all lights on/off button again without turning all on and then hopefully off.

The second part of piston, monitor’s the individual lights for status? Are you away of any DTH types that separates out the switch status from the indicator status?