ha-samsungtv-tizen icon indicating copy to clipboard operation
ha-samsungtv-tizen copied to clipboard

SmartThings Update Sometimes Fails

Open Krocko opened this issue 4 years ago • 15 comments

Hi @jaruba. Can you tell me something about this error?

Logger: homeassistant.helpers.entity
Source: custom_components/samsungtv_tizen/smartthings.py:40 
First occured: 18:23:57 (122 occurences) 
Last logged: 19:16:16

Update for media_player.samsung_tv_remote fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, 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/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 357, in update
    smartthings.device_update(self)
  File "/config/custom_components/samsungtv_tizen/smartthings.py", line 40, in device_update
    data = resp.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.7/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)

Krocko avatar Mar 13 '20 18:03 Krocko

Looks like this: https://github.com/jaruba/ha-samsungtv-tizen/issues/29

jaruba avatar Mar 13 '20 18:03 jaruba

Mhhh ok. For me it was working without problems. I have nothing changed. Also now the integration is working despite the error. Btw. i am on ha 0.107.0b1.

Krocko avatar Mar 13 '20 18:03 Krocko

I've seen that error many times before, it's always the same problem. Your SmartThings API key and / or device id is wrong, create a new key, double (triple) check that you're using the correct device id (not network device id).

jaruba avatar Mar 13 '20 18:03 jaruba

I think it is something else. The device id is correct and i generated several new api tokens. Still the same problem. Can it be the (new) updated samsung integration in 0.107.0b1 that interference with your custom component?

Krocko avatar Mar 13 '20 18:03 Krocko

It will be hard for u to convince me it's not the wrong api key / device id, many said it's not that and it was that.

jaruba avatar Mar 13 '20 19:03 jaruba

I understand. But believe me, that was working the hole time.

Krocko avatar Mar 13 '20 19:03 Krocko

There is resp.json() in your error thread, this means that the request to the SmartThings API (to update data) is made, but the response is not in JSON format. This can happen only if the api key / device id is wrong, if SmartThings changed their API or if you can't do basic http(s) requests anymore with HA 0.107.0b1. The most probable of these 3 (by far) is that your api key / device id is wrong.

jaruba avatar Mar 13 '20 19:03 jaruba

Could it be an error on the api side? Because the states don‘t update on the smartthings website.

Krocko avatar Mar 13 '20 19:03 Krocko

I guess, if the SmartThings API servers went down temporarily.

jaruba avatar Mar 13 '20 19:03 jaruba

Now it is working again and I have done nothing. So i think it was on the smartthings api side.

Krocko avatar Mar 13 '20 19:03 Krocko

Happy it's working.

jaruba avatar Mar 13 '20 19:03 jaruba

@jaruba i must reopen this issue. Sometime it is working sometime not. So i don't think it is a wrong api key. Maybe this has something to do with this problem? https://github.com/home-assistant/core/pull/32810

Have you a chance to test with home assistant version 0.107.0 beta?

Krocko avatar Mar 15 '20 12:03 Krocko

Maybe it is related to that, but if it's a HA issue I can't fix it.

Also, no, I'm using HA 0.105.2, I can't update HA frequently, it would be a full time job to keep all my components running correctly after each update.

jaruba avatar Mar 15 '20 12:03 jaruba

I would of expected more people to announce this problem if it was a HA issue though.

jaruba avatar Mar 15 '20 12:03 jaruba

Ok. Will wait until 0.107 is official released. If the problem then still persists I will open a bug report on the ha repo.

Krocko avatar Mar 15 '20 18:03 Krocko