Write a modbus register

Hello,

I have already read relatively far into HA and Modbus. In the meantime, I read out data via the Modbus integration with Home Assistant and display various values.

My YAML looks like this:

modbus:
  - name: hub1
    type: rtuovertcp
    host: 192.168.178.88
    port: 502
    sensors:
      - unique_id: 27acef9c-1f13-11ee-be56-0242ac120002
        name: EActual
        device_class: energy
        unit_of_measurement: "W"
        state_class: measurement
        slave: 247
        address: 781
        scan_interval: 7
        input_type: holding
        data_type: uint16

      - unique_id: c22bd43a-1f12-11ee-be56-0242ac120002
        name: ETotal
        device_class: energy
        unit_of_measurement: "Wh"
        state_class: measurement
        slave: 247
        address: 546
        scan_interval: 7
        input_type: holding
        data_type: uint32

      - name: EDay
        device_class: energy
        unit_of_measurement: "Wh"
        state_class: measurement
        slave: 247
        address: 566
        scan_interval: 7
        input_type: holding
        data_type: uint16

      - name: E-Limit
        device_class: energy
        unit_of_measurement: "%"
        state_class: measurement
        slave: 247
        address: 292
        scan_interval: 7
        input_type: holding
        data_type: uint16

Here is an excerpt from the PDF with the overview of the available registers:

Address | Name of Data               | Content | Unit  | Data Format | (R.W) Property | Range of Data | Remarks
0222    | ETotal                     |         | 0.1KW | INT32U      | R              |               | Total Energy Yield
030D    | Pac L                      |         | 1 W   | INT16U      | R              |               | low Byte of Feeding power
0236    | EDay                       |         | 0.1KW | INT16U      | R              |               | Energy yield in current day
0124    | Power limit setting with % |         | 1 %   | INT16U      | R/W            | 0-100         |

The address in the Modbus register overview is hex, in the YAML it is decimal under address.
The values are neatly displayed in the Home Assistant, including of course the power limit with e.g. 70%. Now I would like to not only read (R) but also write (W) these registers with a Range of Data value from 1-100.

I have really struggled with the whole Modbus, RS485 TCP LAN adapter, etc., but from here on I can’t get through. How can I create a slider in Home Assistant that I can control from 1-100? The value to which the slider is moved should then be written to the register.

I would be very happy if someone here knows more about the Modbus topic and can help me here.

1 Like

I have same problem, there does not seem to be easy solution for that. It would be great if this could be added to Modbus integration