home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.82k stars 30.08k forks source link

Philips TV goes to Off status #88264

Closed andrewjswan closed 4 months ago

andrewjswan commented 1 year ago

The problem

I turn on the TV (connected via Lan, the address is static), the media player in HA turns on, and after a while it turns off. Turned on the debugging in the log, I do not see anything special. But in the previous log there were warnings.

What version of Home Assistant Core has the issue?

core-2023.2.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Philips TV

Link to integration documentation on our website

https://www.home-assistant.io/integrations/philips_js/

Diagnostics information

{"notifyChange":"http","menulanguage":"Ukrainian","name":"55PFL7008","country":"Ukraine","serialnumber_encrypted":"...","softwareversion_encrypted":"...","model_encrypted":"...","deviceid_encrypted":"...","nettvversion":"8.1.0","epgsource":"one","api_version":{"Major":6,"Minor":2,"Patch":0},"featuring":{"jsonfeatures":{"editfavorites":["TVChannels","SatChannels"],"recordings":["List","Schedule","Manage"],"ambilight":["LoungeLight","Hue","Ambilight"],"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"],"channels":["preset_string"],"mappings":["server_mapping"]},"systemfeatures":{"tvtype":"consumer","content":["dmr","dms_tad"],"tvsearch":"intent","pairing_type":"digest_auth_pairing","secured_transport":"true"}}}

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-02-16 19:48:04.117 WARNING (MainThread) [homeassistant.components.philips_js] Failed to fetch image
2023-02-16 19:48:04.207 WARNING (MainThread) [homeassistant.components.philips_js] Failed to fetch image
2023-02-16 19:48:04.228 WARNING (MainThread) [homeassistant.components.philips_js] Failed to fetch image
2023-02-16 19:48:09.129 WARNING (MainThread) [homeassistant.components.philips_js] Failed to fetch image
2023-02-16 19:48:09.216 WARNING (MainThread) [homeassistant.components.philips_js] Failed to fetch image
2023-02-16 19:48:09.248 WARNING (MainThread) [homeassistant.components.philips_js] Failed to fetch image
... A lot of lines like this ...
2023-02-16 19:49:19.584 WARNING (MainThread) [homeassistant.components.philips_js] Failed to fetch image
2023-02-16 19:49:24.338 WARNING (MainThread) [homeassistant.components.philips_js] Failed to fetch image
2023-02-16 19:49:24.341 WARNING (MainThread) [homeassistant.components.philips_js] Failed to fetch image
...
2023-02-16 19:52:39.220 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.553 seconds (success: True)
2023-02-16 19:52:44.197 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 8.528 seconds (success: True)
2023-02-16 19:53:12.447 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.095 seconds (success: True)
... A lot of lines like this ...
2023-02-16 19:57:06.386 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 5.030 seconds (success: True)
2023-02-16 19:57:37.528 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 4.175 seconds (success: True)
2023-02-16 19:57:42.543 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 5.048 seconds (success: True)
2023-02-16 19:58:05.286 ERROR (Thread-9) [pychromecast.socket_client] [55PFL7008(192.X.X.X):8009] Failed to connect to service ServiceInfo(type='mdns', data='QM164E-fc539c268d1a8889d09eafcb0ba6e200._googlecast._tcp.local.'), retrying in 5.0s
2023-02-16 19:58:10.431 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.060 seconds (success: True)
2023-02-16 19:58:16.447 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 4.088 seconds (success: True)
2023-02-16 19:58:43.454 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.101 seconds (success: True)
... A lot of lines like this ...
2023-02-16 20:04:10.654 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.302 seconds (success: True)
2023-02-16 20:04:13.439 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.086 seconds (success: True)
2023-02-16 20:04:41.034 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 0.682 seconds (success: True)
2023-02-16 20:04:46.462 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.110 seconds (success: True)
2023-02-16 20:05:12.016 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 0.661 seconds (success: True)
2023-02-16 20:05:19.422 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.070 seconds (success: True)
2023-02-16 20:05:43.103 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 0.752 seconds (success: True)
2023-02-16 20:05:52.446 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.095 seconds (success: True)
2023-02-16 20:06:14.013 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 0.662 seconds (success: True)
2023-02-16 20:06:25.407 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.055 seconds (success: True)
2023-02-16 20:06:45.485 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 1.133 seconds (success: True)
2023-02-16 20:06:58.430 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.079 seconds (success: True)
2023-02-16 20:07:16.042 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 0.679 seconds (success: True)
2023-02-16 20:07:31.454 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.102 seconds (success: True)
2023-02-16 20:07:51.887 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 5.535 seconds (success: True)
2023-02-16 20:08:04.418 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.067 seconds (success: True)
2023-02-16 20:08:26.405 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 5.045 seconds (success: True)
... A lot of lines like this ...
2023-02-16 20:14:16.371 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 5.010 seconds (success: True)
2023-02-16 20:14:40.447 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.096 seconds (success: True)
2023-02-16 20:14:51.364 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 5.013 seconds (success: True)
2023-02-16 20:15:13.407 DEBUG (MainThread) [homeassistant.components.philips_js] Finished fetching philips_js data in 3.055 seconds (success: True)

Additional information

image

Sdahl1234 commented 8 months ago

@andrewjswan It is safe. "Kills" means I need to reboot TV to get the JointSpace server on the TV up and running again.

@elupus Its seems the httpx.Limits call has the parameters wrong. Documentations says param1: max connection, param2: max keepalive connections)

I have had the integration running 3 weeks now without any reboot on the TV only changing line 260 from limits = httpx.Limits(max_keepalive_connections=0, max_connections=3) to limits = httpx.Limits(max_connections=3, max_keepalive_connections=3)

Before: 1 TV worked 3 TV's lost connection after 5 minutes After: 4 TV's works

After HA release 2024.2 you need to have haphilipsjs folder in the /config/deps/ folder if you want to test with your own TV's

https://github.com/home-assistant/core/commit/523352c97e79d5a3c973541c89d0ec2295671206

elupus commented 8 months ago

@elupus Its seems the httpx.Limits call has the parameters wrong. Documentations says param1: max connection, param2: max keepalive connections)

I have had the integration running 3 weeks now without any reboot on the TV only changing line 260 from limits = httpx.Limits(max_keepalive_connections=0, max_connections=3) to limits = httpx.Limits(max_connections=3, max_keepalive_connections=3)

They are keyword parameters, so order does not matter.

The change you seem to have made is to allow keep alive. It could be beneficial in some cases IF the server supports it. Ie it would reduce connection load. My old (pre-android) TV's crashed hard with that enabled. I don't own that TV anymore sadly.

If you turn up debug logging on the httpx and httpcore i think you should get logs on reuses of connections. Please verify that you are actually getting re-uses.

I'm mostly fine with enabling keep alive, feel free to provide a patch for the lib to enable that. I think you could allow passing in a limits argument to the constructor. Then it's easier to tune this.

Sdahl1234 commented 8 months ago

@elupus Thanks for the explanation of the parameters. I am not coding very much python.

I noticed some weird behavior with httpx. It does NOT respect the max_connections if max keepalive connections is 0 If I use max_connections=3 and max_keepalive connections=0 then the number of connections increases beyond 3. My TV crashes when I hit about 25 connections (5 minutes after the first connection every time) If i use the max keepalive connection=3 it will stay with max 2 connections and the TV keeps working.

I have no clue why I get more that 3 connections and I sadly does not have the time to debug more at the moment....

elupus commented 8 months ago

@Sdahl1234 That is a very interesting find! Maybe we expose a bug in httpx here.

issue-triage-workflows[bot] commented 5 months ago

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 has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

andrewjswan commented 5 months ago

Still relevant

huberten9111 commented 4 months ago

I still get this , unavailable when powered on , off when powered off

elupus commented 4 months ago

You are of 2024.5.5 release? If so please turn on debug for the integration and reproduce issue. Then turn off and post log here

andrewjswan commented 4 months ago

It got a little better, but still not completely. image

huberten9111 commented 4 months ago

Core 2024.5.5 Supervisor 2024.05.1 Operating System 12.3 Frontend 20240501.1

Added file here if that works? home-assistant_philips_js_2024-05-27T20-23-23.125Z.log