Need history-graph to be an actual graph, not a bar

How do I force a history graph to be an actual graph, please? I’ve added a history-graph via Lovelace. It shows as a coloured bar chart. I have added unit_of_measurement, as suggested numerous times, but I’ve clearly misunderstood something.

I’ve had a good read of: and things like: History graph shows as bar graph instead of line graph

Not seeing what I’m missing…

1 Like

Nowhere on this page does it say you can set a unit of measurement for the card.

You have to set if in the sensor configuration. It the sensor was auto-discovered use customize to set the unit_of_measurement.

You’re right. I added this as a last resort after the below didn’t work. In my defence, the absence of “you can” in the documentation never means “you can’t”!

Now that we have the red herring out of the way, these are manually added MQTT sensors and all have unit_of_measurement set as “°C” in the configuration.yaml. Futher, yes, over-riding them in the configuration DID fix the graphs.

Would appreciate any assistance with what’s wrong with my configuration.yaml, though…


  - platform: mqtt
    name: "Top Temp"
    state_topic: "plant/temp/top"
    unit_of_measurement: "°C"

  - platform: mqtt
    name: "Bot Temp"
    state_topic: "plant/temp/bot"
    unit_of_measurement: "°C"

what do you mean “whats wrong”? The configuration looks correct, what’s happening with the sensors? Or are you referring to the fact that you had to override them?

My interpretation of Tom’s note “If the sensor was auto-discovered use customize to set the unit_of_measurement” is that this is a feature for over-riding auto detected settings.

These were not auto-detected; they were manually added in configuration.yaml. This gives me two quandries:

  • Why did modifying the configuration of the sensor cause the graph to appear correctly?
  • Why was the unit_of_measurement not picked up from the configuration.yaml in the first place?


it most likely is picked up initially, but there could be a number of factors that made it a bar graph / line graph:

  • If the device is already in history as bar graph, it will show up as bar graph. You have to delete your history at this point or purge it and compress.
  • If the state cannot be converted to a number, it will show up as a bar graph. (Like if the sensor returns units with the value in the mqtt topic instead of just the value). I.E. you can’t confvert ‘67 ºC’ to a number because ºC is not a number.
  • After you made the change, you didn’t clear the cache in your browser which kept it a bar graph.

Basically what I’m saying is: If they are configured as ºC in the sensor section, then they should show up as a line graph.

It’s irksome, because they were always configured as “degC” in the configuration. I was clutching at straws when I added unit_of_measurement to the card.

How do I delete history / purge / compress?

I do understand string splitting (software engineer!). In fact, I’m about to tackle the problem of why my WiFi signal strength (as extracted from the Tasmota JSON string returned by /STATE) is being returned to Home Assistant as a string rather than an int. I can’t find a Lovelace card which displays a string.

purge is a service. Delete is just remove the .db file from configuration when HA is off. Compress might not be possible at the moment.

Also, one thing I did notice is that ‘unknown’ was coming through as a state. That could be the root cause of your issues. You may need to add a value_template to your MQTT topic to convert all numbers to a float. In the event that ‘words’ come through, it will be converted to the default float. The default float is zero.

1 Like

Hi i got this issue. i got a wind value lets say N 5 for nort 5 m/s.

Ist it possible to tell HA to ignore the letters in this value N,E;S;W and only read the numbers so i get a graph?

This will split the letter N from the number 5 using space as the separator, then the [-1] chooses the last item in the list. The list at that point should be ['N', '5'], so using [-1] will get the last item in the list. - dictates going backwards through the list. When combined with 1, it’s saying get the first item going backwards.

{{ value_json[“GetSingleStationResult”][“Samples”][1][“Value”].split(' ')[-1] }}

You may have to delete your database to make it become a graph now.

1 Like

I get this error

Error loading C:\Users\Mediaserver-pc\AppData\Roaming.homeassistant\configuration.yaml: while parsing a block mapping in “C:\Users\Mediaserver-pc\AppData\Roaming.homeassistant\sensor/weather.yaml”, line 5, column 4 expected <block end>, but found ‘<scalar>’ in “C:\Users\Mediaserver-pc\AppData\Roaming.homeassistant\sensor/weather.yaml”, line 8, column 92

The space in .split(’ ') is column 92

Can it bee because it use also decimal? ex. N 5.1

Incorrect quote types, this should work

"{{ value_json['GetSingleStationResult']['Samples'][1]['Value'].split(' ')[-1] }}"

worked like a charm, thanks

I am looking for exactly the opposite solution I have a line graph which shows nothing because it has words instead of number so a bar graph would be better suited for the more-info card

Remove the unit of measurement.

this is what I could find in the core.entity_registry as it is a autoloaded I tried to put null instead of the double quotes and it broke so would I just delete the unit_of Measurement line all together?

   "aliases": [],
    "area_id": null,
    "capabilities": null,
    "config_entry_id": "9fd0f14e2138d01eb6e53f510de1f0f8",
    "device_class": null,
    "device_id": "3dbcaeb411107de1c074e4338a9d309a",
    "disabled_by": null,
    "entity_category": null,
    "entity_id": "sensor.victron_solarcharger_mppoperationmode_226",
    "hidden_by": null,
    "icon": null,
    "id": "2ef9da97692edf6f2ef7aa19447b90f0",
    "has_entity_name": false,
    "name": null,
    "options": {},
    "original_device_class": null,
    "original_icon": null,
    "original_name": "solarcharger mppoperationmode",
    "platform": "victron",
    "supported_features": 0,
    "translation_key": null,
    "unique_id": "226_solarcharger_mppoperationmode",
    "unit_of_measurement": ""

Please don’t mess around with the .storage registry. Edit the sensor config, or if it was discovered use customize.

well the customize does is allow me to change the name and area so where do I set the unit of measurement in it?

well I think I will jack with this tomorrow after work I will try deleting the unit of measurement from the core.entity_registry file since that seems to be the only place it is even showed the customize option does not offer anything to deal with unit of measurement

Don’t use the GUI.