HA doesn't start after Power OFF and ON

Some time i have a power problems in my apartment, so when i am at work the power goes Off and then On, and every time the HA on my raspberry doesn’t start the http control, so i can’t open the gui,the raspberry is connected to the internet and all the automation on HA are working
I will try to take the log to see if there is any option to fix it.
Any one have the same problem?

How did you install HA?

Virtual invirment

The instructions for setting up autostart are here
https://home-assistant.io/docs/autostart/

The HA is starting,but without gui

It does take a few minutes to start on the Pi. How long did you wait?

What is the error message you are getting? What does the log file say?

2017-11-22 11:17:13 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py”, line 190, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/init.py”, line 387, in async_setup
success = yield from hass.data[DATA_MQTT].async_connect()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/init.py”, line 498, in async_connect
self._mqttc.connect, self.broker, self.port, self.keepalive)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/paho/mqtt/client.py”, line 768, in connect
return self.reconnect()
File “/srv/homeassistant/lib/python3.5/site-packages/paho/mqtt/client.py”, line 895, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File “/usr/lib/python3.5/socket.py”, line 694, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File “/usr/lib/python3.5/socket.py”, line 733, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution
2017-11-22 11:17:15 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=94 from 2017-11-20 10:56:53.837525)
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies.
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies.
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies.
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies.
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies.
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies.
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies.
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:17 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.
2017-11-22 11:17:18 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of switch.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:18 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform switch.mqtt: Could not setup all dependencies.
2017-11-22 11:17:18 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of switch.mqtt. Setup failed for dependencies: mqtt
2017-11-22 11:17:18 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform switch.mqtt: Could not setup all dependencies.
2017-11-22 11:17:18 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of device_tracker.owntracks. Setup failed for dependencies: mqtt
2017-11-22 11:17:18 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform device_tracker.owntracks: Could not setup all dependencies.
2017-11-22 11:17:20 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform xiaomi
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connection.py”, line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/util/connection.py”, line 83, in create_connection
raise err
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/util/connection.py”, line 73, in create_connection
sock.connect(sa)
OSError: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 601, in urlopen
chunked=chunked)
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File “/usr/lib/python3.5/http/client.py”, line 1107, in request
self._send_request(method, url, body, headers)
File “/usr/lib/python3.5/http/client.py”, line 1152, in _send_request
self.endheaders(body)
File “/usr/lib/python3.5/http/client.py”, line 1103, in endheaders
self._send_output(message_body)
File “/usr/lib/python3.5/http/client.py”, line 934, in _send_output
self.send(msg)
File “/usr/lib/python3.5/http/client.py”, line 877, in send
self.connect()
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connection.py”, line 166, in connect
conn = self._new_conn()
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connection.py”, line 150, in _new_conn
self, “Failed to establish a new connection: %s” % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x6b310ed0>: Failed to establish a new connection: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/requests/adapters.py”, line 440, in send
timeout=timeout
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File “/srv/homeassistant/lib/python3.5/site-packages/urllib3/util/retry.py”, line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘192.168.31.1’, port=80): Max retries exceeded with url: /cgi-bin/luci/api/xqsystem/login (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x6b310ed0>: Failed to establish a new connection: [Errno 113] No route to host’,))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/init.py”, line 149, in async_setup_platform
platform.get_scanner, hass, {DOMAIN: p_config})
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/xiaomi.py”, line 28, in get_scanner
scanner = XiaomiDeviceScanner(config[DOMAIN])
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/xiaomi.py”, line 46, in init
self.token = _get_token(self.host, self.username, self.password)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/xiaomi.py”, line 152, in _get_token
res = requests.post(url, data=data, timeout=5)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/api.py”, line 112, in post
return request(‘post’, url, data=data, json=json, **kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/api.py”, line 58, in request
return session.request(method=method, url=url, **kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/sessions.py”, line 508, in request
resp = self.send(prep, **send_kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/sessions.py”, line 618, in send
r = adapter.send(request, **kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/requests/adapters.py”, line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘192.168.31.1’, port=80): Max retries exceeded with url: /cgi-bin/luci/api/xqsystem/login (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x6b310ed0>: Failed to establish a new connection: [Errno 113] No route to host’,))
2017-11-22 11:17:25 ERROR (Thread-21) [homeassistant.components.light.yeelight] Failed to connect to bulb 192.168.31.109, test light: A socket error occurred when sending the command.
2017-11-22 11:17:25 WARNING (MainThread) [homeassistant.setup] Setup of sensor is taking over 10 seconds.
2017-11-22 11:17:26 WARNING (MainThread) [homeassistant.setup] Setup of duckdns is taking over 10 seconds.
2017-11-22 11:17:27 WARNING (MainThread) [homeassistant.components.sensor] Setup of platform command_line is taking over 10 seconds.
2017-11-22 11:17:27 WARNING (MainThread) [homeassistant.setup] Setup of media_player is taking over 10 seconds.
2017-11-22 11:17:27 WARNING (MainThread) [homeassistant.setup] Setup of light is taking over 10 seconds.
2017-11-22 11:17:27 WARNING (MainThread) [homeassistant.setup] Setup of switch is taking over 10 seconds.
2017-11-22 11:17:30 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking over 10 seconds.
2017-11-22 11:17:30 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking over 10 seconds.
2017-11-22 11:17:32 WARNING (MainThread) [homeassistant.components.switch] Setup of platform broadlink is taking over 10 seconds.
2017-11-22 11:17:32 WARNING (MainThread) [homeassistant.components.switch] Setup of platform broadlink is taking over 10 seconds.
2017-11-22 11:17:32 ERROR (Thread-12) [homeassistant.components.switch.broadlink] Failed to connect to device
2017-11-22 11:17:37 ERROR (MainThread) [homeassistant.setup] Error during setup of component duckdns
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py”, line 804, in _create_direct_connection
hosts = yield from self._resolve_host(req.url.raw_host, req.port)
File “/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py”, line 718, in _resolve_host
loop=self._loop)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/asyncio/tasks.py”, line 241, in _step
result = coro.throw(exc)
File “/srv/homeassistant/lib/python3.5/site-packages/aiohttp/resolver.py”, line 31, in resolve
host, port, type=socket.SOCK_STREAM, family=family)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.5/socket.py”, line 733, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py”, line 190, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/duckdns.py”, line 59, in async_setup
result = yield from _update_duckdns(session, domain, token)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/duckdns.py”, line 105, in _update_duckdns
resp = yield from session.get(UPDATE_URL, params=params)
File “/srv/homeassistant/lib/python3.5/site-packages/aiohttp/helpers.py”, line 99, in iter
ret = yield from self._coro
File “/srv/homeassistant/lib/python3.5/site-packages/aiohttp/client.py”, line 269, in _request
conn = yield from self._connector.connect(req)
File “/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py”, line 393, in connect
proto = yield from self._create_connection(req)
File “/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py”, line 740, in _create_connection
_, proto = yield from self._create_direct_connection(req)
File “/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py”, line 808, in _create_direct_connection
raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host www.duckdns.org:443 ssl:True [Temporary failure in name resolution]
2017-11-22 11:17:37 ERROR (Thread-11) [homeassistant.components.switch.broadlink] Failed to connect to device
2017-11-22 11:17:41 ERROR (Thread-15) [homeassistant.components.sensor.command_line] Timeout for command: python3 -c “import requests; print(requests.get(‘https://pypi.python.org/pypi/homeassistant/json’).json()[‘info’]['version’])”

could be a problem with your mqtt component. try to to disable this component.


an go ahead step by step

There is no problem with the mqtt, the HA working perfect after restart

It looks like you reference something in your configuration.yaml using an external name, rather than an address, and the domain name service (dns) which does the translation has not started when HA starts.

You can probably tell HA to start after the dns service by adjusting the /etc/systemd/system/homeassistant.service file, but I have not sure on the syntax.

I don’t have the knowledge to do this.
Thanks for the help

You might try delaying the startup of HA using some of the techniques in this thread