Modbus with Power Meter configuration

I’m trying to get modbus to work between my power meter and HA but it seems I hit a wall after endless of searching and tinkering. I tried to configure but somehow it failed

`Invalid config for 'modbus' at configuration.yaml, line 113: expected int for dictionary value 'modbus->0->sensors->5->address', got '002A', please check the docs at https://www.home-assistant.io/integrations/modbus`

The address should be correct since I following the manufacturer’s documentation, the address for that particular sensor is on 002A.

here’s my yaml config for modbus:

modbus:
  - name: hub1
    type: tcp
    host: 192.168.8.6
    port: 8899
    sensors:
      - name: Phase R Voltage
        slave: 10
        address: 0025
        input_type: input
        unit_of_measurement: V
        device_class: voltage
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase S Voltage
        slave: 10
        address: 0026
        input_type: input
        unit_of_measurement: V
        device_class: voltage
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase T Voltage
        slave: 10
        address: 0027
        input_type: input
        unit_of_measurement: V
        device_class: voltage
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase RS Voltage
        slave: 10
        address: 0028
        input_type: input
        unit_of_measurement: V
        device_class: voltage
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase ST Voltage
        slave: 10
        address: 0029
        input_type: input
        unit_of_measurement: V
        device_class: voltage
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase TR Voltage
        slave: 10
        address: 002A
        input_type: input
        unit_of_measurement: V
        device_class: voltage
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16        
      - name: Phase R Current
        slave: 10
        address: 002B
        input_type: input
        unit_of_measurement: A
        device_class: current
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16             
      - name: Phase S Current
        slave: 10
        address: 002C
        input_type: input
        unit_of_measurement: A
        device_class: current
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16       
      - name: Phase T Current
        slave: 10
        address: 002D
        input_type: input
        unit_of_measurement: A
        device_class: current
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase R Active Power
        slave: 10
        address: 002E
        input_type: input
        unit_of_measurement: W
        device_class: power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase S Active Power
        slave: 10
        address: 002F
        input_type: input
        unit_of_measurement: W
        device_class: power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase T Active Power
        slave: 10
        address: 0030
        input_type: input
        unit_of_measurement: W
        device_class: power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase RST Active Power
        slave: 10
        address: 0031
        input_type: input
        unit_of_measurement: W
        device_class: power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase R Reactive Power
        slave: 10
        address: 0032
        input_type: input
        unit_of_measurement: var
        device_class: reactive_power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase S Reactive Power
        slave: 10
        address: 0033
        input_type: input
        unit_of_measurement: var
        device_class: reactive_power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
      - name: Phase T Reactive Power
        slave: 10
        address: 0034
        input_type: input
        unit_of_measurement: var
        device_class: reactive_power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16        
      - name: Phase RST Reactive Power
        slave: 10
        address: 0035
        input_type: input
        unit_of_measurement: var
        device_class: reactive_power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16        
      - name: Phase R Power Factor
        slave: 10
        address: 0036
        input_type: input
        unit_of_measurement: "%"
        device_class: power_factor
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16        
      - name: Phase S Power Factor
        slave: 10
        address: 0037
        input_type: input
        unit_of_measurement: "%"
        device_class: power_factor
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16  
      - name: Phase T Power Factor
        slave: 10
        address: 0038
        input_type: input
        unit_of_measurement: "%"
        device_class: power_factor
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16          
      - name: Phase RST Power Factor
        slave: 10
        address: 0039
        input_type: input
        unit_of_measurement: "%"
        device_class: power_factor
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16           
      - name: Phase R Apparent Power
        slave: 10
        address: 003A
        input_type: input
        unit_of_measurement: VA
        device_class: apparent_power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16             
      - name: Phase S Apparent Power
        slave: 10
        address: 003B
        input_type: input
        unit_of_measurement: VA
        device_class: apparent_power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16             
      - name: Phase T Apparent Power
        slave: 10
        address: 003C
        input_type: input
        unit_of_measurement: VA
        device_class: apparent_power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16             
      - name: Phase RST Apparent Power
        slave: 10
        address: 003D
        input_type: input
        unit_of_measurement: VA
        device_class: apparent_power
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16       
      - name: Phase RST Frequency
        slave: 10
        address: 003F
        input_type: input
        unit_of_measurement: Hz
        device_class: frequency
        count: 1
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16       

any help / input will be greatly appreciate it :slight_smile:

nevermind, it turns out the address needs to be converted from hex to decimals :slight_smile:

ok I encountered another issue, it turns out the decimal points of the data is changed dynamically :open_mouth: I’m not sure how to do this in home assistant. Can anyone assist?

the manual:

my ha config

      - name: Larkin Phase R Active Power
        slave: 1
        address: 46
        input_type: input
        unit_of_measurement: W
        device_class: power
        scale: 1
        offset: 0
        precision: 2
        data_type: int16
        scan_interval: 10

The scale is changed dynamically and I can retrieve the value of scale however I cannot figure out how to input the calculation in home assistant. Any help greatly appreaciate it :slight_smile:

I found a way (using value_template) to calculate the correct value of the power, however I am having issues retrieving the scale number (DPQ).

In home assistant when I use the data_type int16 I did get the value of 1264, however in the manual the data type is not int16, rather than “char”. I could not find information on this data type on home assistant.

Upon investigation I think the data is in left part of binary to number

which resulting number 4 which is the makes sense number to put into the formula of determinitng the correct value of decimal points per manufacturer manual.

How do I retrieve and process this in HA?

found the solution, using custom data type

name: Larkin DCT Decimal Point Current
        slave: 1
        address: 35
        input_type: input
        scale: 1
        offset: 0
        precision: 0
        data_type: custom
        count: 1
        structure: 'xB'
        scan_interval: 10
      - name: Larkin DPQ Decimal Point Power
        slave: 1
        address: 36
        input_type: input
        scale: 1
        offset: 0
        precision: 0
        data_type: custom
        count: 1
        structure: 'Bx'
        scan_interval: 10