How to get sensor that will graph?

I’m pulling in data to HassIO to monitor some sensors from MQTT, I’m having a problem with some of them. On the history-graph they show as “state” bars instead of a grouped line-graph.

I’m guessing without a unit HomeAssistant thinks its not numeric and won’t graph it with a line?

Is there a list of valid unit_of_measure values? These are a measurement of count of errors, they are not really “units” per say just an integer and I don’t know what to put.

    name: "Cable Modem Downstream 1 Corrected"
    unique_id: "modemsignals_downstream_1_corrected"
    state_topic: "homeassistant/sensor/modemsignals/downstream/1"
    value_template: "{{ value_json.Corrected }}"
  - platform: mqtt
    name: "Cable Modem Downstream  1 Uncorrectable"
    unique_id: "modemsignals_downstream_1_uncorrectable"
    state_topic: "homeassistant/sensor/modemsignals/downstream/1"
    value_template: "{{ value_json.Uncorrectable }}"

Any suggestions?

Set a device_class and unit_of_measurement

Template - Home Assistant (

unit_of_measurement string (optional, default: None)
Defines the units of measurement of the sensor, if any. This will also influence the graphical presentation in the history visualization as a continuous value. Sensors with missing unit_of_measurement are showing as discrete values.

1 Like

How do I know what is valid to set either of those to?

Its not really a device, and it doesn’t have units, it’s just an integer count?

Whatever you want really, just to force it to something so it does the graph. I think unit_of_measurement is just a string anyway.

Ah, ok - I’ll try making something up then. I expected it had to be something that HomeAssistant “understands” - like temperature is F or C and it seems to “know” how to handle that.

I think it’s mostly the device class anyway that does it… I had a template sensor that I hadn’t got around to fixing, and just added to my yaml to get the graph to display:

unit_of_measurement: goats 
device_class: power

You need to add both for it to work (the NaN is just because home-assistant is still starting after the config change).

Interesting. I don’t think I have device-class set on any of my MQTT sensors (or maybe just a couple?).

In any event, I’ve added a units of measure “Corrected Errors” and “Uncorrectable Errors” respectively and my sensors now have lines!

Good to hear it is working… whichever way it happens.

Not sure why it wouldn’t work for me and I had to have both (because I wouldn’t have thought it was necessary from the documentation) but anyway.