home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.45k stars 30.69k forks source link

MQTT items not working anymore after updating 0.75.3 to 0.76.2 #16123

Closed fluppie closed 5 years ago

fluppie commented 6 years ago

Home Assistant release with the issue:

0.76.2

Last working Home Assistant release (if known): 0.75.3

Operating environment (Hass.io/Docker/Windows/etc.):

Hassbian release Component/platform:

MQTT

Description of problem:

Just did the update from 0.75.3 to 0.76.2 and all my MQTT items are gone from the homescreen. In the log file there are no errors regarding the MQTT plugin. Could this be a visual issue? Items still in HA but unable to activate them through the GUI?

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):


mqtt:
    broker: '192.168.1.29'
    port: 1883
    client_id: home-assistant
    username: emonpi
    password: ***************
    discovery: true
    discovery_prefix: homeassistant

Traceback (if applicable):

Additional information:

tali1974 commented 6 years ago

Before release 0.76, the embedded broker would use your API password as a password to the MQTT user. This is no longer the case.

fluppie commented 6 years ago

I’ve read that, but I use my own mqtt broker on another Raspberry Pi with the OpenEnergyMonitor emonSD image. This device is running for over 3yrs. So I didn’t change anything to my mqtt setup.

Op 22 aug. 2018 om 22:33 heeft tali1974 notifications@github.com het volgende geschreven:

Before release 0.76, the embedded broker would use your API password as a password to the MQTT user. This is no longer the case.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

scottsuine commented 6 years ago

Having the same issue with an external MQTT Broker

jeroenrnl commented 6 years ago

I have problems with MQTT too, internal in my case, and I do have some errors in the log:

2018-08-26 21:29:35 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
  File "/home/jeroen/.local/lib/python3.7/site-packages/homeassistant/setup.py", line 145, in _async_setup_component
    hass, processed_config)
  File "/home/jeroen/.local/lib/python3.7/site-packages/homeassistant/components/mqtt/__init__.py", line 364, in async_setup
    broker_config = await _async_setup_server(hass, config)
  File "/home/jeroen/.local/lib/python3.7/site-packages/homeassistant/components/mqtt/__init__.py", line 311, in _async_setup_server
    hass, conf.get(CONF_PASSWORD), conf.get(CONF_EMBEDDED))
  File "/home/jeroen/.local/lib/python3.7/site-packages/homeassistant/components/mqtt/server.py", line 39, in async_start
    from hbmqtt.broker import Broker, BrokerException
  File "/home/jeroen/.homeassistant/deps/lib/python3.7/site-packages/hbmqtt/broker.py", line 29
    from asyncio import async as ensure_future
                            ^
SyntaxError: invalid syntax
2018-08-26 21:29:38 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2018-08-26 21:29:38 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.
2018-08-26 21:29:38 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2018-08-26 21:29:38 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.
2018-08-26 21:29:38 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2018-08-26 21:29:38 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.
2018-08-26 21:29:38 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2018-08-26 21:29:38 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.
gerth2 commented 6 years ago

Seconded, same symptoms and error as @jeroenrnl

jeroenrnl commented 6 years ago

After some more research & troubleshooting, I found that my problem was caused by (the lack of) Python 3.7 support, updating hbmqtt fixed that

gerth2 commented 6 years ago

@jeroenrnl Thanks. I went ahead and updated to 0.9.4, but am still getting the same error. Seems strange since the PR you linked seems to indicate that the asyncio error should be gone. For reference:

# python   
Python 3.7.0 (default, Jul 15 2018, 10:44:58) 
[GCC 8.1.1 20180531] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hbmqtt
>>> import pkg_resources
>>> pkg_resources.get_distribution("hbmqtt").version
'0.9.4'
>>> 
2018-08-26 16:19:05 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/homeassistant/setup.py", line 145, in _async_setup_component
    hass, processed_config)
  File "/usr/lib/python3.7/site-packages/homeassistant/components/mqtt/__init__.py", line 364, in async_setup
    broker_config = await _async_setup_server(hass, config)
  File "/usr/lib/python3.7/site-packages/homeassistant/components/mqtt/__init__.py", line 311, in _async_setup_server
    hass, conf.get(CONF_PASSWORD), conf.get(CONF_EMBEDDED))
  File "/usr/lib/python3.7/site-packages/homeassistant/components/mqtt/server.py", line 39, in async_start
    from hbmqtt.broker import Broker, BrokerException
  File "/root/.homeassistant/deps/lib/python3.7/site-packages/hbmqtt/broker.py", line 29
    from asyncio import async as ensure_future
                            ^
SyntaxError: invalid syntax
2018-08-26 16:19:05 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Invalid config, message=The following components and platforms could not be set up:

 - [mqtt](https://home-assistant.io/components/mqtt/)
gerth2 commented 6 years ago

Edit: My code works, I have no idea why. Running the following sequence seemed to fix it:

pip uninstall hbmqtt
pip3 install --upgrade homeassistant
awarecan commented 6 years ago

@gerth2

/root/.homeassistant/deps/lib

Means you have a old version hbmqtt lib in deps folder, and it will override the future upgraded lib. So clean that folder will resolve your issue.

I saw you installed home assistant as root user, the deps folder was used to resolve the conflict between home assistant and your system's Python environment. That is why we suggest use virtual environment to install.

gerth2 commented 6 years ago

Gotcha, thanks! Will do a bit of digging, curious if I have other old packages. I'd seen the virtual environment install and I will add it to my to-do list to update.

fluppie commented 6 years ago

So the fix you propose is for the local broker only? Or could this work for external brokers as well? Weird thing is that I don't have any MQTT related errors in the logfile.

gerth2 commented 6 years ago

@fluppie Hmmm, if there is no error in the log, I suspect the problem isn't exactly the same one mentioned previously here. The particular version incompatibility was exposed directly by the presence of the "async" symbol being transformed into a keyword and being no longer available for general usage. If this is the root of your issue, should cause a very similar looking stack trace in some log.

fluppie commented 6 years ago

Ok, funny, apparantly the broker connection works, but it doesn't show the switch and light MQTT items.

2018-08-27 16:42:10 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to homeassistant/# 
2018-08-27 16:42:10 WARNING (MainThread) [homeassistant.components.http] You have been advised to set http.api_password. 
2018-08-27 16:42:14 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tele/sonofflivingbme680/SENSOR 
2018-08-27 16:42:14 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tele/sonofflivingbme680/SENSOR 
2018-08-27 16:42:14 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tele/sonofflivingbme680/SENSOR 
2018-08-27 16:42:14 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tele/sonoffstaliving/SENSOR 
2018-08-27 16:42:14 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tele/sonoffstaliving/SENSOR 
2018-08-27 16:42:14 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tele/sonofflivingbme680/SENSOR 
2018-08-27 16:42:14 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tele/sonofflivingbme680/SENSOR 
2018-08-27 16:42:14 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tele/sonofflivingbme680/SENSOR 
2018-08-27 16:42:55 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/sonoffstaliving/SENSOR: b'{"Time":"2018-08-27T15:42:54","HTU21":{"Temperature":28.9,"Humidity":33.5},"TempUnit":"C"}' 
2018-08-27 16:43:58 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/sonoffstaliving/SENSOR: b'{"Time":"2018-08-27T15:43:57","HTU21":{"Temperature":28.9,"Humidity":33.4},"TempUnit":"C"}' 
2018-08-27 16:45:01 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/sonoffstaliving/SENSOR: b'{"Time":"2018-08-27T15:45:00","HTU21":{"Temperature":28.9,"Humidity":33.5},"TempUnit":"C"}' 
2018-08-27 16:46:08 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/sonoffstaliving/SENSOR: b'{"Time":"2018-08-27T15:46:07","HTU21":{"Temperature":29.2,"Humidity":33.7},"TempUnit":"C"}' 
2018-08-27 16:47:11 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/sonoffstaliving/SENSOR: b'{"Time":"2018-08-27T15:47:10","HTU21":{"Temperature":29.5,"Humidity":33.3},"TempUnit":"C"}'
sir106 commented 6 years ago

same problem here: using hass docker Image 0.77.0b2 with an external mqtt broker. just after updating the docker container the mqtt devices no longer show up. no error messages in the logfile - no changes in setup..

awarecan commented 6 years ago

I am going to clean up this thread a little bit, there are several different issues mixed in one thread, it make us very hard to track.

So I will mark all comments about embedded MQTT server as off topic, since the original issue presented by @fluppie is not related with it. If you still have problem with embedded MQTT server, please open a new issue.

@sir106 better reports beta issue in Discord #beta channel

kgorszczyk commented 6 years ago

I'm having the same problem after updating to 0.77. It appears that HomeAssistant is receiving the messages but ignoring them: [homeassistant.components.mqtt] Received message on office/light/stat/LightSwitch/POWER: b'ON' After updating to 0.77 all of my mqtt.light and mqtt.switch devices are stuck on 'Unavailable'

RyanEwen commented 5 years ago

I think I'm seeing the same issue. None of my MQTT switches are showing up in home assistant anymore since updating.

emontnemery commented 5 years ago

@RyanEwen Are you using MQTT discovery or have you manually added the switches?

RyanEwen commented 5 years ago

I'm using discovery but managed to get everything back by restarting all of my switches.

I have an automation that gets the state of each switch on startup and thought that would do it but later realized how discovery worked.

All good now

balloobbot commented 5 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

oaeide commented 5 years ago

Is this still an issue you are experiencing? Can you please try upgrading to the latest version of Home Assistant (0.90) and report back if this is still a problem? Thanks!

RyanEwen commented 5 years ago

The issue initially went away by setting up an automation to restart my switches on startup.

Then after updating Tasmota on my switches I was able to use the automation that's listed on the Tasmota wiki to fetch state on startup.

Everything is good now