I have DS18B20 sensors in each room to monitor temperature and control warm floors based on it. Initially, the controller (ESP32) used MQTT to send the reading, and Node-RED flow was configured to store them in the InfluxDB. Then nice sharts were plotted by Grafana with no issues.
Recently, I replaced a custom firmware on the controller by ESPHome, and now it publishes reading directly into the HA. To continue using Grafana, an InfluxDB integration was configured in the HA. But now my charts look like this:
The issue is that readings were not changing from 17 to 20 for the air temperature, so there is nothing to plot on the chart. I use fill(previous) but it doesn’t fill starting values.
Of course, I can configure ESPHome to additionally send readings via MQTT (every minute, even if there is no change), but it’ll be double work.
How you are dealing with such cases?
You can try configuring your sensors with force_update: true, which will cause HA to record the states even if they are unchanging, which should trigger the InfluxDB integration to also write the measurement.
For me personally, I don’t bother writing extra measurements. In my case it’s uncommon to be viewing intervals of time in this state, and if it happened, I’d just ignore it.
I do have an HVAC runtime discrete panel where I want this behavior. I ended up writing a custom query that set the query range 7 days prior, in order to try and get at least one measurement.
SELECT last("state") FROM "binary_sensor.ac_on" WHERE $timeFilter -7d GROUP BY time($__interval) fill(none)
Thanks, force_update: true sounds like an acceptable solution (they even mentioned Grafana in the description). It’ll increase the number of records in the HA database, but with the default retention policy (10 days), it shouldn’t create any issues.