MQTTany - GPIO and more over MQTT

I recommend using MQTTfx to monitor MQTT traffic, it will help you understand topics in MQTTany at first and to make sure things are working.

Assuming you are using all default settings, the topic would be HOSTNAME/gpio/pintest. You will need to replace HOSTNAME with the actual hostname of the Raspberry Pi (raspberrypi on Raspbian, openhabian on openhabian).

Ok MQTTany is working. I use mosquitto_sub. But it appears that I have a different problem. I use a manual pushbutton with a pullup resistor. So Pin7 → Pullupresistor → VCC and Pin7 → Pushbutton → GND. In mqttany I have configured resistor: ‘pullup’.

Pressing the button occasionally (very very rarely, 1 out of 15 cases) provides me an “ON” message. Never I receive an OFF message. Mostly, I receive nothing at all. Why that? Is this a problem with the RaspberryPi4, broken?

raspi-gpio get 7
GPIO 7: level=1 fsel=0 func=INPUT pull=UP

How to proceed?

Thank you!!

Interesting, someone else reported similar behaviour but never got back to me with details. Let’s move this to Discussions on GitHub. Please make sure you are running the latest release of MQTTany, delete your log file, and start it with the -vv option. Press the button a few times then stop MQTTany (Ctrl+c) and attach your log file to the discussion.

OK, Problem solved. There was a parameter missing (respect the spaces!!!)

digital:
  interrupt: both

and the Pin number was wrong. The SoC numbering is default in MQTTany, so use the SoC numbers.

Hi, I followed the instructions to install the program but it fails to start as a service.
Can you pls guide me how to debug?

sudo systemctl status mqttany
● mqttany.service - MQTTany service
   Loaded: loaded (/etc/systemd/system/mqttany.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Sun 2021-08-01 02:03:12 CEST; 7s ago
  Process: 3308 ExecStart=/usr/bin/python3 mqttany.py (code=exited, status=1/FAILURE)
 Main PID: 3308 (code=exited, status=1/FAILURE)

running the python script I get:

openhabian@openHABianDevice:/opt/mqttany/mqttany $ python3 mqttany.py
2021-08-04 00:45:51,716 [INFO ] [core                    ] MQTTany 0.14.3 starting
2021-08-04 00:45:51,790 [INFO ] [core.gpio               ] Detected board: RASPBERRY_PI_4B
2021-08-04 00:45:51,928 [INFO ] [core                    ] Module 'mqtt' started successfully
2021-08-04 00:45:51,948 [ERROR] [mqtt                    ] Connection Refused: not authorised. (5)
2021-08-04 00:45:52,048 [INFO ] [core                    ] Module 'mqtt' unloaded
2021-08-04 00:45:52,936 [WARN ] [core                    ] MQTTany exiting with errors

The reason it won’t run as a service is the same as why it exits when you run it manually. Your MQTT server is refusing the connection.

Does your server require a username and password? Does your server require SSL authentication, if so that is not yet supported.

It requires username and password but not SSL. It is not clear for me if only SSL is not supported or also username and password are not supported?

SSL is not supported but user/pass is. The MQTT page in the docs shows you all available options, including username and password.

Ivan,

Got it all installed on my raspberry pi and when i try to run it i get this.
Something simple I am sure I did on the install?

Thanks

Looks like the hostname for you MQTT server is invalid. What is it set to in the config?

Hey Ivan

I’ll get back to you when I have my stuff setup again. Had to evacuate due to a wildfire yesterday. Hopefully be home soon!

Thanks

Hi,

I hadn’t got much time recently so I just tried installing the program again.
When I try to run it manually the program exits:

openhabian@openHABianDevice:/opt/mqttany/mqttany $ python3 mqttany.py -v /etc/mqttany/mqttany.yml
2021-09-26 02:18:14,231 [INFO ] [core    ] [core                    ] MQTTany 0.14.3 starting
2021-09-26 02:18:14,304 [INFO ] [core    ] [core.gpio               ] Detected board: RASPBERRY_PI_4B
2021-09-26 02:18:14,305 [DEBUG] [core    ] [core.gpio               ] Detected GPIO character device
2021-09-26 02:18:14,305 [DEBUG] [core    ] [core.gpio               ] Detected sysfs GPIO interface
2021-09-26 02:18:14,306 [DEBUG] [core    ] [config                  ] Loading config file
2021-09-26 02:18:14,311 [ERROR] [core    ] [config                  ] Config file contains errors
2021-09-26 02:18:14,311 [ERROR] [core    ] [config                  ]

Traceback (most recent call last):
yaml.scanner.ScannerError: while scanning a simple key
  in "/etc/mqttany/mqttany.yml", line 28, column 3
could not find expected ':'
  in "/etc/mqttany/mqttany.yml", line 29, column 3

2021-09-26 02:18:14,312 [ERROR] [core    ] [config                  ] Config file does not specify a version
2021-09-26 02:18:14,312 [ERROR] [core    ] [config                  ] This version of MQTTany requires a minimum config file version of '1.0'
2021-09-26 02:18:14,415 [DEBUG] [core    ] [core                    ] Received exit request from core
2021-09-26 02:18:14,416 [WARN ] [core    ] [core                    ] MQTTany exiting with errors

My config file in etc/mqttany/ is as follows (I didnt configure the sensor yet, trying to establish the connection first):

######## Configuration for MQTTany ########

# All optional values are commented out and default values are shown



### Config file version
version:  '1.0'


######## MQTT Module ########
mqtt:

  ### Broker Host
  # can be either IPv4 address or hostname
  host: '192.168.4.227'

  ### Broker Port
  # port to connect to on the host
  port: 1883

  ### Client ID
  # Substitutions:
  # - {hostname} = the computer's hostname
  client id: 'MQTTAny'

  ### Login
  username:'xxxxxx'
  password:'xxxx'

  ### Session Options
  #qos: 0
  #retain: false

  ### Topics
  # Substitutions:
  # - {hostname} = the computer's hostname
  # - {client_id} = the mqtt 'client id'
  # topics are composed as `{root topic}/{node id}/{property id}`
  #root topic: '{client_id}' # Root topic
  # last will topic becomes `{root topic}/{lwt topic}`
  #lwt topic: 'lwt' # Last Will topic

  ### Heartbeat
  # Interval in seconds to publish status messages
  #heartbeat interval: 300


######## GPIO Module ########
#gpio:

  ### Pin Numbering Mode
  #mode: 'SOC'

  ### Polling Interval
  #polling interval: 60 # interval in seconds to poll all pins

  ### Interrupt Debounce
  #debounce: 50 # in milliseconds

  ### Single Pin Configuration
  #pin-id:

    ### Pin Number
    #pin:

    ### Pin Name
    # Subsitutions:
    # - {pin} = pin number
    # - {pin:02d} = pin number padded with 0's to always be 2 numbers
    # - {pin_id} = name of this section
    #name: '{pin_id}'

    ### Pin Mode
    #pin mode: 'input' # can be 'input' or 'output'

    ### Pin Resistor
    #resistor: 'off' # can be 'pullup', 'pulldown', or 'off'

    ### Pin Type Specifc Options
    # Each pin type will have some options specific to it,
    # consult the documentation for details.

  ### Multiple Pin Configuration
  # alternatively a list of pins can be given.
  # actual id's will be '{batch-id}-{index + first index}'
  # all options from a single pin configuration apply, except those shown below
  #batch-id:

    ### Pin Name
    # a single name may be given, or a list of names the same length as the
    # list of pins can be provided. if a single name is given then actual names will
    # be '{name} {index + first index}'
    # Subsitutions:
    # - {pin} = pin number
    # - {pin:02d} = pin number padded with 0's to always be 2 numbers
    # - {pin_id} = name of this section
    # - {index} = the pin's index in the list of pins plus 'first index'
    #name: '{pin_id}'

    ### Pin Numbers
    #pin: []

    ### First Index
    # this number will be added to 'index' when substituting '{index}' in id's and names
    #first index: 0



######## I2C Module ########
#i2c:

  ### Polling Interval
  #polling interval: 60 # interval in seconds to poll all pins

  ### Device Configuration
  # !! this id is used as the node so it must not match any other node or module name !!
  #device-id:

    ### Device Friendly Name
    # Friendly name used in logging etc
    # Substitutions:
    # - {device_id} = name of device's section in config file
    # - {address:02x} = device address in hex (ex. '20')
    # - {device} = device identifier
    #name: '{device_id}'

    ### Device Type
    # Device identifier, see the wiki for a list of supported devices
    #device: ''

    ### I2C Bus ID
    # ID of the I2C bus to use on your SBC
    # ex. Raspberry Pi 3 this will probably be 1
    # Can also specify full path ex. '/dev/i2c-1'
    #bus:

    ### Device Address
    # 7-bit hex address of the device (ex. 0x20)
    # this can also be a base-10 integer
    #address: 0x

    ### Device Specific Options
    # Each device type will have some options specific to it
    # consult the wiki page for the device for details.



######## OneWire Module ########
#onewire:

  ### Bus Interface
  #bus: 'w1'

  ### Polling Interval
  #polling interval: 60 # interval in seconds to poll all devices

  ### Bus Scan
  # Scan bus for any unconfigured devices and add them
  #bus scan: false

  ### Device Configuration
  #device-id:

    ### Device Name
    # Substitutions:
    # - {device_id} = will be replaced with the device definition section name
    # - {device_type} = will be replaced with the device type (ex. `DS18B20`)
    # - {address} = will be replaced with the device's **FULL 8 BYTE ADDRESS**
    #name: '{device_id}'

    ### Device Address
    # The device's address, can be 7 or 8 bytes, can use w1 style `xx-xxxxxxxxxxxx`
    #address: '' # **MUST BE IN SINGLE QUOTES `''`**

    ### Device Specific Options
    # Each device type will have some options specific to it
    # consult the wiki page for the device for details.

  ### Multiple Device Configuration
  #batch-id:

    ### Device Name
    # a single name may be given, or a list of names the same length as the
    # list of pins can be provided. if a single name is given then actual names will
    # be '{name} {index + first index}'
    # Substitutions:
    # - {device_id} = will be replaced with the device definition section name
    # - {device_type} = will be replaced with the device type (ex. `DS18B20`)
    # - {address} = will be replaced with the device's **FULL 8 BYTE ADDRESS**
    # - {index} = will be replaced with the device's index in the list of addresses
    #name: '{device_id}'

    ### Device Address
    # List of device addresses, can be 7 or 8 bytes, can use w1 style `xx-xxxxxxxxxxxx`
    #address: ['', ''] # **MUST BE IN SINGLE QUOTES `''`**

    ### First Index
    # this number will be added to 'index' when substituting '{index}' in id's and names
    #first index: 0



######## LED Module ########
#led:

  ### Animation Directory
  # A directory or list of directories to look for additional animations in
  #anim dir: []

  ### Startup Animation
  # Animation to play when MQTTany loads
  #anim startup: 'test.array'

  ### Array Configuration
  #array-id:

    ### Array Name
    # Substitutions:
    # - {array_id} = will be replaced with the array definition section name
    #name: '{array_id}'

    ### Output
    # The interface to use for outputting data
    # Available options are 'rpi' or 'sacn'
    #output: ''

    ### Pixel Count
    # The number of pixels in your array (not necessarily LEDs, see next option)
    #count:

    ### LEDs per Pixel
    # Allows you to have more than one LED handled as a single pixel.
    # Ex. A bulb with 3 LEDs in it can be treated as a single pixel in the array.
    # Total number of LEDs in the array should be 'count' times 'leds per pixel'
    #leds per pixel: 1

    ### Initial Brightness
    # The initial brightness of the array, can be 0-255
    #brightness: 255

    ### Color Order
    # The byte order for the color data sent to the LEDs.
    # See the 'test.order' animation for how to determine this
    #color order: '{default}'

    ### Animation Frame Rate
    # Frame rate for animations, you may need to decrease this for
    # longer arrays or certain interface types.
    #anim fps: 60

    ### Interface Specific Options
    # Each interface may have some options specific to it
    # consult the wiki page for the interface for details.



######## XSET Module ########
#xset:

  ### Default Display
  # Display option to use when commands do not specify a display.
  # Omitting this option will omit the '-display' option from the call to xset
  #default display: None

  ### Startup Commands
  # A list of commands to run when the module loads.
  # See the documentation on sending commands for formatting.
  # If none are desired, use an empty list as shown below.
  #startup commands: []

Any ideas?

@DarkoG I do not have any ideas… Config file looks ok but the yaml reader says it’s no good.

Maybe try renaming your current config and copying the current default config file to etc/mqttany in case there are errors in your current one. Add only your broker information to the mqtt section and test to see if it will run.

Hi, I finally got time to work on this again and I found out there was no space between the : and the username and password, so I can now run the script.

However I am failing to configure counters. The config file is as follows:

gpio:
  WaterMeter19:
    pin: 19
    counter:

  IrrigationWaterMeter26:
    pin: 26
    counter:

I can see new MQTT connection, but the log on the Raspberry says my counters are wrong configuration:

openhabian@openHABianDevice:/opt/mqttany $ python3 mqttany/mqttany.py
2022-05-08 01:50:55,403 [INFO ] [core                    ] MQTTany 0.14.3 starting
2022-05-08 01:50:55,479 [INFO ] [core.gpio               ] Detected board: RASPBERRY_PI_4B
2022-05-08 01:50:55,609 [WARN ] [gpio                    ] 'WaterMeter19' is not a valid ID and will be ignored
2022-05-08 01:50:55,609 [WARN ] [gpio                    ] 'IrrigationWaterMeter26' is not a valid ID and will be ignored
2022-05-08 01:50:55,619 [INFO ] [core                    ] Module 'mqtt' started successfully
2022-05-08 01:50:55,626 [INFO ] [core                    ] Module 'gpio' started successfully
2022-05-08 01:50:55,644 [INFO ] [mqtt                    ] Connected to broker '192.168.4.227:1883'

OK , got it. I just saw the ID cant have capital letters

Hello,

I’m really interested into this alternative, as pigpiod is no longer available on current Raspberry Pi OS.

I’m running openhab 5 on a raspberry pi, Python 3.13.5 already installed.

I’m not so familiar with linux, but I tried to follow the instructions as best as possible. I faced the following issues:

  1. openhabian@openhabian:/opt/mqttany $ pip3 install -r requirements/mqttany.txt
    error: externally-managed-environment

    × This environment is externally managed
    ╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    For more information visit http://rptl.io/venv
    

    note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
    hint: See PEP 668 for the detailed specification.

  2. After having started mqqtany:
  3. ● mqttany.service - MQTTany service
    Loaded: loaded (/etc/systemd/system/mqttany.service; enabled; preset: enabled)
    Active: activating (auto-restart) (Result: exit-code) since Sun 2026-04-12 14:05:14 BST; 9s ago
    Invocation: e845449e835d416cb02b3bd7fdff1a70
    Process: 9675 ExecStart=/usr/bin/python3 mqttany.py (code=exited, status=1/FAILURE)
    Main PID: 9675 (code=exited, status=1/FAILURE)
    CPU: 435ms

  4. and finally:
  5. openhabian@openhabian:/opt/mqttany/mqttany/config $ sudo cp udev/98-gpio.rules /etc/udev/rules.d/
    cp: cannot stat ‘udev/98-gpio.rules’: No such file or directory

I’ll be really thanksfull to be helped.

Two issue reports on github mention possible solutions to that problem, but it is not trivial to do that for unexperienced linux users, so take a backup of your sd card before if you want to try it:

Hi,

Thanks for you help.

So I started with Python virtual environment’ installation as proposed. Sadly I ended with

openhabian@openhabian:~ $ sudo python3 -m venv /opt/mqttany/mqttany/venv
[sudo] password for openhabian:
openhabian@openhabian:~ $ sudo /opt/mqttany/mqttany/venv/bin/pip3 install -r /opt/mqttany/requirements/mqttany.txt
Looking in indexes: Simple index , piwheels - Simple index
Collecting typing (from -r /opt/mqttany/requirements/mqttany.txt (line 1))
Downloading https://www.piwheels.org/simple/typing/typing-3.7.4.3-py3-none-any.whl (28 kB)
Collecting pyyaml<6.0,>=5.1.2 (from -r /opt/mqttany/requirements/mqttany.txt (line 2))
Downloading PyYAML-5.4.1.tar.gz (175 kB)
Installing build dependencies … done
Getting requirements to build wheel … error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [78 lines of output]
/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/wheel/bdist_wheel.py:4: FutureWarning: The ‘wheel’ package is no longer the canonical location of the ‘bdist_wheel’ command, and will be removed in a future release. Please update to setuptools v70.1 or later which contains an integrated version of this command.
warn(
/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/dist.py:765: SetuptoolsDeprecationWarning: License classifiers are deprecated.
!!

          ********************************************************************************
          Please consider removing the following classifiers in favor of a SPDX license expression:
  
          License :: OSI Approved :: MIT License
  
          See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
          ********************************************************************************
  
  !!
    self._finalize_license_expression()
  running egg_info
  writing lib3/PyYAML.egg-info/PKG-INFO
  writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt
  writing top-level names to lib3/PyYAML.egg-info/top_level.txt
  Traceback (most recent call last):
    File "/opt/mqttany/mqttany/venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
      main()
      ~~~~^^
    File "/opt/mqttany/mqttany/venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
      json_out["return_val"] = hook(**hook_input["kwargs"])
                               ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/mqttany/mqttany/venv/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=[])
             ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
      self.run_setup()
      ~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 317, in run_setup
      exec(code, locals())
      ~~~~^^^^^^^^^^^^^^^^
    File "<string>", line 271, in <module>
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/__init__.py", line 117, in setup
      return distutils.core.setup(**attrs)  # type: ignore[return-value]
             ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/_distutils/core.py", line 186, in setup
      return run_commands(dist)
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
      dist.run_commands()
      ~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py", line 1000, in run_commands
      self.run_command(cmd)
      ~~~~~~~~~~~~~~~~^^^^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/dist.py", line 1107, in run_command
      super().run_command(command)
      ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/_distutils/dist.py", line 1019, in run_command
      cmd_obj.run()
      ~~~~~~~~~~~^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/command/egg_info.py", line 312, in run
      self.find_sources()
      ~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/command/egg_info.py", line 320, in find_sources
      mm.run()
      ~~~~~~^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/command/egg_info.py", line 542, in run
      self.add_defaults()
      ~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/command/egg_info.py", line 580, in add_defaults
      sdist.add_defaults(self)
      ~~~~~~~~~~~~~~~~~~^^^^^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/command/sdist.py", line 110, in add_defaults
      super().add_defaults()
      ~~~~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/_distutils/command/sdist.py", line 245, in add_defaults
      self._add_defaults_ext()
      ~~~~~~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-uoe2g51v/overlay/lib/python3.13/site-packages/setuptools/_distutils/command/sdist.py", line 330, in _add_defaults_ext
      self.filelist.extend(build_ext.get_source_files())
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
    File "<string>", line 201, in get_source_files
  AttributeError: 'build_ext' object has no attribute 'cython_sources'
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

It is correct to simply apply these lines as proposed on an openhabian environment ?

sudo python3 -m venv /opt/mqttany/mqttany/venv
sudo /opt/mqttany/mqttany/venv/bin/pip3 install -r /opt/mqttany/requirements/mqttany.txt
sudo /opt/mqttany/mqttany/venv/bin/pip3 install -r /opt/mqttany/requirements/mqtt.txt

Hi @sihui - I’m the one who raised those issues, and unfortunately the 3 pull requests I have up there for these are not yet merged, however 2 of them are documentation only, and one can be overcome by a quick edit of one file.

@joflo - If this helps, see the following documentation that I used for building it on my PI 3B.
Apologies for the formatting, its a cut ‘n’ paste from my House Wiki - Hopefully nothing was lost in the process…. Only caveat, is the last time I performed this process, was early 2025, and on Ubuntu ~ 24.04

Hope this helps.

Install Pre-Requisite Packages

sudo apt-get update
sudo apt-get install python3 python3-pip
python3 --version

Clone mqttany

cd /opt
sudo git clone -b v0.14.4 https://github.com/CrazyIvan359/mqttany.git
sudo mkdir /etc/mqttany
sudo cp /opt/mqttany/mqttany/config/mqttany.yml /etc/mqttany/mqttany.yml

Setup Python Virtual Environment

sudo python3 -m venv /opt/mqttany/mqttany/venv

Edit mqtt pip requirements

sudo nano -B /opt/mqttany/requirements/mqttany.txt

Change: pyyaml>=5.1.2,<=6.0 to: pyyaml>=5.1.2,<=6.0.2

Install PIP Modules

sudo /opt/mqttany/mqttany/venv/bin/pip3 install -r /opt/mqttany/requirements/i2c.txt

sudo /opt/mqttany/mqttany/venv/bin/pip3 install -r /opt/mqttany/requirements/led-rpi.txt

sudo /opt/mqttany/mqttany/venv/bin/pip3 install -r /opt/mqttany/requirements/mqtt.txt

sudo /opt/mqttany/mqttany/venv/bin/pip3 install -r /opt/mqttany/requirements/mqttany.txt

sudo /opt/mqttany/mqttany/venv/bin/pip3 install importlib

Edit mprop file to fix deprecated package

sudo nano -B /opt/mqttany/mqttany/venv/lib/python3.12/site-packages/mprop.py

change line 2:

from: import imp to: import importlib

Hi glen_m,

A big thank for your help.

I could follow your proposed process successfully, with the following differences:

sudo nano -B /opt/mqttany/mqttany/venv/lib/python3.13/site-packages/mprop.py

and adding the following line (instead of replacing):

import importlib

The result is:

openhabian@openhabian:~ $ sudo systemctl status mqttany
[sudo] password for openhabian:
● mqttany.service - MQTTany service
Loaded: loaded (/etc/systemd/system/mqttany.service; enabled; preset: enabled)
Active: active (running) since Tue 2026-04-14 20:31:55 BST; 1s ago
Invocation: 21f666db29ca4ee59c4e292ba8cd866b
Main PID: 1408 (python3.13)
Tasks: 1 (limit: 1054)
CPU: 669ms
CGroup: /system.slice/mqttany.service
└─1408 /opt/mqttany/mqttany/venv/bin/python3.13 mqttany.py

Apr 14 20:31:32 openhabian systemd[1]: mqttany.service: Consumed 1.284s CPU time.
Apr 14 20:31:55 openhabian systemd[1]: mqttany.service: Scheduled restart job, restart counter is at 2.
Apr 14 20:31:55 openhabian systemd[1]: Started mqttany.service - MQTTany service.