Building on the example found here:
… which loops through sequentially named items; starts them off, and creates a timer, which on expiry switches an item OFF, and call the next one ON.
I need to issue further commands when the timer expires.
However, the timer only accepts a val (const) and not var (variable).
The problem is: I want to record the water used by the valve being switched OFF and store it in the item Irrigation1_i_ValveVolume.
After giving this some thought I figured that a new rule is required on valve OFF; e.g.
rule "Irrigation group 1 valve cascade OFF"
when
Item Irrigation1_1 received command OFF or
Item Irrigation1_2 received command OFF or
Item Irrigation1_3 received command OFF or
Item Irrigation1_4 received command OFF
then
...
end
Hmm, searching the forum revealed this:
… short answer: not possible…
However… Rich to the rescue, with:
Adding the rule:
rule "Irrigation group 1 valve cascade OFF"
when
Item Irrigation1_1 received command OFF or
Item Irrigation1_2 received command OFF or
Item Irrigation1_3 received command OFF or
Item Irrigation1_4 received command OFF
then
val trigger = gIrrigation1.members.sortBy[lastUpdate].last
logInfo("Irrigation1.off", "... trigger.....: {}", trigger)
… gives me this… (trigger is 1 x valve 1 and 3 x valve 4)
2018-03-24 19:41:20.357 [INFO ] [nhab.model.script.Irrigation.0] - System Start: Irrigation .
2018-03-24 19:41:28.312 [INFO ] [hab.model.script.Irrigation1.0] - System Start: Irrigation initialise state: done.
2018-03-24 19:41:59.961 [INFO ] [hab.model.script.Irrigation1.1] - Irrigation group 1 started...
2018-03-24 19:42:03.757 [INFO ] [hab.model.script.Irrigation1.1] - ... turning Irrigation1_1 ON
2018-03-24 19:43:29.213 [INFO ] [enhab.model.script.Irrigation1] - ... turning Irrigation1_1 OFF
2018-03-24 19:43:35.267 [INFO ] [o.model.script.Irrigation1.off] - ... trigger.....: Irrigation1_1 (Type=SwitchItem, State=OFF)
2018-03-24 19:43:37.202 [INFO ] [enhab.model.script.Irrigation1] - ... turning Irrigation1_2 ON
2018-03-24 19:44:39.416 [INFO ] [enhab.model.script.Irrigation1] - ... turning Irrigation1_2 OFF
2018-03-24 19:44:39.465 [INFO ] [o.model.script.Irrigation1.off] - ... trigger.....: Irrigation1_4 (Type=SwitchItem, State=OFF)
2018-03-24 19:44:40.559 [INFO ] [enhab.model.script.Irrigation1] - ... turning Irrigation1_3 ON
2018-03-24 19:45:40.799 [INFO ] [enhab.model.script.Irrigation1] - ... turning Irrigation1_3 OFF
2018-03-24 19:45:40.847 [INFO ] [o.model.script.Irrigation1.off] - ... trigger.....: Irrigation1_4 (Type=SwitchItem, State=OFF)
2018-03-24 19:45:41.936 [INFO ] [enhab.model.script.Irrigation1] - ... turning Irrigation1_4 ON
2018-03-24 19:46:42.155 [INFO ] [enhab.model.script.Irrigation1] - ... turning Irrigation1_4 OFF
2018-03-24 19:46:42.199 [INFO ] [o.model.script.Irrigation1.off] - ... trigger.....: Irrigation1_4 (Type=SwitchItem, State=OFF)
2018-03-24 19:46:43.903 [INFO ] [enhab.model.script.Irrigation1] - Irrigation group 1 finished.
2018-03-24 19:46:48.346 [INFO ] [enhab.model.script.Irrigation1] - Irrigation group 1 -> reset Now Switch
There is only a one second sleep between the OFF and ON…
Happy to extend to longer value?! changed to 5 seconds → same outcome.
Or does this need a different approach?