I have the below code set to turn on a light when the weather condition changes. It functions, though it is constantly firing. I only know this as I have it trigger IFTTT and my IFTTT activity for this Automation shows it constantly activating.
How may I had a timer of sorts to this? Allow it to check only every 30 mins. Possible? Thanks.
That’s because of the way your value_template is constructed. It is performing a string comparison except the word sunny isn’t presented as a string. Therefore the test never matches the word sunny and always results in true.
Here’s an example of what I mean. The state of my security system is disarmed. I use two templates to compare its state to disarmed (not a string) and 'disarmed' (a string). Compare the results.
I’ve had this coded for several days and it does not seem to be firing at all. No entries for it in the log and the light does not change. Any suggestions?
During daylight hours when it’s not sunny, paste the template into the Template Editor and see what it reports:
{{ states('weather.home') != 'sunny' }}
It should report True.
Now here is what I think may be happening:
The Template Trigger will be evaluated only when the state of weather.homechanges. So if, for example, it changes from sunny to ‘cloudy’, the template will be evaluated. If it then remains ‘cloudy’ for the next three days (during daylight hours) that’s not a state-change and the Template Trigger is not evaluated.
Excellent explanation. Now, each morning, I want HA to determine what the weather is and appropriate turn on/off the light, since it was in a different state overnight. Do I need to write new code for this?
Weather for me is cold…waking up to 40’s F (it’s all relative) in Central Texas, USA.
There are several ways to improve this and it all depends on how you want it to behave. Let’s say the only extra thing you want is to force this to be evaluated at 8:00 AM.
Add a Time Trigger to run at 8:00 AM
Add a Template Condition to confirm that {{ states('weather.home') != 'sunny' }}
I realize that the condition seems redundant (given that there’s a Template Trigger using the same template) but now it’s needed because when the automation triggers at 8:00 AM it should only proceed to execute the action if it’s not a sunny morning.
Will '+25' be understood to mean 25 minutes after sunrise? I would’ve thought it should be something like '00:25:00' or '00:25'. Well, we’ll know tomorrow morning.
The custom in this forum is to tag the post that solves the original problem as being the ‘Solution’. By tagging you own post as the ‘Solution’ it suggests nothing finity or I contributed helped you solve the original problem.
I had not meant to tag myself, I’ll make that change. Do you guys earn points or something for solutions. What was not mentioned is I said thanks in a reply, not to mention I actually came back here to mark a solution. Whatever.
Points? Of course. I’m very close to collecting enough for a one-week trip to Tahiti.
Nope, no points. By marking a post as ‘Solution’ (only you, the author of the topic, can mark a post) a checkmark will appear next to your topic’s title, signaling to others than this topic/problem has an accepted solution. In addition, a link will appear beneath the first post that leads to the Solution. All of this is to help other users, who are facing a similar problem (or are simply interested in learning more), to find answers.
Marking the post containing the problem-solving idea is simply a fair practice; it acknowledges the source of the solution. Otherwise you get the following situation (and I’ve seen it happen):
A user asks for help to solve a problem.
Several people provide assistance.
At least one person’s idea is the key ‘problem solver’.
The user takes that idea and, with few or no significant changes to it, re-posts it as the Solution.
I don’t think that’s how the Solution tag was designed to be used. If everybody did that then this forum would look like everyone ultimately solves their own problems.