Integrate Modbus smart meter with Home Assistant Energy

Hello,

I am using an Eastron Modbus energy meter to monitor the power consumption of my house. So far I have been reading the sensor using esp32 and esphome. Now I want to connect the meter with RS485 to USB converter and read it using the modbus integration of home assistant.

I have the following test config:

modbus:
  - name: hub1
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    port: /dev/ttyUSB0
    stopbits: 1
    sensors:
    - name: sdm630_total_active_energy
      address: 342
      input_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float
      unit_of_measurement: kWh
      device_class: energy
      
    - name: sdm630_phase_1_line_to_neutral_volts
      slave: 1
      address: 0
      input_type: input
      count: 2
      precision: 2
      data_type: float
      unit_of_measurement: V
      device_class: voltage
      

which works just fine.

But when I try to add the total active energy counter as a source in the Energy dashboard, it is not listed there.

I understand that not every integration is ready to be used with “statistics” and the energy dashboard but does anyone know a solution for this problem?

Try adding

state_class: total_increasing

to your energy sensor

1 Like

Thank you! Now it shows fine!

1 Like

I have about the same setup only with TCP interface instead of a serial one.
Actually, I have 2 power meters and in the process of adding my EV charger through Modbus to the system.
I have added the state_class: total_increasing to the sensor definition but I still do not see the sensor in the optional sensors for the energy dashboard.

Hello Miroslavpetrov,

I have also an Eastron energy meter.

type SDM630MID
3 phase
Modbus

Which hardware setup you use for reading the sensor with Home Assistant

Greetings Tjibbe

Hello, I use this → https://twitter.com/innomkr/status/1440343273655074824/photo/1

Its an esp8266 with MAX458 breakout board with ESPhome. The ESPhome config is sdm.yaml - Pastebin.com

Hello , I have a Chint DTSU666 which should be similar to your meter.

Could you please tell me how to integrate into HA? I do have a spare ESP32, but not sure how to connect the hardware part.

Which sensor can you get?

I am using ESP8266 with MAX485 module which converts RS485 to UART. For firmware I use ESPhome which has built in support for the Eastron meters. I don’t see Chint DTSU666 in the list of supported devices in ESPhome, so I would suggest you to get an Eastron meter or if your max load per phase is not more than 100A - get a Shelly 3EM. Shelly 3EM has built in wifi and is discovered by home assistant automatically.

Does Shelly 3EM supports modbus? How can I use Shelly 3EM with my solar inverter?

Shelly 3em uses WiFi and is auto discovered by Home Assistant. The rest is up to you.

Hi everybody, i have eastron sdm230 and i want to get data from inverter in real time, from this meter can ypu get current solar panel energy? My inverter is growatt min-6000tl-xh.

I cannot understand your question… How having a smart meter will help you get data from an inverter? You can connect the output of the inverter through the smart meter and measure the power consumption and energy usage

Hi, I have the same problem as Klagio - I have a Chint DTSU666 with Modbus output. I connected the Modbus cable to an Modbus-to-USB adapter and pluged it directly into the USB-Port of the Raspberry Pi. I used:
modbus:

  • name: hub1
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    port: /dev/ttyUSB3
    stopbits: 1
    sensors:
    • name: Smart Meter
      address: 342
      input_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float16
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing

But I am lost now when it comes to the configuration of the sensor… how do I know the correct parameters - is the setup of mine with the adapter even possible? In the moment I can connect the sensor in the dashboard but no data is received.
Thank you for help!

Its a completely different meter and the addresses of the registers are different. I found a plugin for this meter but for domoticz - DTSU666-Modbus/plugin.py at 7559e61c1cb2ea5f6c70f949319bae34435c723b ¡ elfabriceu/DTSU666-Modbus ¡ GitHub

from this file I can see that the register for the energy in kwh is 0x2012. You can try substituting 342 with 0x2012

Thank you fĂźr your fast reply.
Did not work - I am afraid, that the problem starts wirth the USB-Port of the Rasberry Pi, as I found the following log:

Logger: pymodbus.client.sync
Source: components/modbus/modbus.py:386
First occurred: 08:18:49 (1696 occurrences)
Last logged: 15:24:32

[Errno 2] could not open port /dev/ttyUSB3: [Errno 2] No such file or directory: ‘/dev/ttyUSB3’

Hi - as far as I know you cannot get the data from the smartmeter - you need to read out the data from the dtu or inverter directly.

Thats because your USB to RS485 converter is not connected to this serial port. From home assistant web interface, go to settings, then hardware and when you open hardware there is a three-dot menu on the top right corner - choose All Hardware and you will be presented with a list of all hardware connected to the computer which runs home assistant. From this list search for an entry which starts with ttyUSB. If there is only one serial convertor connected to the computer’s USB ports it should be ttyUSB0

Thank you! The problem with the USB-Port is gone now.
Unfortunately there is still the problem, that the sensor does not deliver any data.
When I open the sensor Info there is not data and when I open the energy dashboard there is
the message:

statistics_not_defined

  • sensor.smart_meter
  • sensor.smart_meter

Entity not available

  • sensor.smart_meter (unavailable)
  • sensor.smart_meter (unavailable)

try with this config

modbus:
  - name: meter
    type: serial
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    port: /dev/ttyUSB0
    stopbits: 1
    sensors:
    - name: sdm630_total_active_energy
      address: 0x2012
      input_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing

If it doesn’t work I cannot suggest anything else but to buy a meter that is known to work with HA!

Thank you!
I think I found the problem - it is the converter - it needs a ch340 driver installed to be seen…