HADashboard server error 500

Hi!

Trying to install HADashboard to see what all the fuss is about. :slight_smile: But I run into an issue when AppDaemon is started. I was getting no connection at all from my browser but after doing some searching I scaled back on the SSL-certificates and other extras just to see what’s going on. Now I get error 500 when connecting and some logs from the terminal.

Let’s dive in!

So I followed this guide to install HADashboard and AppDAemon. When I start AppDaemon I get:

pi@raspberrypi:~ $ appdaemon -c /home/homeassistant/conf
2017-09-24 17:27:49.382345 INFO AppDaemon Version 2.1.9 starting
2017-09-24 17:27:49.382855 INFO Configuration read from: /home/homeassistant/conf/appdaemon.yaml
2017-09-24 17:27:49.806748 INFO Starting Apps
2017-09-24 17:27:50.113574 INFO Got initial state
2017-09-24 17:27:50.114905 INFO Loading Module: /home/homeassistant/conf/apps/hello.py
2017-09-24 17:27:50.120665 INFO Loading Object hello_world using class HelloWorld from module hello
2017-09-24 17:27:50.293972 INFO hello_world: Hello from AppDaemon
2017-09-24 17:27:50.296674 INFO hello_world: You are now ready to run Apps!
2017-09-24 17:27:50.297118 INFO App initialization complete
2017-09-24 17:27:50.297699 INFO Starting dashboard
2017-09-24 17:27:50.315006 INFO Starting API
2017-09-24 17:27:50.498448 INFO Connected to Home Assistant 0.53.0

Looks good right?

If I load http://my.host:5050 I get the 500 error and the following from the terminal:

Traceback (most recent call last):
File “/usr/local/lib/python3.4/dist-packages/aiohttp/web_protocol.py”, line 422, in start
resp = yield from self._request_handler(request)
File “/usr/local/lib/python3.4/dist-packages/aiohttp/web.py”, line 312, in _handle
[middleware for middleware in app.middlewares
AssertionError: Handler <function secure..wrapper at 0x756c6738> should return response instance, got <class ‘dict’> [middlewares ]

So, what’s going on here? What did I miss?

do you have a dashboard made?
how does it look? and where did you put it?

Is that the entire error? None of that is in AppDaemon code so it’s hard to know what is going on 


Thanks!

I used the standard dashboard from the guide. I put it in the dashboards folder in conf.

Is there a way I can supply more errors on what’s going on here? What throws me is that on start, it’s all peachy until I try to load.

This is my appdaemon.yaml:

AppDaemon:
  logfile: STDOUT
  errorfile: STDERR
  logsize: 100000
  log_generations: 3
  threads: 10
  time_zone: Europe/Stockholm
  api_port: 5000
  api_key: passwd
HASS:
  ha_url: https://my.host:8123
  ha_key: passwd
HADashboard:
  dash_url: http://my.host:5050
  dash_password: passwd

Hi,

I’m just getting started with HADashboard and got the same error. My configuration is basically the same as yours except for using !secret.

If I remove the dash_password configuration line the error is gone.

Perhaps someone with more knowledge about HADashboard can investigate more from here.

1 Like

Thanks!

That made the Dashbaords load as expected and I can carry on my testing. But it would be good for both of us to find out what’s up.

Thanks again för sharing!

I’m in the middle of a rewrite for portions of AD - when that’s done I’ll revisit and see whats up!

1 Like

Just had the exact same problem. Removing the “dash_password:” solved it for me. Mostly the same error:

2017-10-04 22:15:32.622031 INFO AppDaemon Version 2.1.9 starting
2017-10-04 22:15:32.622253 INFO Configuration read from: /home/kennhard/.homeassistant/conf/appdaemon.yaml
2017-10-04 22:15:32.715359 INFO Starting Apps
2017-10-04 22:15:32.779909 INFO Got initial state
2017-10-04 22:15:32.780490 INFO App initialization complete
2017-10-04 22:15:32.780675 INFO Starting dashboard
2017-10-04 22:15:32.784094 INFO Starting API
2017-10-04 22:15:32.797693 INFO Connected to Home Assistant 0.54.0
Error handling request
Traceback (most recent call last):
  File "/home/kennhard/.local/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/home/kennhard/.local/lib/python3.5/site-packages/aiohttp/web.py", line 312, in _handle
    [middleware for middleware in app.middlewares
AssertionError: Handler <function secure.<locals>.wrapper at 0x7fa7fad8f488> should return response instance, got <class 'dict'> [middlewares []]
Error handling request
Traceback (most recent call last):
  File "/home/kennhard/.local/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/home/kennhard/.local/lib/python3.5/site-packages/aiohttp/web.py", line 312, in _handle
    [middleware for middleware in app.middlewares
AssertionError: Handler <function secure.<locals>.wrapper at 0x7fa7fad8f158> should return response instance, got <class 'dict'> [middlewares []]
Error handling request
Traceback (most recent call last):
  File "/home/kennhard/.local/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/home/kennhard/.local/lib/python3.5/site-packages/aiohttp/web.py", line 312, in _handle
    [middleware for middleware in app.middlewares
AssertionError: Handler <function secure.<locals>.wrapper at 0x7fa7fad8f158> should return response instance, got <class 'dict'> [middlewares []]

I’m having the exact same issue. Where you ever able to get it working?

Well, No.

But removing the password is a decent workaround.

Just stumbled upon this. Finished a fresh install just on armbian and I have exactly the same issue. The internal server 500 error disappears if you remove the “dash_password” line. For now I can just block 5050 in the firewall but it would be great to be able to put a password on it.

Thanks, I’m currently using that work around however, I was just wondering if anyone got it working as I would like to make it accessible outside of the network.

Andrew is working on a big update project at the moment.
i am sure thats also on his list of points to do.

1 Like

Thanks ReneTode. All in good time :slight_smile: it is a great project though, excited for new updates.

1 Like

I fixed this locally on my installation.

Not seeing anywhere where I can contribute fixes officially, but if someone let me know where I can do that, I’ll be happy to submit the fixes there.

In the meantime, for those who are interested, below are the lines you can update in the directory /usr/local/lib/python3.5/dist-packages/appdaemon (this is where my files are in raspbian; your exact directory may vary).

Hope this helps some folks out there so you can turn on the dashboard password again. :slight_smile:

In rundash.py (line 70)

change

def forcelogon(request):
    return {"logon": 1}

to

def forcelogon(request):
    response = yield from utils.run_in_executor(conf.loop, conf.executor, conf.dashboard_obj.get_dashboard_list, {"logon": 1})
    return web.Response(text=response, content_type="text/html")

In dashboard.py (line 834)

change from

def get_dashboard_list(self):

    dash = self._list_dashes()

    env = Environment(
        loader=FileSystemLoader(self.template_dir),
        autoescape=select_autoescape(['html', 'xml'])
    )

    template = env.get_template("dashboard.jinja2")
    rendered_template = template.render(dash)

    return(rendered_template)

to

def get_dashboard_list(self, paramOverwrite=None):

if paramOverwrite is None:
    dash = self._list_dashes()
else:
    dash = paramOverwrite

env = Environment(
    loader=FileSystemLoader(self.template_dir),
    autoescape=select_autoescape(['html', 'xml'])
)

template = env.get_template("dashboard.jinja2")
rendered_template = template.render(dash)

return(rendered_template)

Hi there @wchan.ranelagh - thanks for looking into this - I would be happy if you would create a pull request against the appdaemon repository :slight_smile:

When you do that I’ll merge it and put out a new version - I just haven’t had time to look at this because of the refactor I’m working on so this would be a great help.

EDIT: Never mind - I just copied it over and will be releasing a new version shortly.

1 Like