hassio-addons / addon-mqtt-io

MQTT IO - Home Assistant Community Add-ons
MIT License
34 stars 21 forks source link

Addon crashes on initial startup #15

Closed ghost closed 2 years ago

ghost commented 2 years ago

Problem/Motivation

I was trying to setup this addon and I had made a config.yml file and everything, but when I started the addon after a while it crashed and if I tried to start the addon once more, it would crash on the same spot again.

Expected behavior

The addon would start as expected

Actual behavior

The addon crashes with the following error code:

× Running setup.py install for Adafruit_DHT did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      running install
      /usr/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-armv7l-3.10
      creating build/lib.linux-armv7l-3.10/Adafruit_DHT
      copying Adafruit_DHT/common.py -> build/lib.linux-armv7l-3.10/Adafruit_DHT
      copying Adafruit_DHT/platform_detect.py -> build/lib.linux-armv7l-3.10/Adafruit_DHT
      copying Adafruit_DHT/Beaglebone_Black.py -> build/lib.linux-armv7l-3.10/Adafruit_DHT
      copying Adafruit_DHT/__init__.py -> build/lib.linux-armv7l-3.10/Adafruit_DHT
      copying Adafruit_DHT/Test.py -> build/lib.linux-armv7l-3.10/Adafruit_DHT
      copying Adafruit_DHT/Raspberry_Pi_2.py -> build/lib.linux-armv7l-3.10/Adafruit_DHT
      copying Adafruit_DHT/Raspberry_Pi.py -> build/lib.linux-armv7l-3.10/Adafruit_DHT
      warning: build_py: byte-compiling is disabled, skipping.

      running build_ext
      building 'Adafruit_DHT.Raspberry_Pi_2_Driver' extension
      creating build/temp.linux-armv7l-3.10
      creating build/temp.linux-armv7l-3.10/source
      creating build/temp.linux-armv7l-3.10/source/Raspberry_Pi_2
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fomit-frame-pointer -g -fomit-frame-pointer -g -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/python3.10 -c source/Raspberry_Pi_2/pi_2_dht_read.c -o build/temp.linux-armv7l-3.10/source/Raspberry_Pi_2/pi_2_dht_read.o -std=gnu99
      error: command 'gcc' failed: No such file or directory
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> Adafruit_DHT
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
2022-07-25 12:21:53 mqtt_io.__main__ [ERROR] MqttIo crashed!
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/__init__.py", line 51, in install_missing_module_requirements
    install_missing_requirements(pkgs_required)
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/__init__.py", line 22, in install_missing_requirements
    check_call([sys.executable, "-m", "pip", "install"] + pkgs_required)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', 'install', 'Adafruit_DHT']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 1230, in run
    self._init_sensor_modules()
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 255, in _init_sensor_modules
    self.sensor_modules[sens_config["name"]] = _init_module(
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 124, in _init_module
    install_missing_module_requirements(module)
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/__init__.py", line 53, in install_missing_module_requirements
    raise CannotInstallModuleRequirements(
mqtt_io.exceptions.CannotInstallModuleRequirements: Unable to install packages for module <module 'mqtt_io.modules.sensor.dht22' from '/usr/lib/python3.10/site-packages/mqtt_io/modules/sensor/dht22.py'> (['Adafruit_DHT']): Command '['/usr/bin/python3', '-m', 'pip', 'install', 'Adafruit_DHT']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/__init__.py", line 51, in install_missing_module_requirements
    install_missing_requirements(pkgs_required)
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/__init__.py", line 22, in install_missing_requirements
    check_call([sys.executable, "-m", "pip", "install"] + pkgs_required)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', 'install', 'Adafruit_DHT']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.10/site-packages/mqtt_io/__main__.py", line 115, in <module>
    main()
  File "/usr/lib/python3.10/site-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 1230, in run
    self._init_sensor_modules()
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 255, in _init_sensor_modules
    self.sensor_modules[sens_config["name"]] = _init_module(
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 124, in _init_module
    install_missing_module_requirements(module)
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/__init__.py", line 53, in install_missing_module_requirements
    raise CannotInstallModuleRequirements(
mqtt_io.exceptions.CannotInstallModuleRequirements: Unable to install packages for module <module 'mqtt_io.modules.sensor.dht22' from '/usr/lib/python3.10/site-packages/mqtt_io/modules/sensor/dht22.py'> (['Adafruit_DHT']): Command '['/usr/bin/python3', '-m', 'pip', 'install', 'Adafruit_DHT']' returned non-zero exit status 1.
[12:21:54] WARNING: MQTT IO crashed, halting add-on
s6-rc: info: service legacy-services: stopping
[12:21:54] INFO: MQTT IO stopped

Steps to reproduce

Start the addon with a fresh install.

thecode commented 2 years ago

Can you share your config.yml?

ghost commented 2 years ago

Of course! This is the config.yml file I have, but I have changed the password and username for obvious reasons:

mqtt:
  host: 192.168.1.2
  port: 2883
  user: "mqtt-username"
  password: "mqtt-password"
  topic_prefix: home/livingroom/climate

sensor_modules:
  - name: dht22_sensor
    module: dht22
    type: AM2302
    pin: 35

sensor_inputs:
  - name: temperatur
    module: dht22_sensor
    interval: 300
    digits: 4
    type: temperature

  - name: luftfuktighet
    module: dht22_sensor
    interval: 300
    digits: 4
    type: humidity
frenck commented 2 years ago

Likely related to: https://github.com/flyte/mqtt-io/issues/244

The Python library used by mqtt.io is archived and no longer maintained: https://github.com/adafruit/Adafruit_Python_DHT/

frenck commented 2 years ago

I've opened up PR #16, which should address this issue. Will ship out a release with that fix asap.

frenck commented 2 years ago

@RavenHamster We've shipped v0.1.1 of the add-on. Could you check if that resolves your issue?

ghost commented 2 years ago

@RavenHamster We've shipped v0.1.1 of the add-on. Could you check if that resolves your issue?

The issue is resolved, however I can not pull the sensor data still but because I think the issue is not related to this I decided to open a new issue #17 instead. Thank you so much for the help you provide <3