Problem with mqtt loading sensors, switches (since 0.108.9)

Hello,

Since the last update to 0.108.9 all my sensors, switches, lights are unavailable.
I don’t know if it is specific to this version but I encountered it when updating from 0.108.8 to 0.108.9. Does anyone has the same problem? Should I try to reinstall HA with previous version?
EDIT: It isn’t a problem with 0.108.9. When I go back to an older version the problem still remains.
MQTT is up and running (tested with MQTTfx).
This are my HA logs:

2020-04-27 06:56:43 WARNING (SyncWorker_8) [homeassistant.components.influxdb] Database host is not accessible due to 'HTTPConnectionPool(host='poseidon', port=8086): Max retries exceeded with url: /write?db=home_assistant (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd216130d10>: Failed to establish a new connection: [Errno -2] Name does not resolve'))', please check your entries in the configuration file (host, port, etc.) and verify that the database exists and is READ/WRITE. Retrying again in 60 seconds.
2020-04-27 06:56:45 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect due to exception: [Errno -2] Name does not resolve
2020-04-27 06:56:45 WARNING (MainThread) [homeassistant.config_entries] Config entry for mqtt not ready yet. Retrying in 5 seconds.
2020-04-27 06:56:46 ERROR (MainThread) [homeassistant.components.switch] Error while setting up mqtt platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 295, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 445, in _async_add_entity
    await entity.async_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/mqtt/switch.py", line 134, in async_added_to_hass
    await self._subscribe_topics()
  File "/usr/src/homeassistant/homeassistant/components/mqtt/switch.py", line 188, in _subscribe_topics
    "qos": self._config[CONF_QOS],
  File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 91, in async_subscribe_topics
    await requested.resubscribe_if_necessary(hass, current)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 47, in resubscribe_if_necessary
    hass, self.topic, self.message_callback, self.qos, self.encoding
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 447, in async_subscribe
    encoding,
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 876, in async_subscribe
    await self._async_perform_subscription(topic, qos)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 916, in _async_perform_subscription
    _raise_on_error(result)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 1027, in _raise_on_error
    f"Error talking to MQTT: {mqtt.error_string(result_code)}"
homeassistant.exceptions.HomeAssistantError: Error talking to MQTT: The client is not currently connected.
2020-04-27 06:56:46 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up mqtt platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 295, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 445, in _async_add_entity
    await entity.async_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/mqtt/sensor.py", line 122, in async_added_to_hass
    await self._subscribe_topics()
  File "/usr/src/homeassistant/homeassistant/components/mqtt/sensor.py", line 174, in _subscribe_topics
    "qos": self._config[CONF_QOS],
  File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 91, in async_subscribe_topics
    await requested.resubscribe_if_necessary(hass, current)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 47, in resubscribe_if_necessary
    hass, self.topic, self.message_callback, self.qos, self.encoding
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 447, in async_subscribe
    encoding,
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 876, in async_subscribe
    await self._async_perform_subscription(topic, qos)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 916, in _async_perform_subscription
    _raise_on_error(result)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 1027, in _raise_on_error
    f"Error talking to MQTT: {mqtt.error_string(result_code)}"
homeassistant.exceptions.HomeAssistantError: Error talking to MQTT: The client is not currently connected.
2020-04-27 06:56:51 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect due to exception: [Errno -2] Name does not resolve
2020-04-27 06:56:51 WARNING (MainThread) [homeassistant.config_entries] Config entry for mqtt not ready yet. Retrying in 10 seconds.
2020-04-27 06:57:02 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect due to exception: [Errno -2] Name does not resolve
2020-04-27 06:57:02 WARNING (MainThread) [homeassistant.config_entries] Config entry for mqtt not ready yet. Retrying in 20 seconds.
2020-04-27 06:57:23 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect due to exception: [Errno -2] Name does not resolve
2020-04-27 06:57:23 WARNING (MainThread) [homeassistant.config_entries] Config entry for mqtt not ready yet. Retrying in 40 seconds.

Did you check if your mqtt broker is running ?

Yes mqtt is up and running. I can turn on/off my switches/lights with MQTTfx when publishing to the topics.

Did you check in developer tools -> Mqtt if HA can talk to your mqtt broker ? There is clearly a problem between HA and mqtt.

Okay HA can’t talk to the mqtt. When I try to publish to a topic with HA I get an error. Fehler beim Aufrufen des Service mqtt/publish. Service not found. -> Failure calling service mqtt/publish. Service not found.

Why is the service suddenly not found?

What broker are you using ?

I’m using eclipse-mosquitto for docker in version 1.6.9. And I only can’t use it from HA, when I test it with other software I can publish and subscribe topics and it is working.

Try to configure it in configuration.yaml :

Example :

mqtt:
  broker: 10.0.0.63
  port: 1883
  discovery: true
  discovery_prefix: homeassistant
  username: xxx
  password: xxx

Restart HA after making the changes.

Thats how I did it:

mqtt:
  broker: !secret mqtt_url
  port: !secret mqtt_port
  client_id: home-assistant
  discovery: true
  discovery_prefix: homeassistant

I don’t have username and password for my mqtt broker because it is only in my local network.

And it works now ?

Sorry didn’t notice that this already was my configuration. The error still remains :frowning:

Do you see anything in the mosquitto logs ?

No activity from HA in the mosquitto logs. It seems that HA can’t even reach it.
I think HA gernerally has a problem that it can’t conntect to anything. This is from the HA log:

2020-04-27 19:26:31 ERROR (MainThread) [homeassistant.components.updater] Error requesting Home Assistant update data: Cannot connect to host updater.home-assistant.io:443 ssl:None [Try again]
2020-04-27 19:26:32 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect due to exception: [Errno -3] Try again
2020-04-27 19:26:32 ERROR (MainThread) [metno] https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/ returned Cannot connect to host aa015h6buqvih86i1.api.met.no:443 ssl:None [Try again]

Here you can see that it fails to connect to mqtt and also to the weather forecast (api.met.no). Same is for influxdb.

run

ha dns info

in SSH and see if there are dns servers present.

Where is the ha command located? I have connected to the container but the command is not in the path:
bash: ha: command not found

Ok, your probably nor running Home Assistant supervised, but Home Assistant Core on docker. Then I don’t know how to fix HA not connecting to anything.

Based on your hint for dns I have investigated a bit further. The problem I’m facing is in fact not a problem related to Home Assistant.
I run HA as a docker container on synology nas. To get it connected to the internet I don’t run it on the host network but on the bridge.
I have tried to run HA on the host network and then it works.
Now I have to figure out why it has stopped working. But I think this is a docker related problem and not HA.

Thanks for your help