Update record of Sensor Template every 5 min

I have correctly configured a template sensor which shows me the setup temperature of my wall thermostat.

Since the temperature will change only a few times a date HA will record the temperature only a few times in the database. Therefore the resulting graph looks odd.
I want HA to write a record every 5 min.

Unfortunately I didn’t find a way to do it. Any Ideas ?

See this documentation of scan_interval:

scan_interval is not accepted for sensor.template :disappointed_relieved:

Entry will result in invalid config

1 Like

Don’t know if this will work, but I would try to limit the update frequency of the entities that are evaluated by the template sensor.

Update frequency doesn’t work either. The problem ist that if there is no change in the value no record will be written in the database.

I managed it with a small python script which i call via automation every 5 min.
With the api call hass.states.set you can set the parameter force_update = True and it will result in writing the value to the database.

Here is the script (named force_update_state.py):

#pass entity_id as argument from call
sensor = data.get('entity_id')

#read old state
oldstate = hass.states.get(sensor)

#write old state to entity and force update to record database
hass.states.set(sensor, oldstate.state , oldstate.attributes, force_update=True)

You can call the script via Automation with the following settings. Please adjust entity_id to your Sensor Template Entity:

- action:
  - data:
      entity_id: sensor.termo_ufficio_set_temp
    service: python_script.force_update_state
  alias: Alias name
  condition: []
  id: '1514845748581'
  trigger:
  - minutes: /5
    seconds: 0
    platform: time
2 Likes