openlumi / homeassistant_on_openwrt

Install Home Assistant on your OpenWrt device with a single command
MIT License
157 stars 43 forks source link

MQTT broken on 2022.12.8 #25

Closed k3lwin closed 1 year ago

k3lwin commented 1 year ago

Changes in MQTT in HA 2022.12 broke the installation script:

  1. MQTT integration now requires text component, which apparently gets removed by the script.
  2. After adding missing text component, I get this error:
    2022-12-24 09:40:27.203 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 127.0.0.1 for mqtt
    File "/usr/lib/python3.10/site-packages/homeassistant/components/mqtt/__init__.py", line 543, in async_setup_entry
    File "/usr/lib/python3.10/site-packages/homeassistant/components/mqtt/__init__.py", line 510, in async_forward_entry_setup_and_setup_discovery
    File "/usr/lib/python3.10/site-packages/homeassistant/components/mqtt/device_automation.py", line 13, in <module>
    File "/usr/lib/python3.10/site-packages/homeassistant/components/mqtt/device_trigger.py", line 28, in <module>
    from . import debug_info, trigger as mqtt_trigger
    File "/usr/lib/python3.10/site-packages/homeassistant/components/mqtt/trigger.py", line 33, in <module>
    vol.Required(CONF_TOPIC): mqtt.util.valid_subscribe_topic_template,
    AttributeError: module 'homeassistant.components.mqtt' has no attribute 'util'

util.py is present in ./components/mqtt directory. Some bug reports with similar issues have been resolved by installing missing pip packages, but it is unclear which package is missing. paho-mqtt was not installed despite being mentioned in MQTT integration manifest, but installing it manually did not solve the issue.

I'm trying to install HA on Xiaomi DGNWG05LM with OpenWRT 22.03.2 r19803-9a599fee93

Unfortunately, I'm not experienced enough to debug this issue further.

devbis commented 1 year ago

Hi! thanks for the report. I updated the script with some patches that can fix the problem. Can you please try it out?

littleboot commented 1 year ago

Hi! thanks for the report. I updated the script with some patches that can fix the problem. Can you please try it out? I have tried it:

Result: Almost working. To make it work I had to install the missing "paho-mqtt" module as @k3lwin noted. SSH into the router and install the missing module: pip install paho-mqtt (V1.6.1 was installed)

NOTE: When i add the MQTT integration it takes ~ 2min before the configuration page is available (not sure if this is normal, but I'm not complaining MQTT is working :D )

Thank you for the update!

devbis commented 1 year ago

Isn't paho-mqtt installed automatically with HA ? You can check it in /etc/homeassistant/deps/ Usually, it takes some time to install all the required packages before using it. Sometimes it is required to restart HA.

littleboot commented 1 year ago

@devbis this folder does not contain any pip modules, only aiogithubapi. This module I installed manually (it was a requirement to get the homeassistant comunity store HACS integration working)

This is my folder tree on the openwrt target:

/etc/homeassistant/deps/
└── lib
    └── python3.10
        └── site-packages
            ├── aiogithubapi
            └── aiogithubapi-22.12.2.dist-info

I reran the first part the script were the requirements are collected inside the /tmp/ha_requirements.txt file. here the paho-mqtt==1.6.1 requirement is listed.

in the /tmp/requirements.txt file which is statically defined inside the script this requirement is not listed.

littleboot commented 1 year ago

I just performed a clean install an ran the script again. (there is an issue with the installation of frozenlist but after fixing this the script is able to finish. However some dependencies are missing after the install, I get an error in the HA log about pycountry missing after the install and when I try to add the MQTT integration a new error is generated and points to paho-mqtt==1.6.1 missing. I found a clue inside the /tmp dir pip-log.txt but I'm not sure why it is failing to install because when I do this manually it installs just fine.

To fix these errors i installed these packages manually and rebooted.

pip install paho-mqtt==1.6.1
pip install pycountry

pip-log.txt

home-assistant_2022-12-29T23-02-24.129Z.log

devbis commented 1 year ago

I added "integration" component to the script as it is mentioned in logs. The probem of installing paho-mqtt seems to be related to the network problems. I don't want to incorporate libraries that could not be used by end-users. E.g. installations without using MQTT at all. As for pycountry, I didn't find any mentions of the package in the code.

littleboot commented 1 year ago

Thank you, I just checked the pycountry module is a dependency of the radios module (radio_browser integration), not sure why it failed to install. Probably not needed to update the script for this.