Problem with modbus switches (Victron) after update

Hello.
I have this problem and I am not able to solve it. I use the modbus component to read sensors info and switch some functions in my Victron Energy inverter/charger.

It has been working for almost two years flawless but after last update I only can read the sensors and the switches are gone. I have tried several configurations without success. I see in last update something change in modbus but more relative about how to configure it.

Here my error log:

Logger: homeassistant.components.switch
Source: components/modbus/switch.py:25
Integration: Interruptor (documentation, issues)
First occurred: 18 de junio de 2021 23:52:31 (1 occurrences)
Last logged: 18 de junio de 2021 23:52:31

Error while setting up modbus platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/modbus/switch.py", line 25, in async_setup_platform
    for entry in discovery_info[CONF_SWITCHES]:
TypeError: 'NoneType' object is not subscriptable
Logger: homeassistant.components.modbus.modbus
Source: components/modbus/modbus.py:203
Integration: Modbus (documentation, issues)
First occurred: 18 de junio de 2021 23:52:42 (4832 occurrences)
Last logged: 20:00:39

Pymodbus: Exception Response(131, 3, GatewayPathUnavailable)

Here my configuration.yaml

modbus:
  - name: "victron"
    type: tcp
    host: 192.168.0.7
    port: 502

sensors.yaml working

  - platform: modbus
    scan_interval: 3
    registers:
    - name: V Grid Power
      hub: victron
      unit_of_measurement: "W"
      slave: 100
      register: 820
    - name: V Load
      hub: victron
      unit_of_measurement: "W"
      slave: 100
      register: 817
    - name: V Battery SoC
      hub: victron
      unit_of_measurement: "%"
      slave: 100
      register: 843
etc...

And here switches.yaml where the problem is:

  - platform: modbus
    registers:
      - name: Victron - Cargador
        hub: victron
        slave: 100
        register: 2701
        command_on: 100
        command_off: 0
        verify_state: false
      - name: Victron - Inversor
        hub: victron
        slave: 100
        register: 2702
        command_on: 100
        command_off: 0
        verify_state: false

Victron has not change the registers as far I know and check. Stop working after update.

Any ideas? Thanks in advance.

You need to update your config to the new way.

Now it all goes under modbus: rather than under separate platforms like switch: or sensor:

And the option name of register has changed to address

See examples here:

https://www.home-assistant.io/integrations/modbus/#configuring-platform-switch

You should do this move for your sensors, switches and any other modbus entities.

1 Like

THANK YOU so much!!
I have tried before the new config but I did it wrong. I was using “register” instead “address” but after you told me I wrote again following the new method and finally I have back my switches (they are very important in my installation).

Again, thank you very much!

1 Like

@robermf would you mind sharing what you changed the switches and sensors to please? I’m having the same issue but struggling to get it sorted out.

Thanks.

1 Like

Hi!
I had to move out switches and sensors to configuration.yaml (or you can create a new yaml file, but not with the other switches.
Here is my config:

modbus:
  - name: "victron"
    type: tcp
    host: 192.168.0.7
    port: 502

    switches:
      - name: Victron - CarLimit- ctive input current
        slave: 238
        address: 22
        command_on: 1700
        command_off: 500

      - name: Victron - 0 W Prueba

        slave: 238
        address: 37
        command_on: 1700
        command_off: 500

      - name: Victron - 0 W Prueba2705

        slave: 100
        address: 2705
        command_on: 70
        command_off: 55

      - name: Victron - Cargador

        slave: 100
        address: 2701
        command_on: 100
        command_off: 0

      - name: Victron - Inversor

        slave: 100
        address: 2702
        command_on: 100
        command_off: 0

#      - name: Victron Grid Power Setpoint
#        hub: victron
#        slave: 100
#        register: 2700
#        command_on: 4000
#        command_off: 80
#        verify_state: false
      - name: Victron Min SoC (Unless grid fails)

        slave: 100
        address: 2901
        command_on: 95
        command_off: 5
     
#      - name: Victron Set SoC
#        hub: victron
#        slave: 238
#        register: 30
#        command_on: 95
#        command_off: 5
#        verify_state: false      
#      - name: Victron AC Current Limit
#        hub: victron
#        slave: 100
#        register: 2316
#        command_on: 30
#        command_off: 5
#        verify_state: false      
#      - name: Victron Active Current Limit
#        hub: victron
#        slave: 100
#        register: 22
#        command_on: 30
#        command_off: 5
#        verify_state: false  

















    sensors:
      - name: V Grid Power
        scan_interval: 3
        slave: 100
        address: 820
        unit_of_measurement: "W"
      - name: V Load
        scan_interval: 3      
        unit_of_measurement: "W"
        slave: 100
        address: 817
#SoC Bateria sin decimal
      - name: V Battery SoC
        scan_interval: 3      
        unit_of_measurement: "%"
        slave: 100
        address: 843
#Battery Power sin invertir
      - name: V Battery Power
        scan_interval: 3      
        unit_of_measurement: "W"
        slave: 100
        address: 842
#Necesita añadir coma para decimal
      - name: V BaterĂ­a Voltaje
        unit_of_measurement: "V"
        slave: 100
        address: 840
        scale: 10
      - name: V BaterĂ­a Intensidad
        unit_of_measurement: "A"
        slave: 100
        address: 841
        scale: 100
#Convertir estados: 0 idle, 1 charging, 2 dischargin     
      - name: V Battery State
        slave: 100
        address: 844
#Necesita añadir coma para decimal
      - name: V Battery Consumed Ah
        unit_of_measurement: "Ah"
        slave: 100
        address: 845
#Writable  
      - name: V Active Input Current Limit
        unit_of_measurement: "A"
        slave: 239
        address: 22
      - name: V Output Power 1
        unit_of_measurement: "W"
        slave: 239
        address: 23

      - name: V Switch Position
#      unit_of_measurement: "W"
        slave: 239
        address: 33


2 Likes

Thanks @robermf for posting your config, I’ve gotten my switches and sensors working again.

1 Like

Menos mal que he encontrado tu post. Me estaba volviendo loco!!!

Gracias!!!

1 Like

how would you create a slider to adjust the amp input limit?

1 Like

Could someone check my modbus config, I cannot get it to work after updating HA and it worked before the updates. I have tried to copy other formats shown or linked in this thread but can’t get it to work, I have tried using it in my configuration.yaml file as well as in it’s own modbus.yaml file, nothing works and I can’t see where I have gone wrong.

modbus:
  - name: "Catt House Electricity"
    type: tcp
    host: 192.168.1.251
    port: 502
    sensors:
      - name: Victron Home AC Consumption
        scan_interval: 5
        data_type: uint
        slave: 100
        register: 817
        unit_of_measurement: "W"
      - name: Victron PV Power
        scan_interval: 5
        data_type: uint
        slave: 100
        register: 850
        unit_of_measurement: "W"
      - name: Victron Grid Power
        scan_interval: 5
        data_type: int
        slave: 100
        register: 820
        unit_of_measurement: "W"
      - name: Victron Battery Power
        scan_interval: 5
        data_type: int
        slave: 100
        register: 842
        unit_of_measurement: "W"
      - name: PV Yield Today
        scan_interval: 5
        data_type: uint
        slave: 245
        register: 784
        unit_of_measurement: "kWh"
      - name: PV Yield Yesterday
        scan_interval: 5
        data_type: uint
        slave: 245
        register: 786
        unit_of_measurement: "kWh"
      - name: Grid State
        scan_interval: 5
        slave: 242
        register: 64
        unit_of_measurement: "on/off"

Use address rather than register?

Thanks! It was that and I had sensor instead of sensors.

Hi!

How can I add a slider to set the percentage instead of ON/OFF?
Thank You!!!