Sprinkler / Leak Detector Issue

Hello All -

It has been awhile since I’ve posted. I’m having a hard time with a situation and was hoping to have others think through my logic.

Setup:

[ol][li]I use PLEG to monitor water usage (via Arduinos) and monitor the sprinkler system (controlled by Open Sprinkler)[/li]
[li]I alert on a few conditions:[/li]
[li][list]
[li]The water has been running too long and the sprinklers aren’t running (stuck valve, etc)[/li]
[li]The bypass (sprinkler) meter is detecting water flow but the sprinklers aren’t running[/li]
[/list][/ol]

The issue is that, during the switch from one zone to the next, the system is technically not running. So I need to debounce the detection of the system running to give it time to start the next zone. I thought I implemented it properly but I guess not.

Triggers/Properties
SprinklerZone01 = Front PopUps(01) is turned on <----Similar for the rest of the zones
UseBypassForSprinkler = Virtual Switch - True/False
WaterBypassRequested = Virtual Switch - True/False
BypassWaterMeterFlow = Flow

Conditions
SprinklersAnyZone = SprinklerZone01 OR SprinklerZone02 OR SprinklerZone03 OR SprinklerZone04 OR SprinklerZone05 OR SprinklerZone06
SprinklersRunning = SprinklersAnyZone OR (!SprinklersAnyZone AND (!SprinklersAnyZone;NOW < 2:00)) <<------ Here’s where I tried to debounce for 2 minutes
SprinklerBypassWaterEnable = SprinklersRunning AND UseBypassForSprinkler
SprinklerBypassWaterDisable = (!SprinklersRunning AND (!SprinklersRunning; NOW > 1:00)) AND !WaterBypassRequested
BypassWaterFlowing = BypassWaterMeterFlow > 0.00
BypassAlert = (BypassWaterFlowing AND (BypassWaterFlowing; NOW > 1:00)) AND !WaterBypassRequested AND !SprinklerBypassWaterEnable
WaterFlowingTooLong = (WaterFlowing AND (WaterFlowing; NOW > 20:00)) AND !SprinklersRunning

The issue is I am triggering notifications for BypassAlert and WaterFlowingTooLong during zone change. This upsets the WAF as the sprinklers run in the middle of the night! Haha!

Thoughts?

I’ve confirmed it’s because the following condition isn’t running as intended:

SprinklersRunning = SprinklersAnyZone OR (!SprinklersAnyZone AND (!SprinklersAnyZone;NOW < 2:00))

I’m basically trying to keep this condition TRUE for 2 minutes after SprinklersAnyZone goes false.

Try:

SprinklersRunning SprinklersAnyZone OR (!SprinklersAnyZone AND !(!SprinklersAnyZone; NOW > 2:00))

Explanation: NOW is an interval timer that fires every minute. Its timestamp is that of the last time it fired. At the point where SprinklersAnyZone becomes false, the Sequence expression (!SprinklersAnyZone;NOW < 2:00) will also be false until the next time NOW fires.

Inverting the logic to !(!SprinklersAnyZone; NOW > 2:00) should give you a term that stays true until two minutes after SprinklersAnyZone becomes false.

Genius, Rex!

I’m certain I’ll never fully grasp sequences. :frowning: I’m having a blast with the Arduino/MySensors stuff and have had great success…but when it comes to PLEG Logic…

This worked like a charm.

Thanks again.

I'm certain I'll never fully grasp sequences. :-( I'm having a blast with the Arduino/MySensors stuff and have had great success......but when it comes to PLEG Logic........

PLEG’s Sequence expressions are a very powerful way to incorporate time factors into logic. This is much more difficult to do in most other programming environments. Wait until you need to do that on one of your Arduinos!

I recently completed some Arduino code to automate my machine tools using stepper motors. The majority of the code was required to keep track of what happened and in what order. I could have done it in PLEG with handful of Sequence expressions…

This worked like a charm.

I’m happy to hear it is doing what you want.