Appdaemon connecting issues

Hi All

I am trying to make my appdaemon to work but having SSL Cert issues. Here is my conf:

AppDaemon:
  logfile: STDOUT
  errorfile: STDERR
  logsize: 100000
  log_generations: 3
  threads: 10
  cert_path: /etc/letsencrypt/live/XXXX.duckdns.org/fullchain.pem
  cert_verify: True
  time_zone: <time zone>
  api_port: 5000
  api_key: !secret api_key
  api_ssl_certificate: '/etc/letsencrypt/live/XXXX.duckdns.org/fullchain.pem'
  api_ssl_key: '/etc/letsencrypt/live/XXXX.duckdns.org/privkey.pem'
HASS:
  ha_url: https://XXXX.duckdns.org
  ha_key: XXXX

My error log is :

 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
 INFO Keyboard interrupt
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 329, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/local/lib/python3.6/ssl.py", line 814, in __init__
    self.do_handshake()
  File "/usr/local/lib/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/local/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘XXXX.duckdns.org', port=443): Max retries exceeded with url: /api/config (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),))

@ReneTode Can you please help?

Thank you.

I am not saying that your path to the cert file are wrong and I don’t know what platform you are using, but I don’t see why you would have the xxxx.duckdns.org in the path. All I have is ssl_certificate: /ssl/fullchain.pem
** ssl_key: /ssl/privkey.pem** using HASSIO.

i dont know if you want to use the appdaemon api (to reach appdaemon with api calls, but if not i would remove those parts at first.

to be able to help i need more info:

  1. logfiles from the moment AD is started.
  2. on which platform did you install AD and how?
  3. is the url you povide beneath HASS exactly as you use it in the browser? and the password also?
  1. Can you please tell me where the log file is?
  2. I have installed it on Hassbian via the pip method
  3. That is the URL to my HA and the password

@carbuthn Thats my path to my ssl_certificate (just checked it and the certs) I know its weird but thats how it was created when I had installed it.

your logfiles now go to STDOUT and STDERR
if you dont know how to get the information from that, then set those options to logfile names on a place where appdaemon has full access.
restart appdaemon and see what is in the logs. (including the first lines which tells which version you have installed)

Right i have changed the logfile and have access if I run via sudo appdaemon -c /home/homeassistant/conf

Nothing happens and I stop it by the keyboard i.e. CTRL + C

My appdaemon.log file shows the following:
2018-02-06 11:52:12.117013 INFO AppDaemon Version 2.1.12 starting
2018-02-06 11:52:12.118363 INFO Configuration read from: /home/homeassistant/conf/appdaemon.yaml
2018-02-06 11:52:12.394307 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:52:17.583656 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:52:22.896318 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:52:28.227394 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:52:33.533472 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:52:38.837380 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:52:39.595325 INFO Keyboard interrupt
2018-02-06 11:54:08.743454 INFO AppDaemon Version 2.1.12 starting
2018-02-06 11:54:08.744819 INFO Configuration read from: /home/homeassistant/conf/appdaemon.yaml
2018-02-06 11:54:09.043367 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:54:14.312785 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:54:19.592619 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:54:24.717934 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:54:29.992351 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:54:35.285032 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2018-02-06 11:54:40.425090 WARNING Unable to connect to Home Assistant, retrying in 5 seconds

My error log file doesnt contain anything.

However when I hit CTRL + C, i get the following errors:

^CTraceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 329, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/usr/local/lib/python3.6/ssl.py", line 814, in __init__
    self.do_handshake()
  File "/usr/local/lib/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/local/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='XXXX.duckdns.org', port=443): Max retries exceeded with url: /api/config (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/admain.py", line 422, in main
    ha_config = utils.get_ha_config()
  File "/usr/local/lib/python3.6/site-packages/appdaemon/utils.py", line 347, in get_ha_config
    r = requests.get(apiurl, headers=headers, verify=conf.certpath)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 506, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='XXXX.duckdns.org', port=443): Max retries exceeded with url: /api/config (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/appdaemon", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/appdaemon/admain.py", line 432, in main
    time.sleep(5)
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 122, in handle_sig
    stopit()
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 108, in stopit
    conf.appq.put_nowait({"event_type": "ha_stop", "data": None})
AttributeError: 'NoneType' object has no attribute 'put_nowait'

oke you have 2.1.12 running and use the commandline like i do.
i would try to change your appdaemon.yaml to this:

AppDaemon:
  logfile: STDOUT
  errorfile: STDERR
  logsize: 100000
  log_generations: 3
  threads: 10
  #cert_path: /etc/letsencrypt/live/XXXX.duckdns.org/fullchain.pem
  #cert_verify: True
  #time_zone: <time zone>
  #api_port: 5000
  #api_key: !secret api_key
  #api_ssl_certificate: '/etc/letsencrypt/live/XXXX.duckdns.org/fullchain.pem'
  #api_ssl_key: '/etc/letsencrypt/live/XXXX.duckdns.org/privkey.pem'
HASS:
  ha_url: https://XXXX.duckdns.org
  ha_key: XXXX
1 Like

ok that works but hello.py throws errors:

my appdaemon.log file:

2018-02-06 12:16:04.583200 INFO AppDaemon Version 2.1.12 starting
2018-02-06 12:16:04.584460 INFO Configuration read from: /home/homeassistant/conf/appdaemon.yaml
2018-02-06 12:19:48.687931 INFO AppDaemon Version 2.1.12 starting
2018-02-06 12:19:48.689139 INFO Configuration read from: /home/homeassistant/conf/appdaemon.yaml
2018-02-06 12:19:49.344986 INFO Starting Apps
2018-02-06 12:19:49.926638 INFO Got initial state
2018-02-06 12:19:49.929185 INFO Loading Module: /home/homeassistant/conf/apps/hello.py
2018-02-06 12:19:49.954247 WARNING Logged an error to /home/homeassistant/error.log
2018-02-06 12:19:49.954948 INFO App initialization complete
2018-02-06 12:19:49.956170 INFO Dashboards are disabled
2018-02-06 12:19:49.956850 INFO API is disabled
2018-02-06 12:19:50.534796 INFO Connected to Home Assistant 0.62.1
2018-02-06 12:19:51.001651 WARNING Scheduler clock skew detected - delta = 1.001528024673462 - resetting
2018-02-06 12:20:43.792863 INFO Keyboard interrupt
2018-02-06 12:20:43.829021 INFO Disconnecting from Home Assistant
2018-02-06 12:20:44.007608 INFO AppDeamon Exited

and the error.log is :

2018-02-06 12:19:49.940425 WARNING ------------------------------------------------------------
2018-02-06 12:19:49.941443 WARNING Unexpected error during loading of hello.py:
2018-02-06 12:19:49.942136 WARNING ------------------------------------------------------------
2018-02-06 12:19:49.952409 WARNING Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 901, in read_app
    conf.modules[module_name] = importlib.import_module(module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/homeassistant/conf/apps/hello.py", line 1, in <module>
    import appdaemon.plugins.hass.hassapi as hass
ModuleNotFoundError: No module named 'appdaemon.plugins'

2018-02-06 12:19:49.953482 WARNING ------------------------------------------------------------

Right @ReneTode I think its working now when I hit sudo appdaemon -c /home/homeassistant/conf but nothing happens on my screen until I cancel it via the keyboard i.e. CTRL + C

This is what I mean :

Also where am I meant to be getting the results when I hit the above command because my results are saved in the appdaemon.log file which is this after running the command:

2018-02-06 13:50:12.130075 INFO AppDaemon Version 2.1.12 starting
2018-02-06 13:50:12.135714 INFO Configuration read from: /home/homeassistant/conf/appdaemon.yaml
2018-02-06 13:50:13.216518 INFO Starting Apps
2018-02-06 13:50:14.056698 INFO Got initial state
2018-02-06 13:50:14.071505 INFO Loading Module: /home/homeassistant/conf/apps/hello.py
2018-02-06 13:50:14.079791 INFO Loading Object hello_world using class HelloWorld from module hello
2018-02-06 13:50:14.633667 INFO hello_world: Hello from AppDaemon
2018-02-06 13:50:14.639878 INFO hello_world: You are now ready to run Apps!
2018-02-06 13:50:14.640730 INFO App initialization complete
2018-02-06 13:50:14.642373 INFO Dashboards are disabled
2018-02-06 13:50:14.643120 INFO API is disabled
2018-02-06 13:50:15.180451 INFO Connected to Home Assistant 0.62.1
2018-02-06 13:50:16.001708 WARNING Scheduler clock skew detected - delta = 1.0015769004821777 - resetting
2018-02-06 13:50:49.374896 INFO Keyboard interrupt
2018-02-06 13:50:49.407530 INFO Disconnecting from Home Assistant
2018-02-06 13:50:50.008522 INFO AppDeamon Exited

which results do you mean?

you have now succesfully installed appdaemon, so you can write apps that work with home assistant or you can enable dashboard and create dashboards.

on its own does appdaemon nothing.

you can use the logs or your terminalscreen to get the output from appdaemon.
i got errorlog as a file and logfiles as stdout (to the screen) so that i can monitor what is happening.

so on my screen when I run sudo appdaemon -c /home/homeassistant/conf nothing happens i.e. the command takes forever and there is no output as you can see in the image i uploaded earlier.

I was hoping some output on my terminalscreen like this:

like i said then you have to change back to

logfile: STDOUT

oh right ok let me do that thanks.

but you still wont get more output then that untill you start writing apps :wink:

1 Like