Efficiency of Outside Lights Script


#1

1) Give a description of the problem
I am getting a notice the piston is using 56% memory. Is there a way to make it more efficient?

2) What is the expected behavior?
Working as expected. Turning outdoor house accent lights on at sunset when no bad weather. Turns them off when bad weather exists. Turns off lights regardless at sunrise. Turns lights back on if turned off accidentally

3) What is happening/not happening?
Working as expected.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach any logs (From ST IDE and by turning logging level to Full)
No logs necessary


#2

First, make yourself a couple String variables at the top of the piston and those make the calls to get the weather conditions. There’s no need to make the calls to check the weather in each and every sub block. That’s eating up a ton of memory right there having the same exact text within the piston multiple times.

Like this:
image

Then you can test against that variable rather than making repeated calls to the same thing. You can even change it to lower case right when you define it too.

Just an FYI, I doubt this will ever be true.

There’s more you could do as well…but that will get you started.