Graphs ignore non-changing values

I have some current transducers that monitor the power usage on various circuits, and send the current reading every 20 secs to HA via MQTT. They monitor things like the consumption of the waterheater, and this works well.

They are set up as sensors in HA, and when I view the graphs I see a sawtooth pattern instead of the expected pulses. I think it is because when the circuit is not drawing power, the sensor simply sends unchanging zero values every 20 sec, and because this is not a state change, nothing is recorded. At least that is my understanding.

What can I do to make the graph for the sensor display nonchanging date ?

I’ve been having the same issue with mqtt data from my weather station.

I took a look at the code and you want to add force_update: true in your yaml file; e.g:

sensor weatherstation:
  - platform: mqtt
    state_topic: "/home/weatherstation/sensor/min_windspeed"
    name: "Min Wind Speed"
    unit_of_measurement: 'mph'
    value_template: '{{ float(value_json) }}'
    force_update: true

Disclaimer: just started with HA so this might not be the best solution, but it is working for me.

update:

Here is the bit of code in entity.py for the force_update:

@property
def force_update(self) -> bool:
“”"Return True if state updates should be forced.

    If True, a state change will be triggered anytime the state property is
    updated, not just when the value changes.
    """
    return False