Multiple tcp modbus slaves?

Is it possible to use multiple tcp modbus devices on different ip adresses

modbus:
   type: tcp
   host: 192.168.1.24
   port: 502 
modbus2:
   type: tcp
   host: 192.168.1.204
   port: 502

this does not work

So, it is not possible jet?

Did You test this?

I think I figured it out!

Copy /srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/modbus.py
to “your_config”/custom_components
rename it modbus1.py
edit the file by changing DOMAIN = 'modbus1'

image

Now if you want a Modbus sensor

Copy /srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/modbus.py
to “your_config”/custom_components/sensor
rename it modbus1.py
edit the file by changing import homeassistant.components.modbus as modbus to
import custom_components.modbus1 as modbus
and then DEPENDENCIES = ['modbus1']

image

Note* I am running in a pvenv so I had to make homeassistant the owner of all the directories and files.

  • custom_components, modbus1.py, sensor, modbus1.py

configuration.yaml…

modbus:
  type: tcp
  host: 127.0.0.1
  port: 4000


modbus1:
  type: rtuovertcp
  host: 192.168.254.196
  port: 4598

sensor:
  - platform: modbus
    registers:
      - name: S1
        unit_of_measurement: 'mA'
        slave: 2
        register: 309
        register_type: holding
        count: 1
        precision: 2
        scale: 0.01
        data_type: custom
        structure: ">h"

  - platform: modbus1
    scan_interval: 60
    registers:
      - name: S2
        unit_of_measurement: 'feet'
        slave: 1
        register: 1
        register_type: holding
        count: 2
        scale: 3.281
        precision: 2
        data_type: float

restart HA Done!

Is there an easy way to access that file on Rpi, samba share does not show it

FYI, a PR just got merged a few days ago to allow multiple modbus hubs. Should be possible in the next release of HA.

https://github.com/home-assistant/home-assistant/pull/19726

what will be way of configuration?

Have a PR for the multiple Modbus slaves https://github.com/home-assistant/core/pull/47043
Can someone pls help me convince code owners that the HA community needs it?