Hi @rossk, it may be that your met office integration does not have that attribute?
Iām using the ClimaCell - Home Assistant integration and that does have a temp low sub-attribute.
Could you post a screenshot of your weather.met_office_daily entity? You might also check the other met office entities and see if they have a lowtemp (or similar) attribute/sub-attribute.
Just FYI, you actually donāt need a for loop or namespaces for your high temperature use case. Jinja has a built-in filter called max you can use here, it takes in a list and returns you the largest value in that list. So your template to get the high temperature can just be this:
{{ state_attr('weather.climacell_hourly', 'forecast')
| map(attribute="temperature")
| list | max }}
Hereās the result on mine. I tweaked it slightly so you could see both the list of temperatures and the final max result to show how it worked:
Part of the reason namespaces and loops are so awkward in Jinja is because generally you donāt need them. Jinja tries to push you to use its streaming filters for handling arrays like map, select, selectattr, max, etc. because they are more performant and lead to cleaner easier to read templates. If you havenāt had a chance to read through their doc I would recommend it. It does a good job and shows all the built-in stuff they make available for you.
Oh nice, thank you @CentralCommand ! Yea, I knew there was the max filter, but did not know how to put the results in to a list that the max filter could iterate through. Iāll give it a try and update.
Thanks @Noblewolf for the reply, after much time tweaking I discovered pretty much this, my weather integrations did not have a high and low state, simply an hourly temp reading forecast.
I ended up using two different weather integrations and also made an additional loop to populate the lowest temp over the first 16 hours blocks.
As a rule of thumb when you arenāt sure how to do something in Jinja, google how to do it in python. Whatever you find will probably also work in Jinja as long as it doesnāt try to mutate the state of an object or require importing a library.
Thanks @rossk for pointing out the limit to the first 16 results. The reason I had that was because if you loop through the entire 24 hours youāll probably get the high temperature for the next day (if the next day is warmer). So the 16 item (or hour) limit is to only get the current dayās high temperature.
Thank you @CentralCommand for the great explanations. Iāve updated my original post with your version of the max temperature filter!
Just wanted to give a quick update. 2.5 months on and my spouse is still loving the notifications as built. She hadnāt mentioned it in a while until she looked at her phone before 7am (automation trigger is 07:00) and mentioned it wasnāt there yet.
I considered running the notification whenever she unplugs her phone in a time range 05:00-12:00, but the iOS version of the HA Companion app doesnāt update that charging sensor often (like ever 15 minutes) so it isnāt a viable trigger. If anyone has an idea of a faster āIām awake because my phone did xā trigger Iād love to hear it.
The way I do it is all through HA and motion sensors to know if one of us is awake. After 5am if the bedroom detects motion by the door (indicating someone is leaving the room) then HA waits to see if the other room gets the motion sensor triggered, indicating that someone left the bedroom and entered the next room, then it waits 10 seconds for them to close the door (so a door sensor could also be the source) and sets the house to āOne Awakeā. Then the next person to repeat the process triggers the house to be āAwakeā (helper input), that is how I know itās time to run my morning announcements 3 minutes later (to give you time to wake up before being inundated with stats).
I have quite a bit of automation around this concept of Awake, Napping, Sleeping, One Awake, where the HVAC kicks in, announcements are made, lights come on and other extra notifications like if itās trash day or whatever. We rarely have to do something manually in the morning unless we wakeup before 5am and the triggering doesnāt occur then we might have to tell Siri āGood Morningā to force the house into Awake mode and start the chain of events.
Neither of us take our phones to the bedroom so that was never an option, plus I donāt know if I would like to be reliant on the fact that someone picked up their phone or took it off charge religiously when I have all these sensors around that can pretty accurately determine whatās going on.
Thatās a good method. We both wake up at very different times, sometimes hours apart, so this combo idea is good. Iāll just have to get some more motion sensors.
Yea, itās worked out very well and only takes two sensors to make it work. One of the reasons I did this two person style is because I like to have the temperature set to 60 for bedtime (automatic based on the āSleep Modeā and other factors) and she felt like an Eskimo when she woke up first, so the āOne Awakeā setting notches the furnace up to 65 for her then 70 when the second person gets up. Thatās a lot to remember when you havenāt had coffee yet, so the automation made sense. Itās also nice having that input variable because it also controls when the home automation makes announcements and where, all my automations are keyed to āIf Sleep Mode is Awakeā.
Me and the better half both have iPhones and as you say the HA iOS app sensors donāt update frequently enough, so for sensors we his the ic3 integration as these trigger straight away for us.
We also use it to trigger the iPad chargers to maintain the batteries nicely.
We use the smart speaker as well, but we only have one in the living room, and she prefers to check the weather before getting dressed and going out of the bedroom. Not more than 20 steps to ask Alexa, but this is about small improvements.
My whole home automation has been built on a series of small improvements over the past 25+ years of doing home automation (starting with X10). Some big ideas get implemented out of the gate, but mostly as a developer I just put in the basics and build upon it. My One Awake/All Awake system was bull on that, it just started as a way to control the thermostat but has evolved to an entire system.
The automatic morning announcement is a pretty beefy Jinja script with tons of conditions, like if itās going to be over or under a certain temperature and reading the wind forecast to see when the best time to go for a run is to reading out the first scheduled task of the day - all this gets wrapped into what the house tells you about when you wake up.
This is why I love HomeAssistant, itās so flexible to do these kinds of things. I even use different TTS voices for different things, all on the fly via scripting.
I assume āone awakeā when the (downstairs) hallway motion sensor detects movement for the 1st time after 6am. Anything before that and it assumes still āasleepā.
How does 'Napping" mode work? Does it lower volumes throughout the house and how do you trigger it?
One awake is when the bedroom motion sensor picks up motion and then the next room detects motion within 2 minutes, then one is awake. The next time the bedroom picks up motion, now itās just fully awake, the rest of the drapes open, heat goes up, so and and so forth. Then, again, motion in the bedroom turns it off, opens the drapes and reverses the process.
Napping is easy, it turns off all the lights in the bedroom, closes the curtains, quits out of certain apps on my PC, turns off all non home automation sounds and done. All my home automation voice prompts bear the condition of āif Sleep Mode == Awakeā so that itās never talking when one or more people are sleeping or napping or whatever.
I do something similar for nap mode. Nap mode is an input boolian that can be triggered via the UI, Alexa āturn on nap modeā or by pressing the ānap mode onā button in our nursery.
Nap mode puts all Alexas into Do-not-disturb mode, and turns on a night light in the nursery. Then the automation turns this off after an input-number amount of minutes.