nstrelow / ha_philips_android_tv

Home Assistant custom component for the newer (2016+) Philips Android TVs
109 stars 28 forks source link

State doesn't change en some errors #15

Closed frerejean closed 5 years ago

frerejean commented 5 years ago

Hello,

I get this error, and it`s not possible to get a state. I use my tv only with Chromecast and don't use the television options. In a previous version (don't know exactly which version) everything did work.

Update for media_player.philips_tv fails Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state await self.async_device_update() File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 377, 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/local/lib/python3.7/site-packages/homeassistant/util/init.py", line 224, in wrapper result = method(args, **kwargs) File "/config/custom_components/philips_android_tv/media_player.py", line 244, in update self._tv.update() File "/config/custom_components/philips_android_tv/media_player.py", line 336, in update self.get_channels() File "/config/custom_components/philips_android_tv/media_player.py", line 379, in get_channels r = self._get_req('channeldb/tv/channelLists/all') File "/config/custom_components/philips_android_tv/media_player.py", line 302, in _get_req return json.loads(resp.text) File "/usr/local/lib/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

nstrelow commented 5 years ago

I cannot help you with this error log. Somehow the response you are getting from the TV is empty.

I would advice you to use the cromecast integration instead, I think it can do all the things you want and more.

frerejean commented 5 years ago

I think I get this error because I don't have configure the TV Channels on my Philips. When I go to the page: https://iptv:1926/6/channeldb/tv/channelLists/all I get an Internal Server Error

My solution: Today I have delete everything with get_channels and it will work. No more errors

Feature Request: Is it possible to add a configuration item that disable get_channels?

nstrelow commented 5 years ago

In my latest commit I added a way to catch the error you were having. This should stop the component from dying, when something like an internal server error occurs.

It also prints to the log, which method is actually failing and what the response actually was, so you can report that and your TV model instead of having just the JSONDecodeError.

https://github.com/nstrelow/ha_philips_2016/commit/4375154dae6b1e7d87e4413e957d2d6e89de6bfe https://github.com/nstrelow/ha_philips_2016/commit/0fde7feec5a0f6cafea3acbf16918cdc79dc23ab

frerejean commented 5 years ago

Thank you for this solution. I tested it and it works better for me than my own solution ;-)

nstrelow commented 5 years ago

@frerejean Awesome! Could you share the logs you get? I would like to know which API is not working and what it returns.

There are two logs:

frerejean commented 5 years ago

I can only find the following logging:

I look at "i" under developer tools, where can I find more logging?

nstrelow commented 5 years ago

message first occured at 14:35 and shows up 352 times**

This is worrying 🙈, might spam the log

Yeah, the second message is logged under the info tag. You have to adapt your config to see it.

Add default: info to logger like here: https://www.home-assistant.io/components/logger/

logger: default: info

nstrelow commented 5 years ago

And what's your TV model? So that we can document which API is working and which is not

frerejean commented 5 years ago

it succeeded, this is the logging:

019-06-14 20:16:01 WARNING (SyncWorker_8) [custom_components.philips_android_tv.media_player] TV is not returning JSON. Either the authentification failed or your TV does not support calling channeldb/tv/channelLists/all. 2019-06-14 20:16:01 INFO (SyncWorker_8) [custom_components.philips_android_tv.media_player] Response of TV:

Status page

Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request

You can get technical details here.
Please continue your visit at our home page.


Result of the url: https://iptv/6/system

{"menulanguage":"Dutch","name":"32PFK5500\/12","country":"Netherlands","serialnumber_encrypted":"0Gz--------------------7uk1XT7L6J2h36egGUUk=\n","softwareversion_encrypted":"NXB0Z--------------------IW47jpnVqlI55ggl+w=\n","model_encrypted":"qObdV7--------------------GNWzM3xT\/PyQF0wRg=\n","deviceid_encrypted":"wBl0vJo--------------------mTnWQRmw\/rX+etHbM=\n","nettvversion":"","epgsource":"one","api_version":{"Major":6,"Minor":1,"Patch":1},"featuring":{"jsonfeatures":{"editfavorites":["TVChannels","SatChannels"],"recordings":["List","Schedule","Manage"],"ambilight":["LoungeLight"],"menuitems":["Setup_Menu"],"textentry":["context_based","initial_string_available","editor_info_available"],"applications":["TV_Apps","TV_Games","TV_Settings"],"pointer":["not_available"],"inputkey":["key"],"activities":["intent"]},"systemfeatures":{"tvtype":"consumer","content":["dmr","dms_tad"],"tvsearch":"intent","pairing_type":"digest_auth_pairing","secured_transport":"true"}}}

nstrelow commented 5 years ago

This will probably not be fixable, since it is a problem on the API side. Therefore I will close it.