Consistent disconnect from HASS

i use it, but have no hassio.
do you have ssl in your home assistant?

if not i am sure that it is a hassio problem.

Yes, I use SSL everywhere, except on my local network…

if SSL in inside hass it can be the problem.

NGINX terminates the SSL handshake. There is no SSL inside HASS.

thats what i asked :wink:
then i can only think that somehow the hassio docker isnt making a right connection to your hass.
did you recheck the url if you didnt make a typo? (grassping at possibilities, as you see :wink: )

No typos. I used the same line as version 2, that is:

ha_url: http://192.168.1.125:8123

That created the disconnection issues with HASS. I then tested:

ha_url: https://myDomainname.duckdns.org

and that worked fine. No more error messages. I then decided to simply try:

ha_url: http://hassio/homeassistant

and that worked !!! I’m leaving it like that (without port 8123). I’m still not sure why my local IP and port wasn’t working. HASS works fine in a browser using my local IP address.

Problem solved. Thanks!

1 Like

thats still local, so good to know they use that.
glad you solved it.

I got the same error, and your solution worked for me too! Thank you!

The problem I am such a solution: ha_key: ’ ’
The key is not empty。Be sure to add:’ ’

Worked for me too. Thanks!

Hello, i hope someone can help. i am also having an issue with constant disconnection.
everything was running fine.
I then upgraded home assistant to version 0.82.1 and also upgrade the AppDaemon Hass.io add-on to the latest version (1.6.0)
now all my dashboards have ‘entity not found’ and looking at the log file for AppDaemon i seem to be having a similar issue to above.
I haven’t changed any of my .yaml files since the upgrade so not sure what has changed in the upgrade.
I’m running HassOS 1.12 on a Pi.

Log file as such:

2018-11-21 18:56:45.282582 INFO AppDaemon Version 3.0.2 starting
2018-11-21 18:56:45.283314 INFO Configuration read from: /config/appdaemon/appdaemon.yaml
2018-11-21 18:56:45.286475 INFO AppDaemon: Starting Apps
2018-11-21 18:56:45.294493 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2018-11-21 18:56:45.534475 INFO AppDaemon: HASS: HASS Plugin Initializing
2018-11-21 18:56:45.535755 INFO AppDaemon: HASS: HASS Plugin initialization complete
2018-11-21 18:56:45.546389 INFO Starting Dashboards
2018-11-21 18:56:45.566247 INFO API is disabled
2018-11-21 18:56:46.195646 INFO AppDaemon: HASS: Connected to Home Assistant 0.82.1
2018-11-21 18:56:46.196774 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-11-21 18:56:50.575025 INFO HADashboard: New dashboard connected: Down Stairs
2018-11-21 18:56:52.742549 INFO AppDaemon: HASS: Connected to Home Assistant 0.82.1
2018-11-21 18:56:52.744554 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-11-21 18:56:54.820214 INFO HADashboard: New dashboard connected: Down Stairs
2018-11-21 18:56:58.161133 INFO AppDaemon: HASS: Connected to Home Assistant 0.82.1
2018-11-21 18:56:58.163395 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-11-21 18:57:04.701565 INFO AppDaemon: HASS: Connected to Home Assistant 0.82.1
2018-11-21 18:57:04.705846 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-11-21 18:57:10.249096 INFO AppDaemon: HASS: Connected to Home Assistant 0.82.1
2018-11-21 18:57:10.253252 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-11-21 18:57:15.785457 INFO AppDaemon: HASS: Connected to Home Assistant 0.82.1
2018-11-21 18:57:15.787538 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-11-21 18:57:22.365974 INFO AppDaemon: HASS: Connected to Home Assistant 0.82.1
2018-11-21 18:57:22.368132 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-11-21 18:57:27.949145 INFO AppDaemon: HASS: Connected to Home Assistant 0.82.1
2018-11-21 18:57:27.951176 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2018-11-21 18:57:34.483318 INFO AppDaemon: HASS: Connected to Home Assistant 0.82.1
2018-11-21 18:57:34.485416 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds

appdaemon.yaml as follows:
this always worked until upgrade:

secrets: /config/secrets.yaml
log:
logfile: /config/appdaemon/appdaemon.log
errorfile: /config/appdaemon/error.log
appdaemon:
latitude: 51.757056
longitude: -0.22528
elevation: 89
time_zone: united_kingdom/London
disable_apps: 1
threads: 10
app_dir: /config/appdaemon/apps
plugins:
HASS:
type: hass
ha_url: https://**********.duckdns.org:8123
hadashboard:
dash_url: http://192.168.0.222:5050
dash_dir: /config/appdaemon/dashboards
dash_password: **********

if you provide yaml please present it as codeblock, or it is not readable.
but i notice some things anyway.

you use hassio, so in your log from the addon there is the warning to use the hassio url.
in the last few versions from HA you need authentication in the appdaemon.yaml
and with the last appdaemon version you need a long lived token.
when the url is set correct hassio automaticly takes care of the token for you
latitude,logtitude elevation and timezone are not needed.

Hi Rene,

thanks for your help.
I have changed the url to haasio/homeassistant and that is now working well. im a little confused as to why this has changed. i tried this in the old version and it didn’t work and i had to use mydomain.duckdns.org due to ssl. weird but as long as it works that’s the important thing. thank you.

Im now trying to get my dahs password to work again. i used to use:

dash_password: !secret dash_password

that does not seem to work anymore as i get:

WARNING HADashboard: Unsuccessful logon from mydomain.duckdns.org:5050

If i use a password directly in the appdaemon.yaml file it works fine but i want the password in my secrets file.

here is the latest appdaemon.yaml. (im not sure if im doing things right to display as codeblock, if not please tell me how, im new to forums)

secrets: /config/secrets.yaml
log:
  logfile: /config/appdaemon/appdaemon.log
  errorfile: /config/appdaemon/error.log
appdaemon:
  latitude: 51.757056
  longitude: -0.22528
  elevation: 89
  disable_apps: 1
  threads: 10
  app_dir: /config/appdaemon/apps
  plugins:
HASS:
  type: hass
  ha_url: http://hassio/homeassistant
  token: *********************************************************************
hadashboard:
  dash_url: http://192.168.0.222:5050
  dash_dir: /config/appdaemon/dashboards
  dash_password: !secret dash_password

using the secrets file doesnt work in the addon.
i believe that frenck would work on that but i am not sure about that.

Okay, thanks Rene.
Obviously it’s changed as it did work previously.
As long as it’s not something I’m doing wrong.
Many thanks for all your help.

1 Like

I’m having a similar problem all of a sudden. AD disconnects, and then reconnects. ABout 2 min later, it disconnects again and reconnects.

My appdaemon.yaml is:

secrets: /config/secrets.yaml
log:
  logfile: /config/appdaemon/log/appdaemonlog.log
  errorfile: /config/appdaemon/log/appdaemonerr.log
appdaemon:
  threads: 10
  app_dir: /config/appdaemon/apps
  plugins:
    HASS:
      type: hass
      ha_url: http://hassio/homeassistant
      token: ****************************************************
hadashboard:
  dash_url: http://127.0.0.1:5050
  dash_dir: /config/appdaemon/dashboards

I’m running on an RPi 3 B+, hass.io, just updated to Home Assistant 0.96.4 from 0.95.x) and have been running on the Pi for about a year now with no issues. This started last week, and has been somewhat consistent for a couple of hours, and then seems to settle down.

The applicable lines from the log file (with debug enabled) are (and I’ll admit that I’m not familiar at all with the web socket activity, but certainly sounds like a connection issue):

2019-07-22 12:42:02.805852 DEBUG AppDaemon: Event type:state_changed:
2019-07-22 12:42:02.806964 DEBUG AppDaemon: {'entity_id': 'sensor.memory_free', 'old_state': {'entity_id': 'sensor.memory_free', 'state': '487.4', 'attributes': {'unit_of_measurement': 'MiB', 'friendly_name': 'Memory free', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:03.044611+00:00', 'last_updated': '2019-07-22T17:39:03.044611+00:00', 'context': {'id': '9dae4e808b884978b37a892916163e48', 'parent_id': None, 'user_id': None}}, 'new_state': {'entity_id': 'sensor.memory_free', 'state': '487.1', 'attributes': {'unit_of_measurement': 'MiB', 'friendly_name': 'Memory free', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:34.055422+00:00', 'last_updated': '2019-07-22T17:39:34.055422+00:00', 'context': {'id': '1e8863f3b7fa42889a6c18de66a25f7f', 'parent_id': None, 'user_id': None}}}
2019-07-22 12:42:02.808413 DEBUG AppDaemon: {'entity_id': 'sensor.memory_free', 'old_state': {'entity_id': 'sensor.memory_free', 'state': '487.4', 'attributes': {'unit_of_measurement': 'MiB', 'friendly_name': 'Memory free', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:03.044611+00:00', 'last_updated': '2019-07-22T17:39:03.044611+00:00', 'context': {'id': '9dae4e808b884978b37a892916163e48', 'parent_id': None, 'user_id': None}}, 'new_state': {'entity_id': 'sensor.memory_free', 'state': '487.1', 'attributes': {'unit_of_measurement': 'MiB', 'friendly_name': 'Memory free', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:34.055422+00:00', 'last_updated': '2019-07-22T17:39:34.055422+00:00', 'context': {'id': '1e8863f3b7fa42889a6c18de66a25f7f', 'parent_id': None, 'user_id': None}}}
2019-07-22 12:42:02.822806 DEBUG AppDaemon: Event type:state_changed:
2019-07-22 12:42:02.823629 DEBUG AppDaemon: {'entity_id': 'sensor.load_15m', 'old_state': {'entity_id': 'sensor.load_15m', 'state': '3.02978515625', 'attributes': {'unit_of_measurement': ' ', 'friendly_name': 'Load (15m)', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:03.063527+00:00', 'last_updated': '2019-07-22T17:39:03.063527+00:00', 'context': {'id': '52c068d17cfd41aa9a5caad560540616', 'parent_id': None, 'user_id': None}}, 'new_state': {'entity_id': 'sensor.load_15m', 'state': '3.00146484375', 'attributes': {'unit_of_measurement': ' ', 'friendly_name': 'Load (15m)', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:34.072256+00:00', 'last_updated': '2019-07-22T17:39:34.072256+00:00', 'context': {'id': 'bc040644b3f0406c9df7bee31b334a55', 'parent_id': None, 'user_id': None}}}
2019-07-22 12:42:02.824743 DEBUG AppDaemon: {'entity_id': 'sensor.load_15m', 'old_state': {'entity_id': 'sensor.load_15m', 'state': '3.02978515625', 'attributes': {'unit_of_measurement': ' ', 'friendly_name': 'Load (15m)', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:03.063527+00:00', 'last_updated': '2019-07-22T17:39:03.063527+00:00', 'context': {'id': '52c068d17cfd41aa9a5caad560540616', 'parent_id': None, 'user_id': None}}, 'new_state': {'entity_id': 'sensor.load_15m', 'state': '3.00146484375', 'attributes': {'unit_of_measurement': ' ', 'friendly_name': 'Load (15m)', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:34.072256+00:00', 'last_updated': '2019-07-22T17:39:34.072256+00:00', 'context': {'id': 'bc040644b3f0406c9df7bee31b334a55', 'parent_id': None, 'user_id': None}}}
2019-07-22 12:42:02.839056 DEBUG AppDaemon: Event type:state_changed:
2019-07-22 12:42:02.839877 DEBUG AppDaemon: {'entity_id': 'sensor.load_5m', 'old_state': {'entity_id': 'sensor.load_5m', 'state': '3.173828125', 'attributes': {'unit_of_measurement': ' ', 'friendly_name': 'Load (5m)', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:03.037129+00:00', 'last_updated': '2019-07-22T17:39:03.037129+00:00', 'context': {'id': '1886aec06d324f22884a0f1c66d2d579', 'parent_id': None, 'user_id': None}}, 'new_state': {'entity_id': 'sensor.load_5m', 'state': '3.07373046875', 'attributes': {'unit_of_measurement': ' ', 'friendly_name': 'Load (5m)', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:34.085887+00:00', 'last_updated': '2019-07-22T17:39:34.085887+00:00', 'context': {'id': '26975679ee5544c2b1987b84d406cfea', 'parent_id': None, 'user_id': None}}}
2019-07-22 12:42:02.840997 DEBUG AppDaemon: {'entity_id': 'sensor.load_5m', 'old_state': {'entity_id': 'sensor.load_5m', 'state': '3.173828125', 'attributes': {'unit_of_measurement': ' ', 'friendly_name': 'Load (5m)', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:03.037129+00:00', 'last_updated': '2019-07-22T17:39:03.037129+00:00', 'context': {'id': '1886aec06d324f22884a0f1c66d2d579', 'parent_id': None, 'user_id': None}}, 'new_state': {'entity_id': 'sensor.load_5m', 'state': '3.07373046875', 'attributes': {'unit_of_measurement': ' ', 'friendly_name': 'Load (5m)', 'icon': 'mdi:memory'}, 'last_changed': '2019-07-22T17:39:34.085887+00:00', 'last_updated': '2019-07-22T17:39:34.085887+00:00', 'context': {'id': '26975679ee5544c2b1987b84d406cfea', 'parent_id': None, 'user_id': None}}}
2019-07-22 12:42:02.850537 DEBUG AppDaemon: Event type:ha_disconnected:
2019-07-22 12:42:02.851225 DEBUG AppDaemon: {}
2019-07-22 12:42:02.853141 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
2019-07-22 12:42:02.853980 WARNING AppDaemon: HASS: ------------------------------------------------------------
2019-07-22 12:42:02.854912 WARNING AppDaemon: HASS: Unexpected error:
2019-07-22 12:42:02.855476 WARNING AppDaemon: HASS: ------------------------------------------------------------
2019-07-22 12:42:02.857492 WARNING AppDaemon: HASS: Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/appdaemon/plugins/hass/hassplugin.py", line 227, in get_updates
    ret = await utils.run_in_executor(self.AD.loop, self.AD.executor, self.ws.recv)
  File "/usr/lib/python3.7/site-packages/appdaemon/utils.py", line 125, in run_in_executor
    response = list(completed)[0].result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.7/site-packages/websocket/_core.py", line 313, in recv
    opcode, data = self.recv_data()
  File "/usr/lib/python3.7/site-packages/websocket/_core.py", line 330, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/lib/python3.7/site-packages/websocket/_core.py", line 361, in recv_data_frame
    self.pong(frame.data)
  File "/usr/lib/python3.7/site-packages/websocket/_core.py", line 304, in pong
    self.send(payload, ABNF.OPCODE_PONG)
  File "/usr/lib/python3.7/site-packages/websocket/_core.py", line 253, in send
    return self.send_frame(frame)
  File "/usr/lib/python3.7/site-packages/websocket/_core.py", line 278, in send_frame
    l = self._send(data)
  File "/usr/lib/python3.7/site-packages/websocket/_core.py", line 448, in _send
    return send(self.sock, data)
  File "/usr/lib/python3.7/site-packages/websocket/_socket.py", line 157, in send
    return _send()
  File "/usr/lib/python3.7/site-packages/websocket/_socket.py", line 139, in _send
    return sock.send(data)
BrokenPipeError: [Errno 32] Broken pipe

2019-07-22 12:42:02.858231 WARNING AppDaemon: HASS: ------------------------------------------------------------
2019-07-22 12:42:03.020639 DEBUG AppDaemon: Scheduler loop compute time: 3.0ms

I need some help - I have tried for a week to figure things out, but am at a loss. And HA is pretty useless in this state…

Okay, I seemed to have figured out how to re-produce this and prevent it on a consistent basis. When I restart homeassistant (homeassistant.restart service), without first stopping AD, i get the disconnect/reconnect cycle. If i first go to AD and stop it, then restart homeassistant, and then, once it’s up and running, start AD, I don’t get the disconnect/reconnect cycle. I’m definitely not smart enough to figure out why this works, but hoping that @aimc, @ReneTode or someone smarter than me can help figure this out. This is an acceptable work-around for me at the moment.

there is something inside your apps that needs HA to be up and running before they are initialised.
when you restart HA, and you didnt set the right settings in the app settings, the apps will all be reinitialised as soon as AD gets the signal from HA that HA is up and running.

but even though HA is up and running some components can be still unfinished initialising.
in the initialisation from your apps make sure (put in checks) that the HA components you work with are available.

Thanks, @ReneTode. This makes sense. When you refer to HA components, would that be things like service calls? For example, I have an HVAC module that sets up callbacks in the initialization function, and then calls a function to preset the thermostats to the settings according to a schedule. In that function, I use the service call to hvac_mode and set_temperature, which is where I think the problem might be. How do i check to see if, in this case, the climate component is fully loaded in HA before calling these services?