Unable to write to Modbus register

Hey guys i’ve been scouring the forum all night trying to find a solution and i just cant get it to work.

I have victron inverter and im trying to set the input current limit with a slider,

com.victronenergy.vebus Active input current limit 22 int16 10 -3276.8 to 3276.7 /Ac/ActiveIn/CurrentLimit yes
FYI this is the modbus path outlines from the victron documentation

dbus-service-name	             description	        Address	  Type	Scale	        Range	                    dbus-obj-path	    writable
com.victronenergy.vebus	   Active input current limit	   22	   int16	10	-3276.8 to 3276.7	/Ac/ActiveIn/CurrentLimit	            yes

Steps taken,

  • Able to read the modbus value from the inverter - 16 (it is having to be scaled in the modbus.yaml
  - name: victron
    type: tcp
    host: 192.168.8.230
    port: 502
    sensors:
      - name: "Input_Current_limit"
        scan_interval: 5
        unit_of_measurement: "A"
        scale: 0.1
        slave: 239
        address: 22

  • Helper slider setup

  • Automation setup according to the forum

- id: '1633556127234'
  alias: Victron - Input Current Limit
  description: ''
  trigger:
  - platform: state
    entity_id: input_number.victron_input_limit
  condition: []
  action:
  - service: modbus.write_register
    data:
      address: 22
      unit: 239
      value: '{{ states.input_number.victron_input_limit.state|int }}'
  mode: single


I don’t have a hub defined as there is only one so i assume it will default plus it throws up errors the second i try and define a hub: victronhub anywhere.

Im at a bit of a loss and when i try and call the service manually it throws an error

SOLVED!!!

i have setup my sensor like that (in configuration yaml):

# Victron
modbus:
  - name: victron
    host: 192.168.1.20
    type: tcp
    port: 502
    sensors:
        # VEBUS
      - name: "Input Current limit"
        data_type: int16
        unit_of_measurement: "A"
        slave: 238
        address: 22
        scale: 0.1

then a placed a slider (in configuration yaml):

input_number:
  input_current_slider:
    name: Input Current Limit - Slider
    min: 0
    max: 16
    step: 0.5

and tried this automation:

alias: Input Current Limit
description: ''
trigger:
  - platform: state
    entity_id: input_number.input_current_slider
condition: []
action:
  - service: modbus.write_register
    data:
      address: 22
      unit: 238
      value: '{{ states(''input_number.input_current_slider'') | float * 10 }}'
      hub: victron
mode: single

and it works!

2 Likes

in conjunction with the above, you can feed back the sensor value to the slider by adding this automation:

alias: Input Current Limiter - Updater
trigger:
  - platform: state
    entity_id: sensor.input_current_limit
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.input_current_slider
    data:
      value: '{{ states(''sensor.input_current_limit'') | int }}'
1 Like

Do we really have to use the automation? It look cumbersome to me. It would be great if we could create the slider under the modbus itself so those two automations would not be needed.

Agree! “Input number” would be very helpful in such situations.

Hi @bzumik1 ,

total agree. But is there another solution?
Would be very interested in.

Thanks
Steffen

@Stroett I am not aware of any but I know that developer of this integration is pretty active so when we will find some more people than we could make it happen. I would also appreciate the template like option where we would be able to do some calculations/transformation on the values of modbus.

For example when you have variable containing 1,2,3 values corresponding for example to SLOW, MID, FAST enum …

Hi,
That would be great.
I would really appreciate having an “input_number” entity under “modbus” integration that would work as it is described in this thread.
Apparently there are some more similar topics:

Please vote on them.