Hi everyone, I have a Zemismart SPM01-D2TW-ZMWifi smart meter and a LocalTuya integration to read its values. However, I realized that it is not possible to use the Energy variable for statistics and for the energy dashboard, since the aforementioned variable does not have the 'state class’ attribute.
I also tried to edit via the ‘Developer tools’ page by modifying the ‘State attributes’ by inserting the new attribute. At the end of the operation I can see the new attribute in the sensor properties, but after a few second after SET STATE losing changes.
thank you for your reply, in the end I had already found a solution by creating a template sensor, this also allowed me to manage the raw values and the necessary approximations with greater precision.
#Legacy template sensor format does not support measurement state_class*
*template:
- sensor:
- name: "SPM01 Energy total"
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
state: >-
{{ states('sensor.energy_total')|float * 1.000}}
- sensor:
- name: "SPM01 Current"
unit_of_measurement: "A"
device_class: current
state: >-
{{ states('sensor.current')|float * 0.001}}
- sensor:
- name: "SPM01 Power"
unit_of_measurement: "kW"
device_class: power
state: >-
{{ states('sensor.power')|float * 0.001}}
- sensor:
- name: "SPM01 Frequency"
unit_of_measurement: "Hz"
device_class: frequency
state: >-
{{ states('sensor.frequency')|float }}
- sensor:
- name: "SPM01 Voltage"
unit_of_measurement: "V"
device_class: voltage
state: >-
{{ states('sensor.voltage')|float }}