Heads up! Upcoming breaking change in the Template integration

If you want specific time control (or more control in general since automations are far more powerful) of when an entity is updated, an automation makes a lot more sense for the use case:

Itā€™s possible you took what I wrote out of context. I was referring specifically to mf_socialā€™s template whose purpose is to identify unavailable entities.

What are the odds of entities in these domains being unavailable: automation, zone, script, scene, etc?

If the odds are next to zero then it stands to reason one shouldnā€™t check them. In other words, for the purpose of this specific template, we donā€™t need to assign listeners to entities in those domains. However, thatā€™s precisely what happens given that the template begins with {{ states | etc ... }}. Therefore the template is evaluated for every possible state-change in the system, including entities that have no practical impact on this particular template.

Thatā€™s why I suggested narrowing the field by using something like {{ expand(states.sensor, states.binary_sensor, states.light, states.switch) | etc ... }}. At least this way listeners are assigned exclusively to the kind of entities this template is interested in and updated only when one of these ā€˜entities of interestā€™ changes state.

The automation wonā€™t supersede the listeners that the system will automatically assign to the entities it detects in the complex template.

That was my point; thereā€™s no longer a means of superseding the automatic assignment of listeners. My automation might be evaluating the template every 15 or whatever minutes but that complex template will also be evaluated by the boatload of automatically assigned listeners.

The automation isnā€™t using a template entity.

2 Likes

AND its not a sensor.
It writes to an input text

I see what you mean; use an automation instead of a Template Sensor.

That begs the question, how are the results of this automation supposed to be reported? I know I can publish via an MQTT Sensor but, man oh man, this is a long way around for what was easy-peasy with a Template Sensor.

Precisely and feh! :slight_smile:

Sorry, I read it again now and see that I picked a poor quote to frame my point. The point still stands, though ā€¦ just skip my first paragraph :slight_smile:

So create a sensor that reads the input text

Early flagelation of post animation equus ferus negated

(cpu death prevented)
:rofl:

Based on some of the provided templates, and feedback there are a few more template performance improvements coming in 0.116

https://github.com/home-assistant/core/pull/40012 (merged)

https://github.com/home-assistant/core/pull/40250 (waiting for review)

https://github.com/home-assistant/core/pull/40272 (builds on #40250)

https://github.com/home-assistant/core/pull/40323 (builds on #40272)

4 Likes

Can you elaborate on what the PRs mean when they state they improve performance of templates involving ā€œcounting statesā€?

What comes to mind is the count filter but I doubt thatā€™s what the PRs mean.

It is anything that looks at the number of states but does not access the state object attributes. The count filter is a good example of this.

Thanks heaps for the code help, Iā€™ve copied it across not, time to test :smile:. Iā€™m actually in Kangaroo land though :upside_down_face:

EDIT: and in the west here we donā€™t have daylight savings because the farmers are worried that the cows will get confused :man_facepalming:

1 Like

That explains the sideways picture

2 Likes

Sod the cows (just donā€™t give them watches), itā€™s me that gets confused with DST

Iā€™m working out a ā€˜foolproofā€™ way (if it works for me itā€™s foolproof) of sorting this, I hope to come back to it soon.

So are you doing a Priscilla thing, visiting family or back for good ? (and is that because I called you Mike ?)
:rofl:
Cheers

At least we put our clocks forward by 1 hour so thatā€™s one less hour of 2020 we have to endureā€¦

1 Like

Donā€™t worry, come October thereā€™s an hour in there weā€™ll make you live twice (a la groundhog day)

No that will be April 2021. We go forward an hour in a week or so.

Ah, southern hemisphereā€¦
:+1:

1 Like

We are last weekend in March and last weekend in October (forward and back)
So you are back and forward in???

I donā€™t actually use scenes and zones, but Iā€™m fairly confident that their state objects never change, they are just either there (scening and zoning) or not.

So I think that only listening to automations and scripts is ā€˜extraneousā€™, but I donā€™t think itā€™s ā€˜expensiveā€™.