Consistent disconnect from HASS

I installed v3.0B2 add-on in HASSio and changed the configuration as specified and every 2 minutes and 12 seconds, the connection is lost betwwen AD and HASS. I get this in the logs:

2018-01-31 12:48:43.695293 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 12:50:56.015463 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 12:53:08.335282 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 12:55:20.655322 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 12:57:32.975252 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 12:59:45.295239 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:01:57.615304 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:04:09.935264 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:06:22.255245 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:08:34.575311 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:10:46.895330 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:12:59.215278 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:15:11.535280 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:17:23.855303 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:19:36.175972 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:21:48.495266 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:24:00.815253 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:26:13.135253 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:28:25.455259 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:30:37.775259 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:32:50.095306 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:35:02.415244 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:37:14.735285 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 13:39:27.055363 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds

VERY consistent , every 2 minutes and 12 seconds? Version 2 was fine. Any idea what’s going on?

please show:

  1. the first part of the log
  2. your appdaemon.yaml
  3. any other information that could help us pinpoint your problem (instaaled apps, how, where which files, etc.)

Also, if you can run with -D DEBUG we will be able to see more details of the error.

  1. The whole log looks fine. No other error messages. Here it is:
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Hass.io Add-on: AppDaemon3 v0.1.0
 Python Apps and HADashboard using AppDaemon 3.x for Home Assistant
 From: Community Hass.io Add-ons
 By: Franck Nijhof <[email protected]>
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
Log level is set to INFO
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] 02-updates.sh: executing... 
INFO: You are running the latest version of this add-on
[cont-init.d] 02-updates.sh: exited 0.
[cont-init.d] 03-version-requirements.sh: executing... 
INFO: Supervisor version requirements checks passed.
[cont-init.d] 03-version-requirements.sh: exited 0.
[cont-init.d] 20-init-configuration.sh: executing... 
[cont-init.d] 20-init-configuration.sh: exited 0.
[cont-init.d] 21-compiled-dir.sh: executing... 
[cont-init.d] 21-compiled-dir.sh: exited 0.
[cont-init.d] 50-compiled-symlink.sh: executing... 
[cont-init.d] 50-compiled-symlink.sh: exited 0.
[cont-init.d] 80-system-packages.sh: executing... 
[cont-init.d] 80-system-packages.sh: exited 0.
[cont-init.d] 81-python-packages.sh: executing... 
[cont-init.d] 81-python-packages.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
starting version 3.2.4
[services.d] done.
2018-01-31 21:15:32.802165 INFO AppDaemon Version 3.0.0b2 starting
2018-01-31 21:15:32.802819 INFO Configuration read from: /config/appdaemon/appdaemon.yaml
2018-01-31 21:15:32.805759 INFO AppDaemon: Starting Apps
2018-01-31 21:15:32.827669 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2018-01-31 21:15:33.099989 INFO AppDaemon: HASS: HASS Plugin Initializing
2018-01-31 21:15:33.101237 INFO AppDaemon: HASS: HASS Plugin initialization complete
2018-01-31 21:15:33.102324 INFO Starting Dashboards
2018-01-31 21:15:33.120360 INFO Starting API
  1. appdaemon,yaml:
secrets: /config/secrets.yaml
appdaemon:
  threads: 10
  app_dir: /config/appdaemon/apps
  api_port: 5000
  api_key: !secret api_key
  plugins:
    HASS:
      type: hass
      ha_url: !secret hass_IP
      ha_key: !secret http_password
log:
  logfile: STDOUT
  errorfile: STDERR
hadashboard:
  dash_url: http://127.0.0.1:5050
  dash_dir: /config/appdaemon/dashboards
  1. No apps running yet

In DEBUG mode, I get:

2018-01-31 21:22:21.614699 DEBUG AppDaemon: Event type:ha_disconnected:
2018-01-31 21:22:21.615641 DEBUG AppDaemon: {}
2018-01-31 21:22:21.616911 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-01-31 21:22:21.617835 WARNING AppDaemon: HASS: ------------------------------------------------------------
2018-01-31 21:22:21.618721 WARNING AppDaemon: HASS: Unexpected error:
2018-01-31 21:22:21.619573 WARNING AppDaemon: HASS: ------------------------------------------------------------
2018-01-31 21:22:21.634731 WARNING AppDaemon: HASS: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/plugins/hass/hassplugin.py", line 187, in get_updates
    "{}/api/websocket".format(url), sslopt=sslopt
  File "/usr/lib/python3.6/site-packages/websocket/_core.py", line 490, in create_connection
    websock.connect(url, **options)
  File "/usr/lib/python3.6/site-packages/websocket/_core.py", line 213, in connect
    options.pop('socket', None))
  File "/usr/lib/python3.6/site-packages/websocket/_http.py", line 70, in connect
    sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
  File "/usr/lib/python3.6/site-packages/websocket/_http.py", line 116, in _open_socket
    sock.connect(address)
TimeoutError: [Errno 110] Operation timed out
2018-01-31 21:22:21.635657 WARNING AppDaemon: HASS: ------------------------------------------------------------

Looks like a networking problem of some sort - AppDaemon is timing out on receiving information from HomeAssistan’t event stream. It looks like it is never succeeding in actually opening the connection.

They are both running on the same host (Raspberry Pi 3B). What I don’t get is the timing of the events; very regular and timed intervals. This was not an issue with version 2.

hass address is local ip?
could be that there is a difference how hassio connects AD3 to HA versus AD2 connection to HA.
did you deinstall V2?

Yes, local IP. I uninstalled v2 and installed v3 after. Nothing else was changed in between, except an upgrade from 0.62 to 0.62.1.

I already tried uninstalling and reinstalling Appdaemon 3. Same issue. I can try it again if needed.

you can use that same IP in a browser to connect to HA without trouble?

Yes, of course. No other issues to report… The only thing I already reported previously is a new error message introduced in HA v0.61. It’s also a regular event, every 8-10 minutes (not that consistent), but the timing does not match the disconnections between AD and HASS. The HASS error I get is:

Error doing job: Task exception was never retrieved
10:37 AM components/isy994.py (ERROR)

See the following post: "Error doing job: Task exception was never retrieved" (was Version 0.61+ and ISY994i)

I don’t think they are related. Like I said, it worked fine with AD v2.

i would suggest contacting frenck to ask if it could be a hassio problem.

I have the same issue on a new install, both hass and appdaemon in docker, more or less default configs on both services

hassio is also docker if i am correct.
i think its a connection problem that is not from inside AD, but from a docker or hassio configuration.
problems like this make me stay away from hassio, docker, venv, etc. :wink:

If it’s related to HASSio and/or Dockers, what I don’t understand is the exact frequency (every 2 minutes and 12 seconds) and the fact that I did not have this issue with version 2 of Appdaemon.

Robban, do you have the exact same frequency?

No, it retries every 5 seconds

2 complete different addons, so 2 different docker packages, with different configurations.

5 secs is logical, 2 minutes and 12 secs isnt (for me at this moment), but it still seems that you are not connected at all. could be that yours has a longer time because you dont use dashboard.

Retrying every 5 seconds, I get it; that’s because AD never connects to HASS (because of its configuration) and it’s retrying. Robban’s issue above is quite different than mine. But 2 minutes and 12 seconds, consistently, that’s not normal. I will play a little more with it to try to pinpoint this issue.

Got it. But I still don’t understand why it’s behaving this way. If I put in my FQDN (ie. https://myDomain.duckdns.org) in the plugins section of appdaemon.yaml, everything is working normally without disconnections. If I put in http://myLocalIP:8123, it does not work and disconnects every 2 minutes and 12 seconds. That is really strange…

Do you guys use your local network IP or your domain name in the configuration? I would prefer to use my local IP so that I can avoid DNS issues altogether and everything stays local.