Home assistant 0.110.1 and AppDaemon 4.0.3

Hello!

I’m using Ubuntu 18.04 in a virtual machine and running Home assistant (HA) and AppDaemon (AD) using docker-compose. I’m a new user and have been playing with this for about a week.
This is the docker-compose.yml I’m using:

version: "3"
services:
  homeassistant:
    container_name: home-assistant
    image: homeassistant/home-assistant:0.110.1
    volumes:
      - /home/$USER/hass/docker_files/homeassistant/config:/config
    environment:
      - TZ=America/New_York
    restart: always
    network_mode: host
  appdaemon:
    depends_on:
      - homeassistant
    container_name: appdaemon
    image: acockburn/appdaemon:4.0.3
    volumes:
      - /home/$USER/hass/docker_files/appdaemon:/conf
    ports:
      - 5050:5050
    restart: always

This is the appdaemon.yaml

appdaemon:
  time_zone: "America/New_York"
  latitude: !secret latitude
  longitude: !secret longitude
  elevation: !secret elevation
  title: Test
  status_update: none

  plugins:
    HASS:
      type: hass
      ha_url: "http://localhost:8123"
      token: !secret token
hadashboard:
  dashboard_dir: ./dashboards
http:
  url: http://127.0.0.1:5050
  password: !secret ad_password
api:
admin:

The issue I’m having is that when I try to run both HA and AD using docker compose I keep getting connection errors.

appdaemon        | 2020-05-23 08:03:55.389055 INFO AppDaemon: AppDaemon Version 4.0.3 starting
appdaemon        | 2020-05-23 08:03:55.389186 INFO AppDaemon: Python version is 3.8.2
appdaemon        | 2020-05-23 08:03:55.389255 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml
appdaemon        | 2020-05-23 08:03:55.389317 INFO AppDaemon: Added log: AppDaemon
appdaemon        | 2020-05-23 08:03:55.389415 INFO AppDaemon: Added log: Error
appdaemon        | 2020-05-23 08:03:55.389502 INFO AppDaemon: Added log: Access
appdaemon        | 2020-05-23 08:03:55.389602 INFO AppDaemon: Added log: Diag
appdaemon        | 2020-05-23 08:03:55.400465 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
appdaemon        | 2020-05-23 08:03:55.406492 INFO HASS: HASS Plugin Initializing
appdaemon        | 2020-05-23 08:03:55.406638 INFO HASS: HASS Plugin initialization complete
appdaemon        | 2020-05-23 08:03:55.406979 INFO AppDaemon: Initializing HTTP
appdaemon        | 2020-05-23 08:03:55.407238 INFO AppDaemon: Using 'ws' for event stream
appdaemon        | 2020-05-23 08:03:55.414304 INFO AppDaemon: Starting API
appdaemon        | 2020-05-23 08:03:55.416407 INFO AppDaemon: Starting Admin Interface
appdaemon        | 2020-05-23 08:03:55.416636 INFO AppDaemon: Starting Dashboards
appdaemon        | 2020-05-23 08:03:55.419098 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
appdaemon        | 2020-05-23 08:03:55.423195 INFO AppDaemon: App 'hello_world' added
appdaemon        | 2020-05-23 08:03:55.423767 INFO AppDaemon: Found 1 total apps
appdaemon        | 2020-05-23 08:03:55.424042 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
appdaemon        | 2020-05-23 08:03:55.424696 INFO AppDaemon: Running on port 5050

appdaemon        | 2020-05-23 08:04:40.001883 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
appdaemon        | 2020-05-23 08:04:45.004781 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds

But if I run AD from the comand line using the same configuration file, it works correctly:

$ appdaemon -c /home/$USER/hass/docker_files/appdaemon

2020-05-23 07:05:42.027019 INFO AppDaemon: AppDaemon Version 4.0.3 starting
2020-05-23 07:05:42.027135 INFO AppDaemon: Python version is 3.7.7
2020-05-23 07:05:42.027219 INFO AppDaemon: Configuration read from: /home/user/hass/docker_files/appdaemon/appdaemon.yaml
2020-05-23 07:05:42.027303 INFO AppDaemon: Added log: AppDaemon
2020-05-23 07:05:42.027395 INFO AppDaemon: Added log: Error
2020-05-23 07:05:42.027478 INFO AppDaemon: Added log: Access
2020-05-23 07:05:42.027560 INFO AppDaemon: Added log: Diag
2020-05-23 07:05:42.034421 WARNING AppDaemon: config_dir: /home exists, but is not writeable, owner: root
2020-05-23 07:05:42.035766 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2020-05-23 07:05:42.041046 INFO HASS: HASS Plugin Initializing
2020-05-23 07:05:42.041191 INFO HASS: HASS Plugin initialization complete
2020-05-23 07:05:42.041403 INFO AppDaemon: Initializing HTTP
2020-05-23 07:05:42.041576 INFO AppDaemon: Using 'ws' for event stream
2020-05-23 07:05:42.047168 INFO AppDaemon: Starting API
2020-05-23 07:05:42.049315 INFO AppDaemon: Starting Admin Interface
2020-05-23 07:05:42.049485 INFO AppDaemon: Starting Dashboards
2020-05-23 07:05:42.050009 WARNING AppDaemon: css: /home exists, but is not writeable, owner: root
2020-05-23 07:05:42.050586 WARNING AppDaemon: javascript: /home exists, but is not writeable, owner: root
2020-05-23 07:05:42.056007 INFO HASS: Connected to Home Assistant 0.110.1
2020-05-23 07:05:42.069887 INFO AppDaemon: App 'hello_world' added
2020-05-23 07:05:42.070366 INFO AppDaemon: Found 1 total apps
2020-05-23 07:05:42.070586 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2020-05-23 07:05:42.081352 INFO AppDaemon: Running on port 5050
2020-05-23 07:05:42.088983 INFO HASS: Evaluating startup conditions
2020-05-23 07:05:42.093506 INFO AppDaemon: Got initial state from namespace default
2020-05-23 07:05:44.084011 INFO AppDaemon: Scheduler running in realtime
2020-05-23 07:05:44.085467 INFO AppDaemon: Adding /home/user/hass/docker_files/appdaemon/apps to module import path
2020-05-23 07:05:44.086507 INFO AppDaemon: Loading App Module: /home/user/hass/docker_files/appdaemon/apps/hello.py
2020-05-23 07:05:44.088251 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2020-05-23 07:05:44.114133 INFO hello_world: Hello from AppDaemon
2020-05-23 07:05:44.114580 INFO hello_world: You are now ready to run Apps!

I was wondering if anyone can help me find what I’m missing or what I’m doing wrong.

Your HA container runs in “host” network mode, so share the IP setting of the whole device.
The appdaemon one doesn’t specify anything, so runs in “bridge” mode, and live in another network space.

Bottom-line ha_url: "http://localhost:8123 won’t work. You have to specify the IP or hostname of the VM.

That did it. Thanks!

I’m having a very similar issue, but I am specifying http://<ip_address>:8123 for ha_url, yet AD is unable to connect. My HA docker container is running on host and AD on the bridge network. AD does work if I launch it with network mode set to host (which suggests a Docker-related network issue); however, I’d rather avoid this unless necessary. Any pointers? Do you mind sharing your updated docker-compose file?