1) Give a description of the problem
I’ve written my first piston, and I am SO PLEASED WITH IT. WebCore is amazing and I’m so grateful I don’t have to much about with contrived virtual switches, scenes, and automation combinations in order to get something to work. However, there are a couple of things I’d like to improve in the code to make it more efficient, and I’m not sure how to do that. Is anyone able to offer me tips on these points?
-
There’s duplication where I work out what value the dimmers should be set to. the four Set Variable lines at 27 and 49. Can I create a function which performs this calculation and just call on it when required instead? How can I do that?
-
This is triggered on a timer but also if a device’s switch changes. But if a device’s switch changes the script iterates through all the devices and sets the dimmers on all of them. This works fine as I intend all the lights in the house to be set to the same value, but it’s inefficient iterating through all the devices. Is there a way to change the dimmer only on the device which triggered the event?
**4) Post a Green Snapshot of the piston![image|45x37]
5) Attach logs after turning logging level to Full
28/10/2020, 19:57:55 +418ms
+1ms ╔Received event [Home].test = 1603915075417 with a delay of 0ms
+132ms ║RunTime Analysis CS > 18ms > PS > 76ms > PE > 38ms > CE
+139ms ║Runtime (53825 bytes) successfully initialized in 76ms (v0.3.110.20191009) (136ms)
+140ms ║╔Execution stage started
+176ms ║╚Execution stage complete. (37ms)
+179ms ║Setting up scheduled job for Wed, Oct 28 2020 @ 8:07:51 PM GMT (in 596.403s)
+190ms ╚Event processed successfully (190ms)