Tasmota is wrong chart

Hello everyone,

This is my first post here, and I need your help. After some research and attempts, the chart is still not displaying correctly.

Right now, it looks like this:

Additionally, all changes spam my log, of course. :smiley:

My configuration.yml looks like this:

template:
  - sensor:
    # Stromzähler Keller Verbrauch
      - name: "Stromzähler Zählerschrank"
        unique_id: "Stromzaehler_Keller"
        unit_of_measurement: kWh
        device_class: energy
        state_class: total_increasing
        state: >-
            {{ float(states('sensor.stromzahler_sm_1_8_0')) | round(3) }}
            
  - sensor:
    # Stromzähler Keller Leistung
      - name: "Stromzähler Zählerschrank Leistung"
        unique_id: "Stromzaehler_Keller_Leistung"
        unit_of_measurement: W
        device_class: power
        state_class: measurement
        state: >-
            {{ float(states('sensor.stromzahler_sm_16_7_0')) | round(3) }}

I copied the settings and made some adjustments from this video:
SML Stromzähler lokal mit Home Assistant auslesen - PowerFox Alternative :fox_face: from simon42

Maybe I have a misunderstanding, but what do I need to change to convert it into a line chart?

Best regarts

How old is the sensor, for the graph I think it needs at least one day old data.

The sensor is a few months old, and I had issues with energy consumption before. However, this was manageable because the few logs per day did not flood my logs.

Today, I received the letter with the PIN for the power meter, and since then, my logs have been spammed every second.

So, the energy consumption sensor is around 12 weeks old and had the same issue before, but now it has become a real problem with the power measurement.

That look correct for energy consumption but shouldn’t it be a line graph, Need history-graph to be an actual graph, not a bar - #11 by ivarsson.christopher . Does it look correct in your Energy dashboard.

Yes, this is my problem: I don’t have a line graph for the actual power consumption. Like I showed in the first picture

The energy consumption data appears correct, but since today I’m able to activate the detailed readings:

This is my Tasmota script (I have already removed everything unnecessary):

>D
>B
TelePeriod 30
=>sensor53 r
>M 1
+1,5,o,0,9600,SM,4
1,1-0:1.8.0*255(@1,Energie Bezug,kWh,1_8_0,3
1,1-0:16.7.0*255(@1,Leistung,W,16_7_0,18
1,1-0:96.1.0*255(@#),Identifikation,,96_1_0,0
#

Did I miss something, or is this a bug?

Looks like the new sensor is still saving a string instead of a numerical value. Have you tried using states() | float() instead of float(states()).

1 Like

Not yet. I will try it out and provide feedback tomorrow.

I’ve seen this.

How long is your recorder period?

How many days ago did you make the changes for device class, state class and UoM?

The older data will screw up the plotting until it’s purged from the DB.

Otherwise, if you don’t want to wait, you can temporarily reduce the recorder period or do a manual purge, or check under the statistics view under the dev tools whether there’s a fix issue button.

1 Like

Short update: Changing to states() | float() sadly didn’t fix the problem.

@parautenbach I have had the sensor for around half a year now, and yes, I had to wait half a year for a letter with the PIN :sweat_smile:

For the total_increasing attribute, I changed it nearly at the beginning, but it didn’t work for me, so I let it be. The logs changed a few times per day. But since I get more data from the sensor, it now changes every few minutes too…

For the measurement attribute, I changed it a few minutes ago after implementing it, since I was getting a log every second.

Now I found something super weird: when I look under statistics, it shows it like I want, but when I’m on the devices page, it’s still showing the block charts:

Tasmota is sending a string value, which is why the device page entity will always look like a graph of changing text. I don’t know of a way, particularly in YAML, to change this value to numeric, as it depends on your Tasmota and hardware config.

The float entity you created in YAML is a template sensor, which is effectively standalone and cannot appear on the device page even if they are defined with an underlying device’s entity — but you should still be able to use it for energy consumption.

In HA 2024.7 (pending release) there should be a new feature to link GUI-defined template sensors to their underlying device page. To try this, you will have to create new measurement & total_increasing sensors under Settings → devices → helpers → create → template, they should show up whenever that feature is released.

You can set a (valid, numeric) device class for an entity via the customize: section.

Indeed! I just added a device class to one of my textual Tasmota sensors, and the “bar” history instantly converts to a line graph, including a week of past data.

So it seems OP has two copies of the same sensor data, one is just a round(3) template of the other. Perhaps customizing the UoM, state and device class of the original achieves almost the same objective. Or perhaps I’m just misunderstanding the original question. Either way, thanks for the pro tip.

1 Like