Can I use PLTS to do this?

Hi folks! I have a small portable humidifier that I’m using. I have access to information about the interior humidity as well as the exterior temp. I am using PLEG to turn off the humidifier if I reach my desired humidity or if the outside temperature drops too low (to prevent condensation). There’s just one more condition that I’d like to capture: turn off the humidifier if its cumulative run-time has been too long. The humidifier does not have an auto-off, but I know roughly how long it can run without draining the tank. So I’d like a pause-able timer. Here’s the scenario in my head:

  • I fill the tank and reset the timer to 4 hours (put the PLEG humidifier into Armed status, if needed)
  • When the humidifier turns on (via z-wave outlet), the timer starts counting down/un-pauses.
  • When the humidifier turns off (via z-wave outlet), the timer pauses.
  • When the timer runs out (4 hours of total run time), an action fires (turn off the outlet and put the PLEG humidifier in Bypass).

Can I do this with a combination of PLEG/PLTS, or maybe another plug-in?

Thanks in advance for your input!

PLTS timers can’t be stopped and started to get a running total.

But the # operator that was just released in Version 5.6 will allow you to do this in PLEG.

DeviceToMonitor On/Off Switch for the Humidifier.
Accumulator OverFlow ? 0 : !DeviceToMonitor ? Accumulator + #!DeviceToMonitor - #DeviceToMonitor : Accumlator
OverFlow Accumulator > 1000

NOTE: This has a forward reference … so you will get an error the first time you run this … OK after that.
The Accumulator is the # of seconds that the Device is turned on. In this case I trip an alarm at 1000 seconds.
It will fire the Overflow Actions when it reaches your limit … and then automatically reset to zero when you turn the DeviceToMonitpr back on.

That is some slick code! Should be added as an example to the PLEG documentation of conditionals and #/#! operators…

I could use that for my daughter’s TV… Or even my wife’s use of lights everywhere… (On second thought maybe not.)



This is awesome! Sorry for the slow reply. Busy weekend. But thank you very much for the response!

I got an error, as you predicted. Just wanted to see if this looks correct. I assume Accumulator is a Condition. It currently has a value of null.

[code]Humidifier Logic

Device ID: 952014-02-03 09:17:34.021 PLC Version: 5.7


Name Description State Last True Last False
tHumidifierOff Virtual Humidifier is turned off false 2014-02-03 09:06:41.910 2014-02-03 09:06:45.527
tHumidifierOn Virtual Humidifier is turned on true 2014-02-03 09:06:45.527 2014-02-03 09:06:41.910
Device Properties

Name Device Name Device Variable Value Last Change Previous Change
pTodayLow Today’s Low Temperature CurrentTemperature 28 2014-02-03 08:42:37.100 2014-02-02 21:14:47.912
pInteriorHumidity Interior Humidity CurrentLevel 37 2014-02-03 04:36:35.759 2014-02-03 04:20:34.756
pFanOn Foyer Thermostat FanStatus On 2014-02-01 11:42:48.832 2014-02-01 11:32:47.747

Name Expression State Last True Last False
cHumidityWanted pInteriorHumidity < 15 OR (pTodayLow > -10 AND pInteriorHumidity < 20) OR (pTodayLow > 0 AND pInteriorHumidity < 25) OR (pTodayLow > 10 AND pInteriorHumidity < 30) OR (pTodayLow > 20 AND pInteriorHumidity < 35) OR (pTodayLow > 30 AND pInteriorHumidity < 40) OR (pTodayLow > 40 AND pInteriorHumidity < 45) false 2014-01-31 11:04:00.914 2014-02-03 00:14:48.137
cFanAvailable pFanOn eq “On” true 2014-02-01 11:42:48.861 2014-02-01 11:32:47.773
cHumidifierOn cFanAvailable AND cHumidityWanted AND !cAccumulator > 14400 false 2014-02-01 11:42:48.864 2014-02-03 00:14:48.175
cHumidifierOff !cHumidityWanted OR !cFanAvailable false 2014-02-01 11:32:47.775 2014-02-01 11:42:48.906
cForceFanOn cHumidifierOff; cHumidityWanted; NOW > 15:00 false 0 2014-01-31 11:18:58.354
cAccumulator cTankEmpty ? 0 : !tHumidifierOn ? cAccumulator + #!tHumidifierOn - #tHumidifierOn : cAccumulator null 2014-02-03 08:31:37.856 2014-02-03 08:31:41.634
cTankEmpty cAccumulator > 14400 false 2014-02-03 08:22:20.517 2014-02-03 08:22:23.927

Actions for Condition: cHumidifierOn


Device Action Arguments
Virtual Humidifier SetTarget newTargetValue=1
Actions for Condition: cHumidifierOff


Device Action Arguments
Virtual Humidifier SetTarget newTargetValue=0
Actions for Condition: cForceFanOn


Device Action Arguments
Foyer Thermostat SetMode NewMode=ContinuousOn
Delay 15:00

Device Action Arguments
Foyer Thermostat SetMode NewMode=Auto
Actions for Condition: cTankEmpty


Device Action Arguments
Virtual Humidifier SetTarget newTargetValue=0[/code]

(Edit: Made more use of ! to reduce number of conditions)

Edit 2: For those trying to use this as an example, I had to change cAccumulator to “cTankEmpty ? 0 : !tHumidifierOn ? 0 + #!tHumidifierOn - #tHumidifierOn : cAccumulator”, then manually start/stop the humidifier. That changed cAccumulator to something other than null. After that, I switched it back to “cTankEmpty ? 0 : !tHumidifierOn ? cAccumulator + #!tHumidifierOn - #tHumidifierOn : cAccumulator”. So just had to let it initialize the variable, and the error went away. So far so good.

Thanks again Richard!