Multiple hass with AppDaemon3 beta

hi,

Appdaemon3 beta supports multiple hass instances as shown here
Has anyone tried it and got it working?
When I add a second instance the apps stop working, even though the docs say the first should get the default namespace.
I get the following in the log

2018-01-20 23:31:41.426269 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 404, in worker
    funcref(args["event"], data, args["kwargs"])
  File "/config/appdaemon/apps/hwcheck.py", line 15, in appd_event
    self.log_notify("AppDaemon is up", "INFO")
  File "/config/appdaemon/apps/hwcheck.py", line 29, in log_notify
    self.notify(msg, name="ios")
  File "/usr/lib/python3.6/site-packages/appdaemon/plugins/hass/hassapi.py", line 18, in func_wrapper
    if not self.AD.get_plugin(self._get_namespace(**kwargs)).reading_messages:
AttributeError: 'NoneType' object has no attribute 'reading_messages'

Here is my appdaemon.yaml

appdaemon:
  logfile: STDOUT
  errorfile: STDERR
  threads: 10
  app_dir: /config/appdaemon/apps
  plugins:
    HASS:
      type: hass
      ha_url: !secret ha_url
      ha_key: !secret ha_key
      namespace: default
    HASS:
      type: hass
      ha_url: !secret ha_slave_url
      ha_key: !secret ha_slave_key
      namespace: slave
HADashboard:
  dash_url: !secret dash_url
  dash_dir: /config/appdaemon/dashboards

I got it working…
I changed the namespaces to master and slave

appdaemon:
  logfile: STDOUT
  errorfile: STDERR
  threads: 10
  app_dir: /config/appdaemon/apps
  plugins:
    HASS:
      type: hass
      ha_url: !secret ha_url
      ha_key: !secret ha_key
      namespace: master
    HASS:
      type: hass
      ha_url: !secret ha_slave_url
      ha_key: !secret ha_slave_key
      namespace: slave
HADashboard:
  dash_url: !secret dash_url
  dash_dir: /config/appdaemon/dashboards

Then to run against the master hass instance added this to the app inside the def initialize

     self.set_namespace("master")

example app

import appdaemon.plugins.hass.hassapi as hass

# Args:
#

class HelloWorld(hass.Hass):

  def initialize(self):
     self.set_namespace("master")
     self.log("Hello from AppDaemon")
     self.log("You are now ready to run Apps!")

i wonder if it really works. because you have a problem in your YAML.

in this part:

  plugins:
    HASS:
      type: hass
      ha_url: !secret ha_url
      ha_key: !secret ha_key
      namespace: master
    HASS:
      type: hass
      ha_url: !secret ha_slave_url
      ha_key: !secret ha_slave_key
      namespace: slave

plugins is a dictionairy with 2 times the same key (HASS)
so this is yaml that couldnt/shouldnt work.

it should be something like:

  plugins:
    HASS_master:
      type: hass
      ha_url: !secret ha_url
      ha_key: !secret ha_key
      namespace: master
    HASS_slave:
      type: hass
      ha_url: !secret ha_slave_url
      ha_key: !secret ha_slave_key
      namespace: slave

plugins cant have the same nme twice, like app instances cant have the same name twice.

I made the suggested changes and it works.
Thanks

1 Like