Modbus switch are gone with Hassio ver. 2021.6.x

Hi,
i’ve tried to install latest version of Home Ass Core (2021.6.x) but after reboot all modbus switches entity are gone.
Anyone has or have had this issue?
Thanks in advance for any help,

Alessandro

You really should read the release notes before updating. Please read the modbus breaking changes (scroll down) and adjust your configuration:

Thanks for reply.
Yes, i’ve just seen that but i haven’t figured out how set new code in switch.yaml.
Actually i’ve this code in configuration.yaml:

#ModBus Ave
modbus:
  name: ave
  type: tcp
  host: 192.168.x.xx
  port: 502

…and all modbus switches configuration in switch.yaml like this:

- platform: modbus
  scan_interval: 5
  switches:
    - name: Faretti Studio
      slave: 1
      address: 72
      command_on: 1
      command_off: 0
      verify:
      - input_type: holding
        address: 72
        state_on: 32769
        state_off: 32768

I’ve these errors:

Invalid config for [switch.modbus]: must contain at least one of coils, registers… Got OrderedDict([(‘platform’, ‘modbus’), (‘scan_interval’, datetime.timedelta(seconds=5)), (‘switches’, [OrderedDict([(‘name’, ‘Faretti Studio’), (‘address’, 72), (‘command_on’, 1), (‘command_off’, 0), (‘verify’, [OrderedDict([(‘input_type’, ‘holding’), (‘address’, 72), (‘state_on’, 32769), (‘state_off’, 32768)])])])])]). (See ?, line ?).

Thanks again for your help.
Regards,

Alessandro

Please please please read the documentation and follow the examples. You’re trying to combine the old configuration with the new configuration.

Link below for switch configuration example. You’ll notice, it’s completely different from yours, all under the modbus field/namespace in yaml.

:smiley:
Thanks for the patience petro.
I’ve already seen modbus integration but i thought all modbus switches could be set in a single file (switch.yaml) yet and not all under configuration.yaml.

I’ll set all under configuration.yaml.
Thanks again.
Regards,

Alessandro

you can set all of modbus under a single file.

configuration.yaml

...
modbus: !include modbus.yaml

modbus.yaml

- type: tcp
  host: 1.1.1.1
  port: 1234
  switches:
  - name: xyz
    ...
  - name: abc
    ...
  sensors:
  - name: xyz
    ...
  - name: abc
    ...
1 Like

Ok,
i’ve created modbus.yaml but i’ve this conf error:

</s> <s>Invalid config for [modbus]: [register] is an invalid option for [modbus]. Check: modbus->modbus->0->switches->0->register. (See /config/configuration.yaml, line 297).</s> <s>

This is my modbus.yaml:

</s> <s>- type: tcp</s> <s> name: ave</s> <s> host: 192.168.x.xx</s> <s> port: 502</s> <s> switches:</s> <s> - name: Faretti Bagno P1</s> <s> slave: 1</s> <s> address: 35</s> <s> command_on: 1</s> <s> command_off: 0</s> <s> verify:</s> <s>

line 297 is: modbus: !include modbus.yaml

Any idea?
Thanks,

Alessandro

Fixed!

Has anyone figured out how to call registers from two different Modbus devices? I see this in the documentation :

But I am unable to use something like hub: hub1 when calling between the two servers?

Snippet of what I am trying to do:

modbus:

  • name: hub1
    type: tcp
    host: 192.168.2.66
    port: 502

  • name: hub2
    type: tcp
    host: 192.168.2.65
    port: 502

    sensors:

    • hub: hub1
      name: I Avg
      unit_of_measurement: ‘Amps’
      slave: 1
      count: 2
      scale: 1
      precision: 2
      data_type: float
      address: 3009
    • hub: hub2
      name: V Avg
      unit_of_measurement: ‘Volts’
      slave: 1
      count: 2
      scale: 1
      precision: 2
      data_type: float
      address: 3012

Put your sensors & switches below hub1 that go with hub 1…

- type: tcp
  host: 1.1.1.1
  port: 1234
  switches:
  - name: xyz
    ...
  - name: abc
    ...
  sensors:
  - name: xyz
    ...
  - name: abc
    ...
- type: tcp
  host: 2.2.2.2
  port: 1234
  switches:
  - name: xyz
    ...
  - name: abc
    ...
  sensors:
  - name: xyz
    ...
  - name: abc
    ...

Thank you!