Modbus response wrong, but correct request

Hi Everyone,
I want to read the energy data from a power meter (Hager SM103e with SM213 Modbus TCP communication module).
If I read the data with another software (Simply Modbus TCP Client 8.1.2) I get the correct value (~170 kW).

In Home Assistant it shows a completely different value (36.410 kW) (. Also tried other registers, they all show wrong in Home Assistant, but correct in Simply Modbus…

My configuration.yaml looks like this (The Hub named “Logger1000” works fine…):

modbus:
  - name: Logger1000
    type: tcp
    host: 192.168.1.147
    port: 502
    sensors:
      - name: Aktuelle Produktion PV W
        unique_id: LiveProdPVW
        slave: 247
        scale: 1
        unit_of_measurement: W
        address: 8069
        data_type: uint64
        input_type: input
        count: 4
        device_class: power
      - name: Tages Produktion PV kWh
        unique_id: DailyProdkWh
        slave: 247
        scale: 0.1
        precision: 1
        unit_of_measurement: kWh
        address: 8073
        data_type: uint32
        input_type: input
        count: 2
        swap: word
        device_class: energy
        state_class: total
      - name: Gesamt Produktion PV kWh
        unique_id: TotalProdPVkWh
        slave: 247
        scale: 0.1
        precision: 1
        unit_of_measurement: kWh
        address: 8079
        data_type: uint64
        input_type: input
        count: 4
        device_class: energy
        state_class: total
  - name: Trafo1
    type: tcp
    host: 192.168.1.61
    port: 502
    sensors:
      - name: Aktueller Verbrauch Trafo 1 kW
        unique_id: AktVerbrT1kW
        slave: 5
        scale: 2
        unit_of_measurement: kW
        address: 790
        data_type: int32
        swap: none
        count: 2
        device_class: power

What I saw in the Log is, that in the Log is, that for the Logger1000 (which is working fine) it shows “SEND”, “WAITING FOR REPLY”, “PROCESSING REPLY” and “TRANSACTION COMPLETE”

2023-08-23 10:16:37.699 DEBUG (SyncWorker_4) [pymodbus.logging] SEND: 0x0 0x1f 0x0 0x0 0x0 0x6 0xf7 0x4 0x1f 0x85 0x0 0x4
2023-08-23 10:16:37.699 DEBUG (SyncWorker_4) [pymodbus.logging] New Transaction state "SENDING"
2023-08-23 10:16:37.699 DEBUG (SyncWorker_4) [pymodbus.logging] Changing transaction state from "SENDING" to "WAITING FOR REPLY"
2023-08-23 10:16:37.701 DEBUG (SyncWorker_4) [pymodbus.logging] Changing transaction state from "WAITING FOR REPLY" to "PROCESSING REPLY"
2023-08-23 10:16:37.701 DEBUG (SyncWorker_4) [pymodbus.logging] RECV: 0x0 0x1f 0x0 0x0 0x0 0xb 0xf7 0x4 0x8 0x0 0x0 0x0 0x0 0x0 0x7 0xbc 0x6
2023-08-23 10:16:37.701 DEBUG (SyncWorker_4) [pymodbus.logging] Processing: 0x0 0x1f 0x0 0x0 0x0 0xb 0xf7 0x4 0x8 0x0 0x0 0x0 0x0 0x0 0x7 0xbc 0x6
2023-08-23 10:16:37.701 DEBUG (SyncWorker_4) [pymodbus.logging] Factory Response[ReadInputRegistersResponse': 4]
2023-08-23 10:16:37.701 DEBUG (SyncWorker_4) [pymodbus.logging] Adding transaction 31
2023-08-23 10:16:37.701 DEBUG (SyncWorker_4) [pymodbus.logging] Getting transaction 31
2023-08-23 10:16:37.701 DEBUG (SyncWorker_4) [pymodbus.logging] Changing transaction state from "PROCESSING REPLY" to "TRANSACTION_COMPLETE"
2023-08-23 10:16:37.704 DEBUG (SyncWorker_4) [pymodbus.logging] Current transaction state - TRANSACTION_COMPLETE
2023-08-23 10:16:37.704 DEBUG (SyncWorker_4) [pymodbus.logging] Running transaction 11

For the power meter (which is not working correctly) it only shows “SEND” and “TRANSACTION_COMPLETE”…

2023-08-23 10:16:37.704 DEBUG (SyncWorker_4) [pymodbus.logging] SEND: 0x0 0xb 0x0 0x0 0x0 0x6 0x5 0x3 0x3 0x16 0x0 0x2
2023-08-23 10:16:37.704 DEBUG (SyncWorker_4) [pymodbus.logging] New Transaction State "SENDING"
2023-08-23 10:16:37.704 DEBUG (SyncWorker_4) [pymodbus.logging] Current transaction state - TRANSACTION_COMPLETE
2023-08-23 10:16:37.704 DEBUG (SyncWorker_4) [pymodbus.logging] Running transaction 32

Any ideas?

Different IP address between Simply Modbus and HA config?

Thanks for your reply.
IP is correct, the hub “Trafo1” it’s 192.168.1.61 and in the Screenshoot also.

Just saw something:
In the log the send request is:

0x0 0xb 0x0 0x0 0x0 0x6 0x5 0x3 0x3 0x16 0x0 0x2

and in Simply Modbus it is (In the screenshoot in the field “Request”:

0x0 0x7 0x0 0x0 0x0 0x6 0x5 0x3 0x3 0x16 0x0 0x2

That Number is part of the transaction identifier. Does that have an Impact?

I was actually just typing out that the request in your simply Modbus app does not match your log map below.

I am going to sau it definitely matters as the request is likely wrong and therefore the device doesn’t know how to respond.

Do you know why they are different?

No, I don’t know why they are different…
In the documentation of Modbus it states, that the Transaction Identifier can be any. It’s repeated in the response to identify to which request the response belongs.

I just checked the number in Simply Modbus and it’s incrementing by 1 on each request I send. So that can’t be the problem…

OK, I think you can rule that out. Is it possible the end device is configured to ignore requests from certain clients like your HA instance, but it is configured to accept from the Modbus app client?

The Problem was “scale: 2” should be “scale: 0.01”…
My fault…

1 Like