D’oh! Of course! I seem to think that you guys write flawless code so didn’t notice that Now when I set sensor.alarm_clock2_time to same as current time, this template returns true!
{% set temp = states('sensor.sonoffth3_am2301_temperature') | float %}
{% set time = as_timestamp((now().date() | string ~ 'T' ~ states('sensor.alarm_clock2_time') ~':00') | timestamp_custom('%H:%M') %}
{{ states('sensor.time') == time and temp > -10 }}
So now that the above template works, I would need to think how I can use this one template to determine if the trigger should happen one, two or three hours before sensor.alarm_clock2_time based on outdoor temperature…
that’s how any HA editor works, same applies to Lovelace editor (it also removes any comments) - and that’s why many people prefer to edit their configs manually.
glad that your template is finally functional
btw, if using it you don’t need condition in your automation old
I did notice that condition now checks the outdoor temperature, same as template, but I thought condition just HAVE to be there as it’s automation Apparently that’s not the case!
mate, you should read docs - without understanding the basics it’s hard to progress. condition is optional.
well, I thought sensor.sonoffth3_am2301_temperatureis your outdoor temperature. and therefore in your template one of the conditions is outdoor temperature is above -10.
so you probably need to modify it
Oh believe me, I have read a lot! It’s just that the learning curve is quite steep and it’s easy to forget something that you have already read… What’s more, there are lots of old information around net, which is understandable with product such as HASS that is updating and changing all the time…
Yes, that’s what I thought as well, and that’s also why this template returned true when two times were identical. But I don’t know how to write that it returns true when time is three hours BEFORE current time, and when outdoor temperature is above -10 (of course, in reality I would change it to less than -10C but this is for testing purposes), and then add other conditions (if temperature is between -10 and -5 AND time is 2 hours before alarm time, and when temperature is between -5 and +2 AND time is one hour before alarm time… I know I should use if - then - else -logic somehow (or, in home assistant, if, elif, endif or something like that )
based on that, I think you need to consider reading this post and adapting it according to your circumstances (asking for help here if needed) as it’s something similar to yours, isn’t it?
alternatively, create your own using Jinja’s if
wanted to say the same. however, that does not 100% guarantee as documentation is currently a little step behind the process because it’s FAST so keep it in mind. the best source of information is code but that’s another story
I have read that thread already and tried yesterday those solutions but they didn’t work for me… However, I was planning to do just what you suggested, that is to adapt those solutions to this template…
Basically my problem with this whole thing is that Jinja syntax is very alien to me, but I thought I start reading Jinja documentation next… I might have done that anyway, but I was just in a hurry with this because it’s winter and our cars need to be heated before we leave to work every morning BUT now that this template works as it is, at least I can program it to trigger when we are still asleep, and estimate when exactly our cars are leaving home And then tweak the automation later! But I WILL get this to work, as I hate to give up! And I want to mark something as solution here as well so others will benefit
I know, unfortunately official documentation is not very…comprehensive, and many times it’s easier to search for actual examples from somewhere else
They are VERY good, it’s just that you probably don’t understand how they are laid out. I help people only using the docs for just about everything. Once in a while, I’ll have to go to the template editor. But I don’t use any of these integrations, I don’t use the built in automations, and I have very few devices outside switches and lights. Yet I help all sorts of people by just reading the docs.
Jinja is near identical to python aside from filters. And filters are advanced. There aren’t many jinja tutorials but there is about 90 million python tutorials. I’d start with basic python tutorials. Learn the basics, then take a look at jinja.
Their official documentation is good… but it will take time, especially to remember that even if it’s very similar to python, it is not python.
Don’t think you’ll need both things unless you’re not a coder and still are very keen to master it
I can believe that, but I also guess that you speak Python and/or Jinja For someone who does that, it is probably quite easy to see from HA docs what needs to be done.
Well, I am mainly interested in home automation, NOT in coding… Although I understand that I have to code something if (and when) I chose to go to Home Assistant, and I am still thinking I will continue with that when I get to build our new house, instead of going to much expensive KNF or ABBFree@Home -route (or whatever, those are quite easy to use but also limiting in what they can do)… It’s been over 20 years since last time I did more coding and even then it was with (Object)Pascal, and I have never done anything with Python…
But I still think that since Lovelace automation tool is quite good already, it would ONLY need to add negative delay to be even better and if there was such an option already, this whole thread would not have been necessary
Then you should move to node red instead. Node-red is for those who don’t want to code, but like understand/think in flow charts.
Actually, you just need to understand yaml to understand the non-template documentation (integrations, etc). The documentation for templates is built like an API documentation. They tell you what the methods are. They do not tell you how to use them because you need to understand code.
…although I probably would have stopped short of putting “very” in capitals
The layout is not the best, but once you get used to it you (usually) know where to look.
Node-red sounds what would suit me better, that is true, but originally when I chose my home automation software (maybe two years ago or so), I chose Home Assistant because I wanted to choose software that would be very much still in developement and have big (and helpful) community because that would mean that if something was not yet possible in that software, it probably would be sooner or later, and if have a problem, there would be an active community that could help me. So far it seems that I chose right Not sure about in what situation Node-red was back then, but I don’t remember really considering that back then. But I did consider Domoticz, but because fanbase for that was declining, I chose HASS instead.
EDIT: Oh, there is Node-Red Add-on to Hassio, I should look into it!