A guide to smoother plots using input_number

I recently posted a compliant that sensor and input number were plotted differently on the Lovelace History Graph Card.
I turned this difference into a plotting benefit for my DYI weather station sensors.
(The weather station reports temperature, pressure, humidity and battery voltage every 5 minutes but only significant changes. The hardware draws an average of 20 uA from the battery due to these update constraints.)
The following pictures show the plot differences:
outdoor_temperature


temp24hrs

The sensor values are plotted, in cyan, as a staircase. The input_number values are plotted, in red, as a linear spline. (points connected by a line)
Both plots show lines going through the same real data points. The difference is the interpolation between these data points.
If more data points were obtained, by sampling these slow changing waveforms more often, they would likely be closer to the line between the original data points than to the staircase run and rise line segments.
If you like the improvement, what follows is a collection of the configuration code fragments used to obtain these results.

input_number:
  temperature:
    min: -20
    max: 50
    step: 0.1
    mode: box
    
automation:
  - alias: Temperature
    initial_state: True
    trigger:
      platform: state
      entity_id: sensor.mysensors_bme280_2_2
    action:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.temperature
          value: "{{ states('sensor.mysensors_bme280_2_2')}}"
          
customize:
  input_number.temperature:
    friendly_name: Outdoor Temperature
    icon: mdi:thermometer
    unit_of_measurement: °C
    
recorder:
  purge_interval: 1
  purge_keep_days: 10
  exclude:
    entities:
      # These are copied to input numbers for linear spline smoothing
      # Reduce database size by not recording
      - sensor.mysensors_bme280_2_1
3 Likes

Sadly, not working in 2022.8.5 as both sensor and input_number are plotted as a staircase.