Home Assistant and Appdaemon - Disconnect from Home Assistant, Retrying in 5 Seconds

The current version of Home Assistant and AppDaemon were installed as Docker containers on Ubuntu.
Home Assistant was installed using:

sudo docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Africa/Johannesburg  \
  -v /home/karibi/home_assistant:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

I can access it on port 8123 and the installation appears to be okay. However, I have not carried out any further configuration.

I installed AppDaemon on the same computer using:

sudo docker run --rm -it -p 5050:5050 \
  --name AppDaemon \
  -e HA_URL=http://UbuntuSrv:8123 \
  -e DASH_URL="http://$HOSTNAME:5050" \
    -v /home/karibi/appDaemon:/conf \
  acockburn/appdaemon:latest

It is running and can be viewed in Portainer. Long live tokens were not used as I believe they are not required. The log file shows it starting up correctly but immediately disconnects and retries 5 seconds later. This is a completely clean build so there is nothing left over from previous installations. Could anybody point me in the right direction to resolve this issue? Any suggestions would be very much appreciated.

2022-12-11 21:05:23.863733 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-12-11 21:05:23.863866 INFO AppDaemon: Python version is 3.9.9
2022-12-11 21:05:23.863947 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml
2022-12-11 21:05:23.864019 INFO AppDaemon: Added log: AppDaemon
2022-12-11 21:05:23.864097 INFO AppDaemon: Added log: Error
2022-12-11 21:05:23.864168 INFO AppDaemon: Added log: Access
2022-12-11 21:05:23.864237 INFO AppDaemon: Added log: Diag
2022-12-11 21:05:23.876333 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-12-11 21:05:23.888181 INFO HASS: HASS Plugin Initializing
2022-12-11 21:05:23.888308 INFO HASS: HASS Plugin initialization complete
2022-12-11 21:05:23.888553 INFO AppDaemon: Initializing HTTP
2022-12-11 21:05:23.888737 INFO AppDaemon: Using 'ws' for event stream
2022-12-11 21:05:23.890786 INFO AppDaemon: Starting API
2022-12-11 21:05:23.892590 INFO AppDaemon: Starting Admin Interface
2022-12-11 21:05:23.892777 INFO AppDaemon: Starting Dashboards
2022-12-11 21:05:28.899616 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2022-12-11 21:05:28.910420 INFO AppDaemon: App 'hello_world' added
2022-12-11 21:05:28.910648 INFO AppDaemon: Found 1 total apps
2022-12-11 21:05:28.910857 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2022-12-11 21:05:28.914286 INFO AppDaemon: Running on port 5050
2022-12-11 21:05:38.908036 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2022-12-11 21:05:48.916322 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2022-12-11 21:05:58.922471 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds

Thanks

You’ll need to use a long-lived token. This needs to be referred in the docker setup or in the docker- compose file.

Thanks for the suggestion. I added the token into appdaemon yaml file. Unfortunately, it didn’t resolve the issue but thanks for the information.

Did you set it up using Docker? If so can you share your appdaemon compose file? If not, please share the config file?

Yes it is running in Docker and I just edited the appdaemon.yaml file. I have added the log file at the end. Both homeassistant and appdaemon are running on the same hardware so I am assuming that eliminates any potential firewall issues. Thanks for your continuing help.

appdaemon:
  latitude: -33.8044
  longitude: 18.9683
  elevation: 0
  unit_system: metric
  time_zone: Africa/Johannesburg
  plugins:
    HASS:
      type: hass
      ha_url: http://UbuntuSrv:8123
      token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI4ZmFhM2IzZWIwNzQ0MDg3ODYxZGRiODljMWJmOWQ5YSIsImlhdCI6MTY3MDcwMzkyMCwiZXhwIjoxOTg2MDYzOTIwfQ.VMzNBpSiwCtsucs0tdDCXElTQHQCFOtnbYDR9mqOV_s
http:
  url: http://UbuntuSrv:5050
admin:
api:
hadashboard:
logs:
  error_log:
      filename: /conf/error.log
  main_log:
      filename: /conf/appdaemon.log
  access_log:
      filename: /conf/access.log
  diag_log:
      filename: /conf/diag.log      

Appdaemon log is:

2022-12-12 20:26:24.979834 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-12-12 20:26:24.980093 INFO AppDaemon: Python version is 3.9.9
2022-12-12 20:26:24.980247 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml
2022-12-12 20:26:24.980396 INFO AppDaemon: Added log: AppDaemon
2022-12-12 20:26:24.980553 INFO AppDaemon: Added log: Error
2022-12-12 20:26:24.980707 INFO AppDaemon: Added log: Access
2022-12-12 20:26:24.980854 INFO AppDaemon: Added log: Diag
2022-12-12 20:26:24.993402 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-12-12 20:26:25.017540 INFO HASS: HASS Plugin Initializing
2022-12-12 20:26:25.017697 INFO HASS: HASS Plugin initialization complete
2022-12-12 20:26:25.018027 INFO AppDaemon: Initializing HTTP
2022-12-12 20:26:25.018318 INFO AppDaemon: Using 'ws' for event stream
2022-12-12 20:26:25.020648 INFO AppDaemon: Starting API
2022-12-12 20:26:25.022609 INFO AppDaemon: Starting Admin Interface
2022-12-12 20:26:25.022878 INFO AppDaemon: Starting Dashboards
2022-12-12 20:26:30.031294 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2022-12-12 20:26:30.037513 INFO AppDaemon: App 'hello_world' added
2022-12-12 20:26:30.037836 INFO AppDaemon: Found 1 total apps
2022-12-12 20:26:30.038112 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2022-12-12 20:26:30.038622 INFO AppDaemon: Running on port 5050
2022-12-12 20:26:40.039866 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2022-12-12 20:26:50.046047 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds

Hi there,

Here’s my Docker ditto for reference:

version: "3.8"
services:
# Appdaemon
  appdaemon:
    container_name: appdaemon
    image: acockburn/appdaemon:latest
    restart: always
    privileged: true
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/docker/appdaemon/conf:/conf
    environment:
      - HA_URL=http://$SERVER_IP:8123
      - TOKEN=$HA_APPDAEMON_KEY
      - DASH_URL=http://$SERVER_IP:5050
    ports:
      - "5050:5050"

The environment variables are as follows:
HA_URL points to the URL of your HA instance (including the port)
TOKEN is the long-lived token you acquire from your HA instance
DASH_URLis the URL to the AppDaemon instance (including the port)

You can check out the AppDaemon with Docker tutorial.

Hope this helps

Bjarne

Hello,
I have had HA and AD (always on docker) for about three years and I didn’t really want to update them because the file syntax had changed and above version 2021.6.6 modbus no longer wanted to read my converters.

But to the point, a month ago I decided that I would update everything to “latest”, knowing that I would have to change the “yaml” syntax in HA and the converters… well, I now have two HA instances running, i.e. “latest” and “2021.6.6” .
After the update, HA and AD worked on old long-life tokens.

I was tempted to straighten out one nuisance - out of two phones, one was no longer tracked, I found information that I had to log out and remove the token. After several attempts to log out + remove tokens, I decided to delete all of them. On computers or phones, I will log in again and create the AD token again.

It stopped working and in AD I have “WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds”. So I installed AD on another machine and left tcpdump on the server listening to the IP from the new machine.
It turned out that AD did not establish any communication with HA, no packet.

On the above-mentioned new machine there is a new instance from this morning with another new long-life token.
The website http://new-machine-AD:5050 works without any problems.

Any ideas ?

Regards

Changing the

HA_URL=“srv:8123”

parameter to

HA_URL=“http://srv:8123

during reinstallation helped me in all AD settings.