Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONDecodeError in coinmarketcap component. #26410

Closed
sephrioth opened this issue Sep 4, 2019 · 13 comments
Closed

JSONDecodeError in coinmarketcap component. #26410

sephrioth opened this issue Sep 4, 2019 · 13 comments

Comments

@sephrioth
Copy link

sephrioth commented Sep 4, 2019

Home Assistant release with the issue:

v98.2

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.):

Docker

Component/platform:

sensor.coinmarketcap

Description of problem:
Can't update / setup coinmarketcap sensor

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

Traceback (if applicable):


Additional information:

Update for sensor.ethereum fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 261, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 441, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/coinmarketcap/sensor.py", line 148, in update
    self._ticker = self.data.ticker.get("data")
AttributeError: 'JSONDecodeError' object has no attribute 'get'
@springstan
Copy link
Member

Seems like that is an error on the side of the python package coinmarketcap.
It throws an exception here:
https://github.com/barnumbirr/coinmarketcap/blob/4d43a77259952b77b32cb863a4ba385ba2c35491/coinmarketcap/core.py#L36-L47
and does not handle this exception properly instead it is just returned and returned to Home Assistant.
Therefore, Home Assistant tries to access this 'JSONDecodeError' object with the get() Method and fails.
Please consider opening an issue in coinmarketcap's repo.

@sephrioth
Copy link
Author

Seems like that is an error on the side of the python package coinmarketcap.
It throws an exception here:
https://github.com/barnumbirr/coinmarketcap/blob/4d43a77259952b77b32cb863a4ba385ba2c35491/coinmarketcap/core.py#L36-L47
and does not handle this exception properly instead it is just returned and returned to Home Assistant.
Therefore, Home Assistant tries to access this 'JSONDecodeError' object with the get() Method and fails.
Please consider opening an issue in coinmarketcap's repo.

Thank you, i will open an issue there.
BTW, after I upgrade HA to v98, there are more JSON issues, for instance 26343, are these issues related?

@springstan
Copy link
Member

Of course! Hopefully this will be fixed soon.

BTW, after I upgrade HA to v98, there are more JSON issues, for instance 26343, are these issues related?

I am not quite sure to be honest, the waqi-async package seems to be connected to asyncio in some way or another. Since I have not any experience with asyncio yet I cannot really say if these issues are related or not.
Hope you understand :)

@sephrioth
Copy link
Author

@springstan Thanks for your kindly explanation, very helpful.

@springstan
Copy link
Member

@sephrioth how does your configuration for this integration look like? Trying to reproduce your issue.

@sephrioth
Copy link
Author

sephrioth commented Sep 6, 2019

@sephrioth how does your configuration for this integration look like? Trying to reproduce your issue.

Should be quite normal.. and i didn't make any changes. All coinmarketcap sensors report the same error. But sometimes when I just restart HA , it works well for about couple minutes, then the error appears.

 - platform: coinmarketcap
    currency_id: 1
    display_currency: USD
    display_currency_decimals: 2

  - platform: coinmarketcap
    currency_id: 1027
    display_currency: BTC
    display_currency_decimals: 8

  - platform: coinmarketcap
    currency_id: 2010
    display_currency: BTC
    display_currency_decimals: 8

  - platform: coinmarketcap
    currency_id: 1376
    display_currency: BTC
    display_currency_decimals: 8

  - platform: coinmarketcap
    currency_id: 1765
    display_currency: BTC
    display_currency_decimals: 8

  - platform: coinmarketcap
    currency_id: 1839
    display_currency: BTC
    display_currency_decimals: 8

@springstan
Copy link
Member

"attention": "WARNING: This API is now deprecated and will be taken offline soon.  Please switch to the new CoinMarketCap API to avoid interruptions in service. (https://pro.coinmarketcap.com/migrate/)", 

This is from the current API endpoint

I am not quite sure if this is related to your problem but it seems that this API is slowly being taken down and services should migrate over to their new API. In addition, there is a new python package for the new API but it is not used very much so that could be a reason why Home Assistant has not switched yet.

@sephrioth
Copy link
Author

@springstan Thanks for your effort on this, but I don't have a clue. Have you also got this error?

@springstan
Copy link
Member

No problem, that is okay. Unfortunately, I cannot test your configuration in my setup right now but I will get back to you as soon as I can.

@springstan
Copy link
Member

@sephrioth Yes I also have the same error so it is not just your setup.

@sephrioth
Copy link
Author

@sephrioth Yes I also have the same error so it is not just your setup.

Glad to know i am not the only one, hope they fix soon.

@stale
Copy link

stale bot commented Dec 6, 2019

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 6, 2019
@stale stale bot closed this as completed Dec 13, 2019
@metbril
Copy link

metbril commented Feb 16, 2021

Did you eventually create the issue @sephrioth? Can you refer the issue number?

#26410 (comment)

Edit: found it. barnumbirr/coinmarketcap#55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants