Tasmota Energy Values setup

Hi, I am new to Home Assistant and Tasmota. I want to create this nice pictures under the energy button.
What I get running; At my dashboard I see the correct data Solar Power & Solar Enegy from my shelly-. From the tasmota I get the total Ennergy and actual power consamtion, Both values without (kWh/W).
I think that is the reseon why i see onl the solar sensors if I like to setup the energy staff. It looks like there are a lot of possibilities.to change that. but all that stuff is so confusing for me. I run a Mosquitto broker. And I see the right values of the entities.
What can do to get these Entities in the Power configuration. What files should I edit ?
So far as I understand I have to set somewhere…

state_class: total_increasing
unit_of_measurement: kWh
device_class: energy
friendly_name: Energy Consumption

thx for hlep

Something like that.

I didn’t check the defaults (I added them after I copied my old sensors that didn’t have the defaults)

mqtt:
    sensor:
      - name: "Daily Energy"
        state_topic: "homeassistant/topic/etcetc"
        value_template: '{{ value_json.EToday | default(none) }}'
        unit_of_measurement: "kWh"
        icon: "mdi:solar-power"
        device_class: energy
        state_class: total_increasing
        
        
      - name: "Total Energy"
        state_topic: "homeassistant/topic/etcetc"
        value_template: '{{ value_json.ETotal | default(none) }}'
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing

      - name: "Power AC"
        state_topic: "homeassistant/topic/etcetc"
        value_template: '{{ value_json.PACTot | default(none) }}'
        unit_of_measurement: "W"
        icon: "mdi:flash"
        device_class: power
        state_class: measurement        

thx … but where do a have to place that staff ?

Where do you have your mqtt sensors setup currently?

From the tasmota I get the total Ennergy and actual power consamtion

Where is this coming from? A manually created mqtt sensor or a discovered one?

I have a Tasmota Wifi setup with a sensor. That ESP8266EX sends the Data as entitities to my Tasmota plugin in home assistant. Is that what you ask for ?

basically what I am asking yes.

So they are auto discovered from the Tasmota integration and not manual sensors you have created in configuration.yaml (or similar location)?

Tasmota should be sending them out with that information already if they are setup sensors…
Or do you use a rule to publish the message?
You should check why they are being discovered without those attributes.

However, you can use customize.yaml to fix them in HA,

In configuration.yaml you need

homeassistant:
    customize: !include customize.yaml

Then in customize.yaml

Capture

sensor.tasmota_named_this: 
  state_class: total_increasing
  device_class: energy

customize docs

still not working. here are my yaml files.

/config/configuration.yaml


# Loads default set of integrations. Do not remove.
default_config:

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
homeassistant:
    customize: !include customize.yaml

/config/scenes.yaml

- id: '1663440413539'
  name: Neue Szene
  entities:
    sensor.tasmota_sm_36_7_0:
      unit_of_measurement: ' '
      friendly_name: L1
      state: '22.38'
    sensor.tasmota_sm_56_7_0:
      unit_of_measurement: ' '
      friendly_name: L2
      state: '313.94'
    sensor.tasmota_sm_76_7_0:
      unit_of_measurement: ' '
      friendly_name: L3
      state: '10.03'
    switch.tasmota:
      friendly_name: Tasmota
      state: 'on'
    sensor.tasmota_last_restart_time:
      device_class: timestamp
      friendly_name: Tasmota Last Restart Time
      state: '2022-09-17T20:04:04+00:00'
    sensor.tasmota_mqtt_connect_count:
      icon: mdi:counter
      friendly_name: Tasmota MQTT Connect Count
      state: '4'
    sensor.tasmota_restart_reason:
      icon: mdi:information-outline
      friendly_name: Tasmota Restart Reason
      state: Blocked Loop
    sensor.tasmota_ssid:
      icon: mdi:access-point-network
      friendly_name: Tasmota SSID
      state: Master-Box-2.4
    sensor.tasmota_wifi_connect_count:
      icon: mdi:counter
      friendly_name: Tasmota WiFi Connect Count
      state: '1'
    sensor.tasmota_sm_16_7_0:
      unit_of_measurement: kWh
      friendly_name: Verbrauch aktuell
      device_class: energy
      state: '346.35'
    sensor.tasmota_sm_1_8_0:
      unit_of_measurement: W
      device_class: energy
      friendly_name: Verbrauch total
      state: '7437515.21298'
  metadata: {}

/config/customize.yaml

sensor.tasmota_sm_16_7_0:
  state_class: total_increasing
  device_class: energy

Hope thats clears the problem. thx

Is that setup somewhere else or just in scenes? scenes is not the right spot to add device_class.
scenes.yaml is for well scenes.

Do you have something like below in configuration.yaml

mqtt
   sensor
       - name: Verbrauch aktuell
         state_topic: "homeassistant/tasmota/sensor"
         value_template: '{{ value_json.EToday }}'
         unit_of_measurement: kWh
         device_class: energy       <<< will not be there, but it's where they should be for manual sensors.
         state_class: total_increasing

or does the entity come from something like

mqtt2

or

Customize should work anyway, probably needs a restart.

ok, thx, I moved the sensors from /config/scenes.yaml to /config/sensors.yaml
I dontknow why they are in szenes. I dont handle scenes.
My entity is in
mqtt2

and now I changed as well the customize.yaml

sensor.tasmota_sm_16_7_0:
  device_class: power
  unit_of_measurement: W
  accuracy_decimals: 3
  friendly_name: Verbrauch aktuell
  state_class: measurement
 
sensor.tasmota_sm_1_8_0:
      state_class: total_increasing
      unit_of_measurement: Wh
      accuracy_decimals: 3
      device_class: energy
      friendly_name: Verbrauch total
      

Now i get the data in Energy dash. But a wrong value of my usage. I have no idea, where the value from 13.190 kwh is coming from. The data in the Sensor Window is ok. you see there the total value of 7.445.487 Wh … somehow from that the dayly enegrgy should be calculatet .


Ok so if they are coming from the Tasmota Integration, you don’t need to make manual mqtt sensor.

This is a manual mqtt sensor example.

mqtt
   sensor
       - name: Verbrauch aktuell
         state_topic: "homeassistant/tasmota/sensor"
         value_template: '{{ value_json.EToday }}'
         unit_of_measurement: kWh
         device_class: energy       <<< will not be there, but it's where they should be for manual sensors.
         state_class: total_increasing

They should have attributes like this however in dev tools states. The customize.yaml should have fixed that now(after a restart).

Tasmota should really be sending it out with the correct state_class and device_class though when it is sending out discovery info to the Tasmota Integration.

It would be worth asking on the tasmota discord why that isn’t happening. It may be a device setting or a bug.

Tasmota discord

Yes there are the right numbers.
But there are still 2 Problems.
1.) the sm_1_8_0 sends in wh not kwh
2.) the number of the used Energy is wrong . I think it should start at 0 and then add sm_1_8_0 . Is that right ?

It takes a little while to calculate.
is that 13.2 kwh or 13000 kwh I can’t tell with the decimal and comma. 13kwh looks about right for a daily cumulative value. It should reset at midnight and start from 0 automatically.

Developer tools > statistics (the last tab)
Is where you can adjust erroneous values.

Is good to know that there will be a automatic reset.
Anyway… now the picture looks a bit different
It says 7.485.841,1 khw from the grid
home usage 7.458.848,8 kwh
The sensor on the right side is getting 7.446.617,67 Wh … The couter is a relative new one, and my eyes read there 7.446 kwh … very strange

so it looks at least, that either in tasmoto or in a .yaml I have to divide the numbers by 1000 !

is verbrauch total a lifetime or daily value?
its a pulse counter or something on your meter?
7kwh is probably a good value if its only measured for half a day or so…

See how it all looks tomorrow. You may need to change your values.
Yes possibly need to divide by 1000. You could just change the units in customize.yaml change to kwh

verbrauch total is the lifetime value !
Its this one: https://www.dreamzz.io/blog/tasmota-energymeter/
I changed

sensor.tasmota_sm_16_7_0:
  device_class: energy
  unit_of_measurement: W
  accuracy_decimals: 3
  friendly_name: Verbrauch aktuell
  state_class: measurement
  state: '346.35'
  
sensor.tasmota_sm_1_8_0:
      state_class: total_increasing
      unit_of_measurement: kWh
      accuracy_decimals: 3
      device_class: energy
      friendly_name: Verbrauch total
  

but that only the txt in the graphic not the number !!