Tasmota Integration does not set device_class of my smartmeter reader correctly
The problem
The Tasmota Integration Auto-Detects my Smartmeter-Reader, but fails to set some attributes correctly. device_class, state_class and unit_of measurement don't get set. That means that I can't add the SmartMeter Reader to the Energy Dashboard.
Is there any more information that could help? I'm using a pre-manufactured bitShake-SMR. Here are some informations:
Tasmota Version 13.0.0(tasmota32)
Erstellungs-Datum & -Uhrzeit 2023.08.09 13:17:09
Core-/SDK-Version 2_0_10/4.4.5.230614
What version of Home Assistant Core has the issue?
core-2023.11.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Tasmota
Link to integration documentation on our website
https://www.home-assistant.io/integrations/tasmota
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
Hey there @emontnemery, mind taking a look at this issue as it has been labeled with an integration (tasmota) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of tasmota can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign tasmotaRemoves the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
tasmota documentation tasmota source (message by IssueLinks)
I am facing the exact same issue. I have smartmeter providing consumption and feed-in counter but only consumption entity is correctly created by the tasmota integration. Because the entity is created and updated automatically I unable to correct that manually.
This is the sensor data being send to the mqtt broker:
The Tasmota integration creates all three entities but the feed-in ("Supply") is missing the the device_class, state_class and measurement.
Where is documented what the correct mqtt value are so that the Tasmota integration identifies the values correctly?
This is the corresponding bitShake smartreader script to get the sensor data into mqtt: `>D
B ->sensor53 r M 1 +1,5,s,16,9600,Energy 1,77070100010800ff@1000,Consumption(1.8.0),kWh,Total,16 1,77070100020800ff@1000,Feed-in(2.8.0),kWh,Supply,16 1,77070100100700ff@1,Current Power,W,Power,16 #`
Would great to get a solution soon.
Habe das gleiche Problem, gibt es dafür keine Lösung?
Soweit ich weiß ist die Lösung das man es in der config.yaml konfiguriert. Macht vielleicht auch Sinn weil man ja nicht unbedingt alle möglichen Sensoren in der Energieübersicht will.
Alles klar, also wird der Fehler nicht sinnvoll behoben, schade.
Wenn müsste das Tasmota machen glaub ich, weil vom Gerät nicht notwendigerweise mitgegeben wird was es ist.
@step21 @Speedymatze Please don't use German on the issue tracker.
The root problem is that the sensor definition in Tasmota firmware leaves too much freedom, and Home Assistant needs to guess what kind of sensor is connected. Please share the output of command status 8 on the console.
Here is my status 8 output:
08:51:57.771 CMD: status 8
08:51:57.779 MQT: stat/tasmota_B7FAC0/STATUS8 = {"StatusSNS":{"Time":"2024-03-06T08:51:57","SM":{"1_8_0":7555000.000,"1_8_1":0.000,"1_8_2":0.000,"2_8_0":0.00000000,"16_7_0":0.00,"36_7_0":0.00,"56_7_0":0.00,"76_7_0":0.00,"96_1_0":"XXXXXXXXX"}}}
I'm currently working around this issue by creating a sensor that maps to the desired state but has the correct attributes set:
- sensor:
- name: Electricity Meter Total
unique_id: electricity_meter_total
attributes:
device_class: energy
unit_of_measurement: Wh
state_class: total_increasing
state: "{{ states.sensor.bitshake_smartmeterreader_sm_1_8_0.state }}"
Thanks @Subito 👍
"1_8_0", "1_8_1" etc. are OBIS data points. I think the way forward is to teach the Tasmota Home Assistant integration about these.
@jens-fluegel Your issue is different, what Tasmota sensor have you configured?
Here is my status 8 output:
13:19:43.278 MQT: stat/fluegel_smartmeter_1/STATUS8 = {"StatusSNS":{"Time":"2024-03-10T13:19:43","Energy":{"1_8_0_Consumtion":6076,"2_8_0_Feed-in":8709,"Power":5}}}
I am using the following Tasmota sensor: Tasmota Version: 13.0.0(tasmota32) Core-/SDK-Version: 2_0_10/4.4.5.230614
The OBIS data point could be one approach or some key works in the data record name let the Tasmota Home Assistant set the right attributes. If I do change "1_8_0_Consumption" to just "Consumption" it works but it does not work for the second data record. Even if I change it to "2_8_0_Consumption" or just also "Consumption" the second sensor does not have the right attributes.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
This issue is still relevant
I’m facing the same issue, is there any update or a workaround?
I’m facing the same issue, is there any update or a workaround?
If I remember correctly the solution was to reset the tasmota device (and remove all remnants) and then for usage over time create an extra custom entity.
@MarcusLerch I worked around it by wrapping it in another sensor which has the correct state_class set and gets its state from the original sensor:
- sensor:
- name: Electricity Meter Total
unique_id: electricity_meter_total
attributes:
device_class: energy
unit_of_measurement: Wh
state_class: total_increasing
state: "{{ states.sensor.bitshake_smartmeterreader_sm_1_8_0.state }}"
Thanks @Subito and @step21. Defining the sensor in a template in configuration.yaml didn't work out for me, but pointed me in the right direction. I used a helper to define essentially the same thing and even used the same state definition. After that it showed up in the energy dashboard and it now works like a charm.
While I did not find the answer to the issue I'm experiencing from this thread, I suggest a simpler solution to this issue. I have a bunch of devices running an ancient version of Espurna which I cannot be bothered to update. That old Espurna firmware has MQTT based HA integration built in but it uses some no longer supported attributes for all the energy sensors. To fix the problem, I didn't create a template sensor or a helper but instead I've added a customize.yaml config file that corrects the attributes.
Here's an example config which I'd believe could be used as a workaround to this issue with Tasmota as well:
sensor.electrolux_ac_current:
friendly_name: AC Current
device_class: current
icon: mdi:current-ac
sensor.electrolux_ac_voltage:
friendly_name: AC Voltage
device_class: voltage
entity_category: diagnostic
icon: mdi:sine-wave
sensor.electrolux_ac_power:
friendly_name: AC Power
device_class: power
state_class: measurement
icon: mdi:flash
sensor.electrolux_ac_reactive:
friendly_name: AC Reactive Power
device_class: power
entity_category: diagnostic
icon: mdi:flash
sensor.electrolux_ac_apparent:
friendly_name: AC Apparent Power
device_class: power
entity_category: diagnostic
icon: mdi:flash
sensor.electrolux_ac_factor:
friendly_name: AC Power Factor
device_class: power_factor
entity_category: diagnostic
icon: mdi:alpha-f-circle-outline
sensor.electrolux_ac_energy:
friendly_name: AC Energy
device_class: energy
state_class: total_increasing
icon: mdi:lightning-bolt
Edit: read comment below.
I learned today, that 2 labels are neccessary in configuration.yaml: "homeassistant:" and "customize:" So in my case the following configuration works now as workaround to overwrite the automatic tasmota bitshaker configuration to one that works with the energy dashboard:
homeassistant:
customize:
sensor.bitshake_smartmeterreader_mt631_total_in:
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
icon: mdi:transmission-tower-import
friendly_name: Stromzähler Bezug
sensor.bitshake_smartmeterreader_mt631_total_out:
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
icon: mdi:transmission-tower-export
friendly_name: Stromzähler Einspeisung
sensor.bitshake_smartmeterreader_mt631_power_cur:
unit_of_measurement: W
device_class: power
state_class: measurement
icon: mdi:transmission-tower-import
friendly_name: Strombezug aktuell
This issue is still present . HA is on the newest Version from today Tasmota FW 14.2.0 on my IR Smartmeter this the script was is running on my smartmeter.
D B =>sensor53 r M 1 // highlight-next-line +1,3,s,16,9600,SML,1 // highlight-next-line 1,77070100010800ff@1000,Gesamtverbrauch,KWh,Energy,4 // highlight-next-line 1,77070100020800ff@1000,Gesamteinspeisung,KWh,Energy_out,4 // highlight-next-line 1,77070100100700ff@1,Verbrauch,W,Power,0
on HA this sensors values are shown with correct unit_of_measurement 1,77070100010800ff@1000Gesamtverbrauch,KWh,Energy,4 shown as KWh 1,77070100100700ff@1,Verbrauch,W,Power,0 shown as W
This Value 1,77070100020800ff@1000,Gesamteinspeisung,KWh,Energy_out,4 is shown without " KWh"
This ist output of my Smartmeter console stat/SmartMeter/STATUS8 = {"StatusSNS":{"Time":"2024-10-19T17:34:13","SML":{"Energy":1289.1877,"Energy_out":1163.5963,"Power":-3,"Power_L1":32.18,"Power_L2":16.71,
i tried every solutions waths are posted in the configuration.yaml but nothing helps.
Note : so long one of them comes as Energy or Power is all correct, but if i need a second Value as Energy / Power so is this one without the the measurement "KWh" or "W"
Can some one give me the right direction for an solution ?
My Home Assistant Dashboard shows me now my correct Attributes,
I've added following to the config.yaml.
homeassistant:
customize:
sensor.smartmeter_sml_energy_out_2:
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
icon: mdi:transmission-tower-export
friendly_name: PV Einspeisung
sensor.smartmeter_sml_power_curr:
unit_of_measurement: W
device_class: power
state_class: measurement
icon: mdi:flash
friendly_name: SML_Power_Curr
For me the above solution about adding entries under the customize section didn't work.
What worked is this approach, under helpers then a new sensor can be defined e.g. which has the units attached.
Under Settings / Sensors / Helper, I added based on the template/ template for sensors the entries.
The format of the states template entry is then in this format:
{{states('sensor.tasmota_mt631_total_in')}}
Hello together, I had the same issue and I got it working the following way:
- Implement the customization as proposed by @AldebaranPrime , though in my case I had to change the imported energy counter unit of measurement to Wh instead of kWh to get correct readings from my Apator Lepus device with a WattWächter module and change the state_class of all three sensors to "total".
- Delete the configured Tasmota device and add it back in.
- Then go to Developer Tools -> Statistics and fix the displayed unit changes either by converting (in my case) the unit from "" to "Wh" or deleting the history entries.
This made all three available for selection as an energy sensor.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.