History Graph - how to show entities that change very rarely

Good day, please help me to move in right direction. Here is the situation:

I have a temperature sensor in a room. I also have a feedback loop to my air conditioning system to keep that temperature in a defined range. Between min and max. Min and max are also template sensors to track current settings of the room temperature.

Those 3 sensors are put onto a History Graph
Annotation 2020-07-22 163437

It all looks and works good. But after some time the min and max lined disappear
Annotation 2020-07-22 163156

I assume it happens because min and max do not change so often and data about their history gets deleted from the DB.

Any idea how to fix that? Maybe there’s an option for a sensor to save its state to DB every let’s say 12 hours even in case there’s no change?

BTW here is how information is displayed by History Graph and Mini Graph card right after the min and max lines disappear and I manually change the values to force them to re-appear:

History Graph:
Annotation 2020-07-22 164427

Mini Graph Card
Annotation 2020-07-22 164458

So you can see that Mini Graph Card somehow knows that there was information in the past and draws a line for the past 24 hours. However History Graph does not do the same.

So here’s what I’ve ended up with for now.

The main point was to force HA to save states periodically even if the state does not change. This task appeared not to be trivial. It looks like there are optimizations in place to prevent this (saving an unchanged state) from happening.

So the idea was to somehow alter the state without really changing it. In my case the sensor looks like this

- platform: template
      friendly_name: min
      unit_of_measurement: °C
      icon_template: mdi:ray-start-arrow
      value_template: "{{ states('input_text.office_air_temperature_min') }}"

It saves a string that represents float temperature value. And here I’ve decided to use the fact that adding a 0 to the end after the dot does not change the value, but alters the state. like 23.0 and 23.00 is the same value on a graph but it’s a different state.

And this is what I did via AppDaemon:

import appdaemon.plugins.hass.hassapi as hass

class RefreshStatesForGraphs(hass.Hass):
  def initialize(self):
    self.run_daily(self.repeat_every_12_hours, '23:51:00')
    self.run_daily(self.repeat_every_12_hours, '11:51:00')

  def repeat_every_12_hours(self, kwargs):

  def refresh_float_entity(self, entity_id):
    current_state = self.get_state(entity_id)
    new_state = str(float(self.get_state(entity_id)))
    if current_state == new_state:
      new_state += '0'

    # Preserve attributes
    state_with_attr = self.get_state(entity_id, attribute="all")
    attr = state_with_attr['attributes']    
    self.set_state(entity_id, state=new_state, attributes=attr)

Works fine so far. If anyone have an idea about how to optimize this - please let me know.