WebCore optimization

I’m having performance issues. Actions are delaying by sometimes minutes following the trigger, particularly with presence-based triggers. I’m not positive it’s attributable to WebCore, but I want to optimize my routines regardless. I have a few questions that maybe anyone aware of the backend system for webcore could answer.

Do pistons run repeatedly, or (assuming there’s no timer in it) does it gets triggered when there’s any “event”? If the former, then presumably if I had a top level “if” with the least likely condition (such as a button push) would be a good way to do it, since the piston would almost always exit on the first condition. If it were a common condition (like being “Home”) then it would force more comparisons.

If execution of pistons is triggered by a system event, what might be an event aside from button pushes and such?

Do the number of “chunks” matter? Should they generally be minimized? For that matter, what is a chunk?

Would async if statements, when not necessary, cause more processing? I’m presuming they do, since each async would need to be evaluated, rather than it kicking out on a prior condition.

In general, any tips on how to optimize…? TIL

First there’s a WC forum. Probably a better place to ask a detailed question such as this as you’ll have more of the devotees looking at it… https://community.webcore.co/

I would suggest reading the section on the website there regarding conditions and triggers. That’s what mostly makes a piston do something at a certain time.

So in answer to your general question…yes, pistons run repeatedly. They essentially sit there humming along in the background waiting for “events” to happen that they are “subscribed to” so that they can then act. For instance, if you had a piston that was triggered when a contact sensor opened then the piston would sit there and “watch” that contact sensor and when it opened then the piston would get notified and then perform the actions you told it to do. It is always running and watching that contact sensor to see when it opens.

Like anything, there are certainly good ways and bad ways to write the code for a piston. Excessive use of Global Variables can cause performance issues. Having pistons that loop back into themselves can cause performance issues (such as if you’re monitoring for a change in something and then your piston changes the thing you’re monitoring…that’s potentially problematic).

My advice would be to go to the WC forum and look at the Examples section there and see how others are making it work. Then you can actually share some of your pistons in the Piston design help area and people can help you make specific changes. Talking generalities can often make things challenging.

1 Like