krocat / ToonHA

Home-Assistant component for Toon by Eneco

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

invalid config if API is not available

scheric opened this issue · comments

Wen Home Assistant cant fetch data from the API home assistant gives an error and shows Invalid config.

Home Assistant can then only discover toon when a new reboot happened and the API is available.

I can fetch data from my toon to Home Assistant. So my configuration is probably alright but if there is a hiccup at boot everything fails.
prob2

as you can see that if toon fails to set up properly it conflict with the discovery of a lot of other components.

these are all errors that popup at boot
prob1

Could this be the toon API not being strong enough to make a connection with my Home Assistant or it this because my toon cant push al the data to the toon servers?
Or is there something wrong in the code?

Thu Apr 12 2018 17:09:29 GMT+0200 (West-Europa (zomertijd))

Error doing job: Task exception was never retrieved

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/discovery.py", line 133, in scan_devices
    results = await hass.async_add_job(_discover, netdisco)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/discovery.py", line 161, in _discover
    for disc in netdisco.discover():
  File "/usr/lib/python3.6/site-packages/netdisco/discovery.py", line 92, in discover
    return [dis for dis, checker in self.discoverables.items()
  File "/usr/lib/python3.6/site-packages/netdisco/discovery.py", line 93, in <listcomp>
    if checker.is_discovered()]
  File "/usr/lib/python3.6/site-packages/netdisco/discoverables/__init__.py", line 17, in is_discovered
    return len(self.get_entries()) > 0
  File "/usr/lib/python3.6/site-packages/netdisco/discoverables/huawei_router.py", line 12, in get_entries
    "deviceType": "urn:schemas-upnp-org:device:InternetGatewayDevice:1"
  File "/usr/lib/python3.6/site-packages/netdisco/discoverables/__init__.py", line 73, in find_by_device_description
    return self.netdis.ssdp.find_by_device_description(values)
  File "/usr/lib/python3.6/site-packages/netdisco/ssdp.py", line 74, in find_by_device_description
    if location not in seen and entry.match_device_description(values):
  File "/usr/lib/python3.6/site-packages/netdisco/ssdp.py", line 172, in match_device_description
    device = self.description.get('device')
  File "/usr/lib/python3.6/site-packages/netdisco/ssdp.py", line 143, in description
    xml = requests.get(url, timeout=5).text
  File "/config/deps/lib/python3.6/site-packages/toonapilib/toonapilib.py", line 237, in _patched_request
    if response.status_code == 401 and response.json().get('fault', {}).get(
  File "/usr/lib/python3.6/site-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.6/site-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

After i restarted Home Assistant a few times in a period of an hour i got data from toon again.
but the errors stay.

Wat i tried to get it working

  1. Remove toon setting in the configuration.yaml
  2. Deleting custom_components folder and reinstall everything
  3. Deleting the toonlib at \deps\lib\python3.6\site-packages and deleting files that are created by toonlib at \deps

After every change i did i did a reboot no susses at time of writing.

Wen i remove toon from configuration.yaml and leave everything as is the errors disappear and I get the automated discovery system back (for chrome cast and other stuff).

What could possibly be a solution for this?

This problem is not created by this code it is the toonapilib from: https://github.com/costastf/toonapilib
Look at issue: costastf/toonapilib#8