Modbus config problem

I have been trying to configure my inputs every way but never result in a workable solution;
my latest attenpt has script as follows with errors thereafter.
I use serial 9600 8,N,1 all hardware working fine for sending data just cannot configure inputs
Latest trial script;
`

  • name: “keep_door”
    unique_id: keep door
    address: 0
    scan_interval: 5
    slave: 113
    device_class: ‘door’
    input_type: discrete_input
    slave_count: 8

    lights:

    • name: “pond_pump”
      address: 0
      slave: 110
      `
      and error thrown by integration;

Logger: homeassistant.config
Source: components/modbus/validators.py:150
First occurred: 14 September 2022 at 15:30:42 (1 occurrences)
Last logged: 14 September 2022 at 15:30:42
Unknown error calling modbus CONFIG_SCHEMA

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config.py”, line 832, in async_process_component_config
return component.CONFIG_SCHEMA(config) # type: ignore[no-any-return]
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 272, in call
return self._compiled([], data)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 595, in validate_dict
return base_validate(path, iteritems(data), out)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 387, in validate_mapping
cval = cvalue(key_path, value)
File “/usr/local/lib/python3.9/site-packages/voluptuous/validators.py”, line 229, in _run
return self._exec(self._compiled, value, path)
File “/usr/local/lib/python3.9/site-packages/voluptuous/validators.py”, line 353, in _exec
v = func(path, v)
File “/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py”, line 818, in validate_callable
return schema(data)
File “/usr/src/homeassistant/homeassistant/components/modbus/validators.py”, line 150, in scan_interval_validator
for entry in hub[conf_key]:
TypeError: ‘NoneType’ object is not iterable

Please, please, can anyone produce the correct script to input eight discreet inputs in one read
Not reading coil status but eight discreet inputs as modbus protocol allows
sent data (command) should look like ; 01 02 00 00 00 08 79 CC
received data will be returned as 01 02 01 00 A1 88
That’s address one, function two, one byte, and checksum returned.
works perfectly with a monitor programme.
Any help very welcome!

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Sorry Tom, Thanks for the nudge.
The modbus code looks like this;

modbus:
  - name: "hub1"
    close_comm_on_error: false
    delay: 5
    timeout: 1
    type:  serial
    baudrate:  9600
    bytesize:  8
    method:  rtu
    parity:   N
    port:  /dev/ttyUSB0
    stopbits:  1
    binary_sensors:
    # Example configuration.yaml entry for binary_sensor configuration
      - name: "lower hall ios"
        address: 0
        scan_interval: 2
        slave: 100
        input_type: 'discreet_input'
        slave_count:  8
        device_class: 'presence'
The validator comes up with this error:

                    Invalid config for [modbus]: value must be one of ['coil', 'discrete_input'] for dictionary value @ data['modbus'][0]['binary_sensors'][0]['input_type']. Got 'discreet_input'. (See /config/configuration.yaml, line 21). 
From where I'm sitting I have set input_type to discreet_input and have tried with and without  quote marks around  the discreet_input text.  I notice the example shows the type discreet_input in black whereas my displays red is this a clue?
Still desperately seeking answers....


``

Hello,

The error message is telling you:

Invalid config for [modbus]: value must be one of ['coil', 'discrete_input'] for dictionary value @ data['modbus'][0]['binary_sensors'][0]['input_type']. Got 'discreet_input'.

You are puting discreet_input instead of discrete_input, it’s just a typo :slight_smile:

I can get 4 values in one read:

binary_sensors:
    - name: "Logo Chaufferie Input"
      input_type: discrete_input
      address: 0
      slave_count: 3

Values will be named:

binary_sensor.logo_chaufferie_input
binary_sensor.logo_chaufferie_input_1
binary_sensor.logo_chaufferie_input_2
binary_sensor.logo_chaufferie_input_3

I hope that helps.

Many Thanks for your sharp observation. I had previously tried with the correct spelling, however, your post led me on an alternate route and things are looking far more promising now… The relay boards I have are real fussy with no error messaging - if they don’t like the command they just don’t reply! That was the issue. I noted you asked for three and read four parameters. The problem is with Modbus you’re never sure if the indexing starts at one OR ZERO. Once I changed my script to ask for seven parameters the board began replying to requests. I’m still not getting correct data yet, but at least I now can have a conversation with the ones and noughts! Thank you so much for replying to the post it is much appreciated.

1 Like

A day later and I am now reading values from one of the two styles of Modbus boards I have I’ll have to make more tests on the (larger) boards. Thanks again for your post.

1 Like