thks for sharing this. Have installe smart-me based on your setup. All wroks fine except being able to add it into the energy tab:
I have used your setup in my templates.yaml file:
- sensor:
- name: "El forbrug aktuelt stat"
unit_of_measurement: kW
state: "{{ states('sensor.el_aktuelt_forbrug') }}"
attributes:
device_class: power
state_class: measurement
- name: "El Måler stat" #the one that i use on the energy tab
unit_of_measurement: kW
state: "{{ states('sensor.el_forbrug_total') }}"
attributes:
device_class: "energy"
state_class: "total_increasing"
but get the following error:
Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:597
Integration: Sensor (documentation, issues)
First occurred: 2:35:59 PM (1 occurrences)
Last logged: 2:35:59 PM
Sensor sensor.el_forbrug_aktuelt_stat has device class None, state class None and unit kW thus indicating it has a numeric value; however, it has the non-numeric value: unknown (<class 'str'>); Please update your configuration if your entity is manually configured,
Hi Marinus!
it looks like you use the smart-me website - and not the local api via modbus - am i right?
because i changed to the mobus tcp connection.
i have 2 entities for the modbus connection
total watt - which is current use right now.
and then a counter - which is the value from the counter.
now to make it possible to use it in the energy dashboard you have to add the stateclass
and possibly device class to. this is also the error you get.
here you can see my setup:
modbus:
- name: "kamstrup"
type: tcp
close_comm_on_error: false
host: 10.0.0.10
port: 502
delay: 2
retries: 10
sensors:
- name: "Kamstrup Total Watt"
unique_id: "kamstrup_total_watt"
device_class: power
address: 8195
count: 2
input_type: holding
unit_of_measurement: W
scale: 1
precision: 1
data_type: int32
- name: "Kamstrup Counter"
unique_id: "kamstrup_counter"
device_class: energy #<<< the device class - which is power
state_class: total_increasing #<< state class - which is total increasing
address: 8267
count: 2
input_type: holding
unit_of_measurement: kWh
scale: 0.001
precision: 2
data_type: int32
also - when i see the error - it looks like its from the first sensor - aktuelt stat - which is simply
the “current energy usage” - but do you actually get any values?
because it says that there are no values available?
EL aktuelt forbrug 0.931 state_class: total ActivePower: 0.931 Name: Borgergade Serial: 9206050 unit_of_measurement: kWh device_class: energy friendly_name: EL aktuelt forbrug sensor.el_forbrug_aktuelt_stat
El forbrug aktuelt stat 0.931 device_class: power state_class: total unit_of_measurement: kW friendly_name: El forbrug aktuelt stat sensor.el_forbrug_total
EL Forbrug Total 26547.11 ActivePower: 0.931 Name: Borgergade Serial: 9206050 unit_of_measurement: kWh device_class: energy friendly_name: EL Forbrug Total´´´
After adding state_class: total I get the following error
´´´ Logger: homeassistant.components.sensor.recorder
Source: components/sensor/recorder.py:405
Integration: Sensor (documentation, issues)
First occurred: 11. juni 2023 kl. 11.40.10 (1 occurrences)
Last logged: 11. juni 2023 kl. 11.40.10
The unit of sensor.el_aktuelt_forbrug (kWh) cannot be converted to the unit of previously compiled statistics (kW). Generation of long term statistics will be suppressed unless the unit changes back to kW or a compatible unit. Go to Link to Developer Tools: Statistics – My Home Assistant to fix this´´´