-
Design Pattern: Associated Items : Use a naming scheme that is easier to parse and put your Items into Groups to more easily access them
-
If you are coding OH 2.x rules you do not need and should not have any of those imports.
-
Design Pattern: Cascading Timers Here is a concrete example for you
-
As Jürgen and Vincent points out, using a while loop in this way is a really bad idea. You are consuming 4 of your 5 total available threads for running Rules. Furthermore, there is no sleep in your while loops so you are probably maxing out your CPU sitting there running through this loop doing nothing which can possibly cause heating and other performance issues. I want to emphasize, this is a really bad implementation approach. You need to generate an event when it is time to start the irrigation system. Not sit spinning in an infinite loop forever consuming tons of CPU doing nothing. You need to use the CalDav binding, Astro Binding, one of the Alarm Clock examples, or something external to trigger the irrigation to start. Otherwise your OH install will only be good for just running these four zones of irrigation and you will probably burn up your machine with overheating. If you must poll like this, use a Time cron triggered rule that checks once a minute or so to see if it is time to turn on or off the zone at a minimum.
-
There is no need to use a primitive int for lawnTime. Unlike with many other languages, the Rules DSL does better when you avoid the use of primitives unless necessary.
1 Like