I’m trying to create a template sensor that only updates when I use the update entity service. The issue is that the attributes for the sensor are changing frequently and these changes are making the sensor update.
What i need is for the sensor to only update on demand and at this point update the attributes from the source. See below from template.yaml. Any ideas appreciated.
I think I need to take a different approach to setting the attributes from within the script (or probably there is a much better way)…
For context - below is a chart that shows the issue. Source GPS data updates frequently and screws up the speed calculations - I need to fix this - but I can’t control the source sensor update frequency. It automatically starts high frequency GPS updates when I get within 1km of my house.
Create a triggered template sensor with a trigger that never occurs, or triggers when something you cause happens, like your current automation frequency triggers (whatever they are), then you would need one less automation.
As I said you can use the always false trigger and the entity update service or replace that trigger with whatever trigger(s) you are using in the automation now that calls the entity update service.
Looks like the trigger is working correctly. One last question. I am trying to add the last time the script ran - see below. It is working but in wrong timezone. Is there a better way?
I’ve been searching for ways to update a service when needed, rather than constantly - such as using the home assistant entity update service - and I noticed you had some luck with that on this thread.
In my case I’m using the UK Transport API - looks like I’m the only one using it - it works well for me. But I obviously only want it to update and provide the times when I need them, not constantly, otherwise it would cost a fortune every month.
I’m trying to figure out how to me the yaml script only update and call on the API when I need the times, rather than several times an hour, and wondered if I could adapt your example for this.
I was considering having a button on my timetable tab to press when I want to call on the API to update the entities with the next bus/train times.
I’m trying to figure out where in the yaml I would need to enter this, and what I would need to put in there. Do you have any tips by any chance?
I’m quite new to HA and Yaml esp. No worries if not
Have you solved this or do you still need help (I am a learner too but will help if I can).
You can use a button with an action to call a service (or an automation) to force an update
Or another way would be to use a trigger in a template. This works well if there are a number of different scenarios that you want to force the update.