Integrate Modbus RTU/RS485 Energy Meter(s) with Home Assistant...

Post Reply
rashdown_online
Posts: 7
Joined: Wed Jan 18, 2023 4:49 pm

Hello all.

I post this on the HA community forum. But thought it might come in handy for people who are "new" to configuring HA to work with RS485 energy meters.

With the help of people across teh HA community, I’ve got my Eastrons working as I hoped. So here’s a copy of my modbus config for all those others out there who are “new” to this, and might find helpful.

My setup:
  • 1x Eastron SDM230
  • 3x Eastron SDM120
  • 1x Industrial Modbus RS485 to USB Adaptor
  • 1x IntelNUC (i5; 8Gb RAM; 128Gb SSD) flashed for HA only
  • Daisy-chained using a single pair taken from a CAT6 cable.
  • No GND cable
  • No Terminating resistor
  • My configuration.yaml calls a separate file in the same directory as the config.yaml called “modbusUSB.yaml”.
Extract from my "configuration.yaml":

Code: Select all

modbus: !include modbusUSB.yaml
Contents of “modbusUSB.yaml”.

I’m able to read the following data on all of the individual meters:
  • Active Energy (kWh)
  • Voltage (V)
  • Current (A)
  • Active Power (W)
  • Power Factor
NOTE: You'll need to change the port and other settings at the top of the code to suit your specific installation/hardware.
NOTE: You must also ensure the "slave" value(s) match that of each individual meter - the meters need to have their own unique ID.
NOTE: You can also change the "name" and "unique_id" to suit your requirements.

Code: Select all

# ---------------------------USB/Serial--------------------------------------
# Modbus Config confirmed working for Eastron SDM230 and SDM120 single phase energy meters
# Adjust port setting to match USB port in use
# "slave" setting should be changed on each SDM individually, and each sensor updated accordingly

- name: HomeModbus1
  type: serial
  baudrate: 9600
  bytesize: 8
  method: rtu
  parity: N
  port: /dev/ttyACM0
  stopbits: 1
  # ---------------------------------------------------------------------------

  sensors:
# SDM120; EPS Circuits
# Slave 200
    - name: "EPS Active Energy"
      unique_id: eps_active_energy
      address: 342
      input_type: input
      count: 2
      slave: 200
      precision: 2
      data_type: float32
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing
    - name: "EPS Voltage"
      unique_id: eps_voltage
      slave: 200
      address: 0
      input_type: input
      count: 2
      precision: 2
      data_type: float32
      unit_of_measurement: V
      device_class: voltage
    - name: "EPS Current"
      unique_id: eps_current
      slave: 200
      address: 6
      input_type: input
      count: 2
      precision: 3
      data_type: float32
      unit_of_measurement: A
      device_class: current
    - name: "EPS Active Power"
      unique_id: eps_active_power
      slave: 200
      address: 12
      input_type: input
      count: 2
      precision: 3
      scale: 0.001
      data_type: float32
      unit_of_measurement: kW
      device_class: power
    - name: "EPS Power Factor"
      unique_id: eps_power_factor
      slave: 200
      address: 30
      input_type: input
      count: 2
      precision: 2
      data_type: float32
      unit_of_measurement: cosф
      device_class: power_factor
# SDM230; Non-EPS Circuits
# Slave 100
    - name: "Non-EPS Active Energy"
      unique_id: non_eps_active_energy
      address: 342
      input_type: input
      count: 2
      slave: 100
      precision: 2
      data_type: float32
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing
    - name: "Non-EPS Voltage"
      unique_id: non_eps_voltage
      slave: 100
      address: 0
      input_type: input
      count: 2
      precision: 2
      data_type: float32
      unit_of_measurement: V
      device_class: voltage
    - name: "Non-EPS Current"
      unique_id: non_eps_current
      slave: 100
      address: 6
      input_type: input
      count: 2
      precision: 3
      data_type: float32
      unit_of_measurement: A
      device_class: current
    - name: "Non-EPS Active Power"
      unique_id: non_eps_active_power
      slave: 100
      address: 12
      input_type: input
      count: 2
      precision: 3
      scale: 0.001
      data_type: float32
      unit_of_measurement: kW
      device_class: power
    - name: "Non-EPS Power Factor"
      unique_id: non_eps_power_factor
      slave: 100
      address: 30
      input_type: input
      count: 2
      precision: 2
      data_type: float32
      unit_of_measurement: cosф
      device_class: power_factor
# SDM120; Induction Hob Circuit
# Slave 101
    - name: "Hob Active Energy"
      unique_id: hob_active_energy
      address: 342
      input_type: input
      count: 2
      slave: 101
      precision: 2
      data_type: float32
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing
    - name: "Hob Voltage"
      unique_id: hob_voltage
      slave: 101
      address: 0
      input_type: input
      count: 2
      precision: 2
      data_type: float32
      unit_of_measurement: V
      device_class: voltage
    - name: "Hob Current"
      unique_id: hob_current
      slave: 101
      address: 6
      input_type: input
      count: 2
      precision: 3
      data_type: float32
      unit_of_measurement: A
      device_class: current
    - name: "Hob Active Power"
      unique_id: hob_active_power
      slave: 101
      address: 12
      input_type: input
      count: 2
      precision: 3
      scale: 0.001
      data_type: float32
      unit_of_measurement: kW
      device_class: power
    - name: "Hob Power Factor"
      unique_id: hob_power_factor
      slave: 101
      address: 30
      input_type: input
      count: 2
      precision: 2
      data_type: float32
      unit_of_measurement: cosф
      device_class: power_factor
# SDM120; Immersion Circuit
# Slave 102
    - name: "Immersion Active Energy"
      unique_id: immersion_active_energy
      address: 342
      input_type: input
      count: 2
      slave: 102
      precision: 2
      data_type: float32
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing
    - name: "Immersion Voltage"
      unique_id: immersion_voltage
      slave: 102
      address: 0
      input_type: input
      count: 2
      precision: 2
      data_type: float32
      unit_of_measurement: V
      device_class: voltage
    - name: "Immersion Current"
      unique_id: immersion_current
      slave: 102
      address: 6
      input_type: input
      count: 2
      precision: 3
      data_type: float32
      unit_of_measurement: A
      device_class: current
    - name: "Immersion Active Power"
      unique_id: immersion_active_power
      slave: 102
      address: 12
      input_type: input
      count: 2
      precision: 3
      scale: 0.001
      data_type: float32
      unit_of_measurement: kW
      device_class: power
    - name: "Immersion Power Factor"
      unique_id: immersion_power_factor
      slave: 102
      address: 30
      input_type: input
      count: 2
      precision: 2
      data_type: float32
      unit_of_measurement: cosф
      device_class: power_factor
With the above, I’m able to get kWh (Active Energy) from each meter, so there's no need to write script to change power to energy.

These energy meters are not placed to monitor import/export - I’ll be using a solar inverter (Fox-ESS H1 6kW) for that. I also have a Hildebrand GLOW In House Display (IHD) reading my SMETS2 and sending data via MQTT to my HA instance. This allows me to track tariff rates and import/export consumption at the boundary line. (This is a UK setup).

I will also be adding further Eastrons over time, as and when teh need presents itself.

I also pull in other energy data from various Shelly plus1PMs and a Shelly Pro4PM.

I'm now able to monitor individual devices in HA through the Energy dashboard, as well as get other data (current/voltage/PF) via Grafana or dashboard cards.

Hope the above is of use to someone out there.

Thanks.

Roland.
calum
Posts: 398
Joined: Fri Feb 24, 2023 11:00 am
Location: Stockport

Thanks for sharing. How do you find the Glow IHD? Reliable?
H1-3.7 / 6xHV2600 / 14x400W / RS485 Modbus->HA
FoxESS Modbus HA Integration
Contact Fox here
rashdown_online
Posts: 7
Joined: Wed Jan 18, 2023 4:49 pm

Hi Calum.

It's been working well so far for me. I've had it running for a good few months now.

I've been on a fixed rate with E.On up to the end of March and transferred to Octopus in April in readiness for Flux after my SolarPV+Battery gets signed off.

The GLOW picked up the SMETS2 changes.

There's a bit of HA coding for MQTT sensors, and I have speak-to-the-geek to thank for that.

All-in-all, I'm happy with it. And their support team are good, too.

Thanks.
Post Reply