Modbus first installation

Hi

I have problems starting with modbus.

Here are my observations. When i add “modbus:” to my configuration.yaml the configuration check ends up with the spinning wheel and is not returning any results. Also no error message or warning.

Do I need to install the integration first?

Tanks for any support.

modbus is a core integration, so you don’t need to install anything.
You should add a hub, not just empty modbus:. See Modbus - Home Assistant

ok. thanks. so no extra installation.

So my initial try had more code. but as said it throughs an error even if I strip down the config to just

modbus:

Here is my full setup:

modbus:      
  - name: "hub1"
    type: tcp
    host: 192.168.177.24
    climates: 
    - name: Dining
      slave: 1
      data_type: int
      data_count: 1
      scale: 0.1
      offset: 0
      precision: 1
      max_temp: 30
      min_temp: 15
      temp_step: 0.5
      target_temp_register: 51
      current_temp_register: 50
      current_temp_register_type: input  

The error in th log is

2022-01-31 16:50:02 ERROR (MainThread) [homeassistant.config] Unknown error calling modbus CONFIG_SCHEMA
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config.py", line 842, in async_process_component_config
    return component.CONFIG_SCHEMA(config)  # type: ignore
  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 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
    cval = cvalue(key_path, value)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 215, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 339, in _exec
    v = func(path, v)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/src/homeassistant/homeassistant/components/modbus/validators.py", line 236, in duplicate_modbus_validator
    if hub[CONF_TYPE] == SERIAL:
KeyError: 'type'
2022-01-31 16:50:02 ERROR (MainThread) [homeassistant.setup] Setup failed for modbus: Invalid config.

Any idea?

Your indentation is wrong. Should be

modbus:
  - name: "hub1"
    type: tcp
    host: 192.168.177.24
    climates:
      - name: Dining
        slave: 1
        data_type: int
        data_count: 1
        scale: 0.1
        offset: 0
        precision: 1
        max_temp: 30
        min_temp: 15
        temp_step: 0.5
        target_temp_register: 51
        current_temp_register: 50
        current_temp_register_type: input

Thanks. true. Gave that a try. Still no success. When validating the config (which is fine without modbus) i get the spinning wheel.

and this is in the logs:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/core.py", line 29, in post
    errors = await async_check_ha_config_file(request.app["hass"])
  File "/usr/src/homeassistant/homeassistant/config.py", line 938, in async_check_ha_config_file
    res = await check_config.async_check_ha_config_file(hass)
  File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 183, in async_check_ha_config_file
    config = config_schema(config)
  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 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
    cval = cvalue(key_path, value)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 215, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/validators.py", line 339, in _exec
    v = func(path, v)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/src/homeassistant/homeassistant/components/modbus/validators.py", line 201, in duplicate_entity_validator
    addr = str(entry[CONF_ADDRESS])
KeyError: 'address'

You are missing address in your climate’s config.

hmmm, true, you are chasing me ;-)… that will need some time to figure out! i will come back to you.

1 Like

Tell you what. It works!

So key learning for me:

  1. config checks ending up in a spinning wheel might still be caused by configuration error.
  2. for modbus in particular i found a lot of samples that are wrong or incompatible with current modbus. So really refer to the manual. E.g.
current_temp_register_type: input

is wrong, new syntax is

input_type: input
  1. VIEGA floor heating: only use the last two digits from the register (at least that help get my case working)
  2. VIEGA floor heating: do not forget to activate modbus in the VIEGA control panel

Kudos to @ondras12345 . That helped a lot!

Cheers

1 Like

Hi there,

Has anyone got it working with outputs (coils) being able to get activated? I have the Advantech ADAM-series (6050 and 6052) and so far I can only read sensors (inputs)

1 Like

Hi, can you please give me some help of how to read the inputs?

Here’s my config:

- name: "Adam6050Back"
  type: tcp
  host: 192.168.2.160
  port: 502
  binary_sensors:
    - name: "Input 6050_00 -"
      address: 0000
      unique_id: 6050_00
      scan_interval: 1
      device_class: door
      slave: 1
    - name: "Input 6050_01 -"
      address: 0001
      unique_id: 6050_01
      scan_interval: 1
      device_class: door
      slave: 1
    - name: "Input 6050_02 -"
      address: 0002
      unique_id: 6050_02
      scan_interval: 5
      device_class: problem
      slave: 1
    - name: "Input 6050_03 -"
      address: 0003
      unique_id: 6050_03
      scan_interval: 5
      device_class: problem
      slave: 1
    - name: "Input 6050_04 -"
      address: 0004
      unique_id: 6050_04
      scan_interval: 5
      device_class: problem
      slave: 1
  lights:
    - name: "Output 6050_16 - "
      address: 16
      unique_id: 6050_16
      write_type: coil
  switches:
    - name: "Output 6050_17 -"
      address: 17
      unique_id: 6050_17
      write_type: coil
      
- name: "Adam6052Front"
  type: tcp
  host: 192.168.2.159
  port: 502
  binary_sensors:
    - name: "Input 6052_00 - "
      address: 0000
      unique_id: 6052_00
      scan_interval: 1
      device_class: door
      slave: 1
    - name: "Input 6052_01 - "
      address: 0001
      unique_id: 6052_01
      scan_interval: 1
      device_class: garage_door
      slave: 1
  switches:  
    - name: "Output 6052_19 - "
      address: 19
      unique_id: 6052_19
      write_type: coil
#    - name: "Output 6052_20 - "
#      address: 20
#      unique_id: 6052_20
#      write_type: coil```

Hi to all.
I have one issue with my modbus setup, but i don’t exactly understood what
Here the error:

Logger: homeassistant.config
Source: config.py:1195
First occurred: 00:23:31 (1 occurrences)
Last logged: 00:23:31

Invalid config for 'modbus' at configuration.yaml, line 27: value must be one of [<DataType.CUSTOM: 'custom'>, <DataType.FLOAT16: 'float16'>, <DataType.FLOAT32: 'float32'>, <DataType.FLOAT64: 'float64'>, <DataType.INT16: 'int16'>, <DataType.INT32: 'int32'>, <DataType.INT64: 'int64'>, <DataType.STRING: 'string'>, <DataType.UINT16: 'uint16'>, <DataType.UINT32: 'uint32'>, <DataType.UINT64: 'uint64'>] for dictionary value 'modbus->0->sensors->0->data_type', got 'integer', please check the docs at https://www.home-assistant.io/integrations/modbus

and here is the configuration:

modbus:
  - name: MPX
    type: serial
    method: rtu
    port: /dev/ttyUSB0
    baudrate: 9600
    stopbits: 1
    bytesize: 8
    parity: N
    sensors:
      - name: "Sm"
        slave: 199
        data_type: integer
        address: 1
        input_type: holding
        unit_of_measurement: °C
        count: 1
        scale: 0.1
        offset: 0
        precision: 1

line 27 is: data_type: integer
I tryed also with int and int32 but doesen’t work.
Do you have any idea?

Hello,

i am dealing with advantech wise 4060 lan issues;
can any of you provide a working advantech config?

this code should switch a garage door, (switch on, and switch of in 1second)
covers:
- name: garage door
device_class: door
scan_interval: 5
input_type: coil
address: 18
state_open: 0
state_closed: 1
status_register: 3
status_register_type: holding
slave: 1

i think i can need each info

Hi there!

Would you mind sharing how you managed to see the Sensors: ?

I have serial rtu device, but for the life of me I can not get any data to show up as an entity.

Thanks!