Hot Water Recirc - Global Date/Time Variable
-
Hello All -
I've finally gotten to the point where I can start / stop hot water recirculation using MSR and a HASS service call, reliably.I'd like to start with some simple automation to start circulation in certain instances (e.g. motion in bathroom, etc).
That said, I do not want to obsessively run circulation in the spirit of energy conservation and equipment abuse. So I'd like to use a time stamp of last run and perhaps limit the execution to something like once per hour.
I read the manual and see references to date handling in expressions. I see that response to the date() call is in EPOCH. That's great and should make math easy. However, in the reaction to start the circulation, I'm having a hard time setting a global variable to the current date/time.
Can someone point me to examples? Using a 'Set Variable' and date() just puts "date()" in as a string value.
Thanks.
-
Hello All -
I've finally gotten to the point where I can start / stop hot water recirculation using MSR and a HASS service call, reliably.I'd like to start with some simple automation to start circulation in certain instances (e.g. motion in bathroom, etc).
That said, I do not want to obsessively run circulation in the spirit of energy conservation and equipment abuse. So I'd like to use a time stamp of last run and perhaps limit the execution to something like once per hour.
I read the manual and see references to date handling in expressions. I see that response to the date() call is in EPOCH. That's great and should make math easy. However, in the reaction to start the circulation, I'm having a hard time setting a global variable to the current date/time.
Can someone point me to examples? Using a 'Set Variable' and date() just puts "date()" in as a string value.
Thanks.
-
@tbully date() does not exist as a function, I think you mean
time()
The value for the set variable in set reaction must be in the format of${{time()}}
to be evaluated to the global variable.@crille
Argh. Thanks. I meant time and clearly saw it in the manual. I was caught up on the function / call and syntax so this was helpful.Can someone check me on my logic? As a test, I'm looking for recirc to be ran 10 minutes or later and motion in the workshop.
-
You condition test is literally testing to see if the entity attribute is the string "true", not the boolean value true. There is a special "is TRUE" operator for testing if the value is boolean true.
The other issue you will run into is that
time()
is not continuously evaluated. These conditions will only be evaluated when dependencies change which are (as given):- The
LastHotWaterRecirc
value changes; - The motion detector changes state (from anything to anything).
You probably want that first condition to be re-evaluated every minute or so, I'm guessing, and in that case, you need to add an Interval condition to the mix there.
When you get that far, remember the status panel for the rule will show you the current values for each condition dependency, and the logic states of the conditions, groups, and the rule itself, so that's what you need to be looking at in testing/debugging your rule(s).
- The
-
Interesting on the time() eval. Makes sense. I have to rethink this as I want it to be rather responsive without MSR constantly running the function. In other words, I don't want to wait a minute (as an example) for recirc to start when someone enters the bathroom.
Also agree on boolean vs. string and thought it was weird that it wanted a string. Because it was a test (and that part worked), I didn't put much thought in to it.
The time piece is really the issue at the moment.
-
Interesting on the time() eval. Makes sense. I have to rethink this as I want it to be rather responsive without MSR constantly running the function. In other words, I don't want to wait a minute (as an example) for recirc to start when someone enters the bathroom.
Also agree on boolean vs. string and thought it was weird that it wanted a string. Because it was a test (and that part worked), I didn't put much thought in to it.
The time piece is really the issue at the moment.
All -
I took a different approach. I didn't feel like asking the forum a bunch of stupid questions.
- Setup a global variable ("ReadyForRecirc") which will contain a true or false
- Utilize my global "Start Hot Water Recirculation" reaction. After starting the reaction, wait for 60 minutes before "ReadyForRecirc" is set to TRUE.
- Where I have logic to run recirculation, call the "Start Hot Water Recirculation" reaction, wait 5 seconds, set "ReadyForRecirc" to FALSE.
Seems to work OK.
p.s. I don't know why I have to manually enter true/false for my motions but seems to be OK.
-
Good approach! Very easy to follow the logic here.
-
T toggledbits locked this topic on