Group updates from Modbus read on multiple nodes

Hi

I have three electricity meters in our house, and I’m reading six values from each.
They are on the same modbus line, but clearly they are on three different modbus-controllers.
My issue is, right now, they are read one node at a time, and the values does not appear in HomeAssistant at the same time.
I’m doing som calculations in HA, but since the values are not read at the (nearly) same time, I get a lot of spikes.
Does anyone know of a way or a trick to not send the values to HA until all three nodes have been read?

Wouldn’t it be better to do calculations on esphome?

Then I need to change a lot, and will loose historical data.
Some of the calculations are done on statistical entities based on modbus readings.
I changed from a RS485 USB-Stick to ESPHome to get it done wirelessly, and I therefore have, I guess, two years of historical data that I will lose, if I change the entities in HA

Post your code (with code tags).

Sorry for the delay :slight_smile:
Here’s the code for reading the nodes

uart:
  - id: uart_iem3155
    rx_pin: GPIO12 # D6
    tx_pin: GPIO14 # D5
    baud_rate: 38400
    data_bits: 8
    parity: EVEN
    stop_bits: 1

modbus:
  - id: modbus_iem3155
    uart_id: uart_iem3155

modbus_controller:
  - id: modbus_house_meter
    address: 1
    modbus_id: modbus_iem3155
    setup_priority: -10
    update_interval: 10s
  - id: modbus_solar_meter
    address: 2
    modbus_id: modbus_iem3155
    setup_priority: -10
    update_interval: 10s
  - id: modbus_charge_box_meter
    address: 3
    modbus_id: modbus_iem3155
    setup_priority: -10
    update_interval: 10s

# https://esphome.io/components/number/modbus_controller/

sensor:

  #####################################
  ## Houese-Meter - ReadModbusActual ##
  #####################################
  
  # Read Actual import
  # readHoldingRegisters( 3053, 8 ) - P1, P2, P3, Ptot (hver er Float32)
  # 0-1 => P L1
  # 2-3 => P L2
  # 4-5 => P L3
  # 6-7 => P Ltot
  - platform: modbus_controller
    modbus_controller_id: modbus_house_meter
    name: "T - iem3155modbus - House-Meter - Actual - L1"
    register_type: holding
    address: 3053
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0
  - platform: modbus_controller
    modbus_controller_id: modbus_house_meter
    name: "T - iem3155modbus - House-Meter - Actual - L2"
    register_type: holding
    address: 3055
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0
  - platform: modbus_controller
    modbus_controller_id: modbus_house_meter
    name: "T - iem3155modbus - House-Meter - Actual - L3"
    register_type: holding
    address: 3057
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0
  - platform: modbus_controller
    modbus_controller_id: modbus_house_meter
    name: "T - iem3155modbus - House-Meter - Actual - All"
    register_type: holding
    address: 3059
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0

  ####################################
  ## Houese-Meter - ReadModbusTotal ##
  ####################################

  # Read Total Import
  # readHoldingRegisters( 3203, 4 ) - hver er Int64
  # Total Import: Importeret til husstanden (+ forbrugt af inverteren)
  - platform: modbus_controller
    modbus_controller_id: modbus_house_meter
    name: "T - iem3155modbus - House-Meter - Import"
    register_type: holding
    address: 3203
    unit_of_measurement: "kWh"
    value_type: S_QWORD 
    accuracy_decimals: 3
    filters:
      - multiply: 0.001
  # Read Total Export
  # readHoldingRegisters( 3207, 4 ) - hver er Int64
  # Total Export: Eksporteret fra husstanden
  - platform: modbus_controller
    modbus_controller_id: modbus_house_meter
    name: "T - iem3155modbus - House-Meter - Export"
    register_type: holding
    address: 3207
    unit_of_measurement: "kWh"
    value_type: S_QWORD 
    accuracy_decimals: 3
    filters:
      - multiply: 0.001

####################################
## Solar-Meter - ReadModbusActual ##
####################################

# Read Actual import
# readHoldingRegisters( 3053, 8 ) - P1, P2, P3, Ptot (hver er Float32)
# 0-1 => P L1
# 2-3 => P L2
# 4-5 => P L3
# 6-7 => P Ltot
  - platform: modbus_controller
    modbus_controller_id: modbus_solar_meter
    name: "T - iem3155modbus - Solar-Meter - Actual - L1"
    register_type: holding
    address: 3053
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0
  - platform: modbus_controller
    modbus_controller_id: modbus_solar_meter
    name: "T - iem3155modbus - Solar-Meter - Actual - L2"
    register_type: holding
    address: 3055
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0
  - platform: modbus_controller
    modbus_controller_id: modbus_solar_meter
    name: "T - iem3155modbus - Solar-Meter - Actual - L3"
    register_type: holding
    address: 3057
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0
  - platform: modbus_controller
    modbus_controller_id: modbus_solar_meter
    name: "T - iem3155modbus - Solar-Meter - Actual - All"
    register_type: holding
    address: 3059
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0

###################################
## Solar-Meter - ReadModbusTotal ##
###################################

# Read Total Import
# readHoldingRegisters( 3203, 4 ) - hver er Int64
# Total Import: På grund af den måde, som måleren er monteret på, så er Import => produceret (fra inverteren) - Af hensyn til logikken er dette omvendt i HA => Export er produceret for inverteren
  - platform: modbus_controller
    modbus_controller_id: modbus_solar_meter
    name: "T - iem3155modbus - Solar-Meter - Import"
    register_type: holding
    address: 3203
    unit_of_measurement: "kWh"
    value_type: S_QWORD 
    accuracy_decimals: 3
    filters:
      - multiply: 0.001
# Read Total Export
# readHoldingRegisters( 3207, 4 ) - hver er Int64
# Total Export: På grund af den måde, som måleren er monteret på, så er Export => forbrugt (til inverteren) - Af hensyn til logikken er dette omvendt i HA => Import er forbrugt for inverteren
  - platform: modbus_controller
    modbus_controller_id: modbus_solar_meter
    name: "T - iem3155modbus - Solar-Meter - Export"
    register_type: holding
    address: 3207
    unit_of_measurement: "kWh"
    value_type: S_QWORD 
    accuracy_decimals: 3
    filters:
      - multiply: 0.001

#########################################
## Charge-Box-Meter - ReadModbusActual ##
#########################################

# Read Actual import
# readHoldingRegisters( 3053, 8 ) - P1, P2, P3, Ptot (hver er Float32)
# 0-1 => P L1
# 2-3 => P L2
# 4-5 => P L3
# 6-7 => P Ltot
  - platform: modbus_controller
    modbus_controller_id: modbus_charge_box_meter
    name: "T - iem3155modbus - Charge-Box - Actual - L1"
    register_type: holding
    address: 3053
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0
  - platform: modbus_controller
    modbus_controller_id: modbus_charge_box_meter
    name: "T - iem3155modbus - Charge-Box - Actual - L2"
    register_type: holding
    address: 3055
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0
  - platform: modbus_controller
    modbus_controller_id: modbus_charge_box_meter
    name: "T - iem3155modbus - Charge-Box - Actual - L3"
    register_type: holding
    address: 3057
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0
  - platform: modbus_controller
    modbus_controller_id: modbus_charge_box_meter
    name: "T - iem3155modbus - Charge-Box - Actual - All"
    register_type: holding
    address: 3059
    unit_of_measurement: "W"
    value_type: FP32
    accuracy_decimals: 0
    filters:
      - multiply: 1000.0

########################################
## Charge-Box-Meter - ReadModbusTotal ##
########################################

# Read Total Import
# readHoldingRegisters( 3203, 4 ) - hver er Int64
# Total Import: På grund af den måde, som måleren er monteret på, så er Import => produceret (fra inverteren) - Af hensyn til logikken er dette omvendt i HA => Export er produceret for inverteren
  - platform: modbus_controller
    modbus_controller_id: modbus_charge_box_meter
    name: "T - iem3155modbus - Charge-Box - Import"
    register_type: holding
    address: 3203
    unit_of_measurement: "kWh"
    value_type: S_QWORD 
    accuracy_decimals: 3
    filters:
      - multiply: 0.001
# Read Total Export
# readHoldingRegisters( 3207, 4 ) - hver er Int64
# Total Export: På grund af den måde, som måleren er monteret på, så er Export => forbrugt (til inverteren) - Af hensyn til logikken er dette omvendt i HA => Import er forbrugt for inverteren
  - platform: modbus_controller
    modbus_controller_id: modbus_charge_box_meter
    name: "T - iem3155modbus - Charge-Box - Export"
    register_type: holding
    address: 3207
    unit_of_measurement: "kWh"
    value_type: S_QWORD 
    accuracy_decimals: 3
    filters:
      - multiply: 0.001