Skip to content

Error with fresh install due to PAHO-Client incomtability #53

@cheak1974

Description

@cheak1974

Hi,

I just wanted to try out this library and before using it with docker I like to use it from the CLI in order to better understand what is happening. So I created a folder with a venv and installed modbus4mqtt into it with pip3 install modbus4mqtt. Then I tried to create a really simple config.yaml.

To test the program I just called the help text with modbus4mqtt --help which worked fine.
When I tried to run the program against the config I got:

modbus4mqtt --hostname 192.168.10.5 --config EBYTE_ME31_AAAX2240.yaml

RESULT:

2024-03-28 18:13:21 INFO     Starting modbus4mqtt v0.6.1
Exception ignored in: <function Client.__del__ at 0x0000029263C1C7C0>
Traceback (most recent call last):
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\paho\mqtt\client.py", line 874, in __del__
    self._reset_sockets()
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\paho\mqtt\client.py", line 1133, in _reset_sockets
    self._sock_close()
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\paho\mqtt\client.py", line 1119, in _sock_close
    if not self._sock:
           ^^^^^^^^^^
AttributeError: 'Client' object has no attribute '_sock'
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\_coding_\modbus4mqtt_testing\venv\Scripts\modbus4mqtt.exe\__main__.py", line 7, in <module>
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\modbus4mqtt\modbus4mqtt.py", line 292, in main
    i.connect()
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\modbus4mqtt\modbus4mqtt.py", line 42, in connect
    self.connect_mqtt()
  File "D:\_coding_\modbus4mqtt_testing\venv\Lib\site-packages\modbus4mqtt\modbus4mqtt.py", line 75, in connect_mqtt
    self._mqtt_client = mqtt.Client()
                        ^^^^^^^^^^^^^
TypeError: Client.__init__() missing 1 required positional argument: 'callback_api_version'

So I guessed there has to be something wrong with the underlying mqtt library. I removed PAHO 2.0.0 with pip uninstall paho-mqtt and installed and earlier version of PAHO with pip3 install paho-mqtt==1.6.1.

Afterwards modbus4mqtt is running right away, so you should consider either updating your program to the new API of PAHO-mqtt 2.0.0 or change your requirements.txt to use 1.6.1 version during installation.

P.S.: For me it is difficult to understand how the addresses for the modbus registers are configured in the right way. Is the first number of the address the modbus function? When is the holding and when is the input table used? I think this is the core of modbus configuration and the documentation should be a little more extensive.

HTH

regards from germany

Chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions