Implement time tracking in templates#41147
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as its been labeled with an integration ( |
5589fc6 to
982e3db
Compare
|
Looks like we need tests for
|
03c2a09 to
35211ff
Compare
|
This is functionality that should not be in the template engine. I feel like we are going down a rabbit hole we should not. I think we should put a halt to this design we are heading towards, it makes things unneeded complex, for reasons I fail to see at this point. |
Without a way for users to take control of the update frequency, we leave cases like this #40621 (comment) without a solution. Admittedly, it appears to be a rare case, and this does seem to be heading for feature overload so, I'll put this on ice until we can show that we have a larger set of affected users. |
d25110d to
e97d5cf
Compare
track_time_pattern in templates|
Offline discussion: do away with the configurability and just call_later(60) after each update (cancelled on the next update). That should have minimal performance impact and also avoid a CPU spike at xx:yy:00. |
websocketapi fix test tweaks add time pattern skip if update inside the time pattern reverts reverts reverts and switch to interval adjust tests handle now going away and coming back update tests cover
5c5aa45 to
d591bc6
Compare
|
I think it is more consistent (and thus easier to explain/understand) to always delay 60 seconds after the last update. I have tried to adjust to that and it actually simplified things: amelchio@e08a598 ... but you said this would not work so maybe I missed something? |
What you have will work. There are two caveats we would need to be ok with:
|
|
I don't think those caveats apply. The running |
I've stared at this and I can't see where the |
|
It's |
|
I misunderstood. So the intent is to always update every 60 seconds even if there is a state changed event in the time window (taking out the |
|
No, my intent is to force an update if the template is idle for 60 seconds. A state change at time 17 will schedule an update for time 77. Another state change at time 33 will cancel the first timer and instead schedule a new update for time 93 (always 60 seconds later). With the same state change at time 33, your implementation might skip a time update at time 77 and then refresh at time 137 (104 seconds after the last state change). |
I checked this out on my desktop instead of trying to look at it on github and parse the changes on top of changes in my head and I'll all on board now. It looks good to me. 👍 Do you want to push it on top of the existing branch in this PR? |
|
Pushed it now. I am obviously cool with this change but I'll refrain from marking as approved since I think we should get feedback from at least @frenck as well so we can avoid any more emergency brakes :) |
|
|
Using |
Good call. Since we have microsecond precision, how about 60.45? We could probably even go lower. |
|
Whatever you think is fine, I'm in ... |
|
Grammar question to Breaking change: ... when an referenced entity changes state or at the start of each minute ... Should that "or" be "and"? As it is, I understand that one will not get updates from state changes if |
|
It is a bit unwieldy. I'll rework the phrasing. |
|
I adjusted the phrasing. Hopefully that makes more sense. |
Completes home-assistant/architecture#206
Breaking change
It is no longer necessary to reference
sensor.time,sensor.date, or manually update template entities that do not listen for state changes whennow()orutcnow()is present in the template.The template will automatically be updated when:
now()orutcnow()is present in the template.Type of change
Example entry for
configuration.yaml:# Example configuration.yamlAdditional information
track_time_patternin templates home-assistant.io#14854 (outdated)Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: