BigNocciolino / CryptoTracker

Integration for Home Assistant to implement a crypto tracking system
23 stars 4 forks source link

Stopped working after HA 2021.12.2 #11

Closed GazTheGeek closed 2 years ago

GazTheGeek commented 2 years ago

I updated to HA 2021.12.2 and the entities have stopped updating. They no longer show as sensors.

Yaml:

- platform: cryptostate
  resources:
    - compare: btc-aud
      name: btc-aud
    - compare: eth-aud
      name: eth-aud
    - compare: ada-aud
      name: ada-aud

Logs show this error:

Logger: homeassistant.components.sensor
Source: custom_components/cryptostate/sensor.py:65 
Integration: Sensor (documentation, issues) 
First occurred: 8:05:14 AM (3 occurrences) 
Last logged: 8:05:15 AM

cryptostate: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 684, in async_device_update
    await task
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/cryptostate/sensor.py", line 140, in _update
    self._state = get_data(self._compare)
  File "/config/custom_components/cryptostate/sensor.py", line 65, in get_data
    if (resp_parsed["success"]):
TypeError: string indices must be integers
MikeshCZ commented 2 years ago

Same to me...

BigNocciolino commented 2 years ago

Hello, After some investigation and debugging, I noticed that the return code from the API request was 503.

>>> import requests
>>> import json
>>> URL = "https://api.cryptonator.com/api/ticker/btc-usd"
>>> requests.get(URL, headers={"User-Agent": "Mozilla/5.0 (Platform; Security; OS-or-CPU; Localization; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)"})
<Response [503]>
>>>

This code identifies that the API is inactive for the moment. (See: 503 code)

I will remain active in the next few days to understand, and eventually solve the problem.

Thanks for the bug report

BigNocciolino commented 2 years ago

Hello, I just checked and now the problem seems to be solved. Let me know, thanks.

GazTheGeek commented 2 years ago

Yes I needed to reboot to getting it working again. All good at the moment. Thanks for following up.