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

philips_js: Unstable behaviour in every way #48839

Closed
Sjorsa opened this issue Apr 8, 2021 · 48 comments
Closed

philips_js: Unstable behaviour in every way #48839

Sjorsa opened this issue Apr 8, 2021 · 48 comments

Comments

@Sjorsa
Copy link
Contributor

Sjorsa commented Apr 8, 2021

The problem

I'm sorry the title is not very descriptive, but there's no way I can get all my issues in the title.
When I visit http://IP_ADDRESS_OF_TV:1925/system, I get the correct page and my api_version is 6.
When I first set it up I changed the volume and it worked. Now everytime I try to change something from the media_player card, a message pops up saying failed to call service: media_player.turn_off or set_volume or volume up, and the card then shows the TV is off. It will turn on if I turn the actual TV off, wait a minute and turn it on again.
I will also mention, I tried to add this integration in a previous HA version, but I experienced the same instabilities. I hoped the new update would help some of it, but unfortunately not :(
My TV is the Philips 55PUS7181/12

What is version of Home Assistant Core has the issue?

core-2021.4.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

philips_js

Link to integration documentation on our website

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

Example YAML snippet

No response

Anything in the logs that might be useful for us?

List of errors I get: https://i.imgur.com/nQgobWk.png + example from one of the errors. If a specific error is needed I can provide it as well.

`Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/asyncio.py", line 233, in acquire
    await asyncio.wait_for(self.semaphore.acquire(), timeout)
  File "/usr/local/lib/python3.8/asyncio/tasks.py", line 501, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/httpx/_exceptions.py", line 326, in map_exceptions
    yield
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1492, in _send_single_request
    (status_code, headers, stream, ext) = await transport.arequest(
  File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 169, in arequest
    return await self._pool.arequest(
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 213, in arequest
    await self._add_to_pool(connection, timeout=timeout)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 345, in _add_to_pool
    await self._connection_semaphore.acquire(timeout=timeout.get("pool", None))
  File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/asyncio.py", line 235, in acquire
    raise self.exc_class()
httpcore.PoolTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 311, in _postReq
    resp = await self.session.post(self._url(path), json=data, timeout=timeout)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1624, in post
    return await self.request(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1361, in request
    response = await self.send(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1396, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1434, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1466, in _send_handling_redirects
    response = await self._send_single_request(request, timeout)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1492, in _send_single_request
    (status_code, headers, stream, ext) = await transport.arequest(
  File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.8/site-packages/httpx/_exceptions.py", line 343, in map_exceptions
    raise mapped_exc(message, **kwargs) from exc  # type: ignore
httpx.PoolTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 143, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 206, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 649, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 692, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 686, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/philips_js/media_player.py", line 221, in async_volume_up
    await self._tv.sendKey("VolumeUp")
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 735, in sendKey
    res = await self._postReq('input/key', {'key': key}) is not None
  File "/usr/local/lib/python3.8/site-packages/haphilipsjs/__init__.py", line 329, in _postReq
    raise GeneralFailure(err) from err
haphilipsjs.GeneralFailure
`
@probot-home-assistant
Copy link

philips_js documentation
philips_js source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @elupus, mind taking a look at this issue as its been labeled with an integration (philips_js) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@elupus
Copy link
Contributor

elupus commented Apr 8, 2021

This mainly looks like a buggy tv. They are notoriously bad and crash prone. Especially if you send many commands (volume is easy to hammer the key).

If you just leave it be, does it stay online and display things like current channel?

@Sjorsa
Copy link
Contributor Author

Sjorsa commented Apr 8, 2021

https://i.imgur.com/dPXd3Gx.png It seems to stay on, I can see all the apps etc. When it worked, I was able to switch the TV to youtube, but it took about a minute to do.
Honestly, the only reason I want this integration is to turn the TV off at night, which seems to work so I'll leave it at that.

@elupus
Copy link
Contributor

elupus commented Apr 13, 2021

How is it behaving after the .4 point release? It should not be as prone to go offline anymore. It may still fail commands.

@Sjorsa
Copy link
Contributor Author

Sjorsa commented Apr 15, 2021

I readded the integration and it seems a liiitle bit better, but when I click around all the options it still crashes and I have to restart the TV. I managed to open the Kodi app once, which I was quite pleased with.
It does seem to give a lot more messaged in the logs if I touch the more advanced features.
It is pretty stable if I just stick to on/off and volume, but still sometimes crashes.

@henriklund
Copy link

henriklund commented Apr 16, 2021

A small observation from my own PoV on the component behaviour.

Previously I used another component for my TV (https://github.com/nstrelow/ha_philips_android_tv). This worked like a charm. I then tried to chang to philips_js, and all of a sudden I experienced that my flows (nodeRED) occasionally stopped with API errors when calling services. The only way to resolve the API error would be to power cycle of my TV.

Upon investigation, I saw that when API errors occurred that:

  • port 1925 worked
  • port 1926 timed out / failed (v6 runs on 1926)

When the port failed, NMAP showed the port as still open which then lead to a check with WireShark. This showed the initial TCP handshake failed in the last step (the TV did not react to Home Assistant sending ACK as a reply to TV SYN/ACK). The result was that the TLS handshake failed (it was started by Home Assistant while the TV was still stuck in the TCP handshake doing retransmission of SYN/ACK).

The solution for me was to reinstall my TV (take a note of your TVs setting before doing such as everything is reset). Despite hammering the TV with commands (on / off / source change / channel change) I have now run for two days without any failures.

---EDIT 2021-04-18---
As of yesterday evening (after almost four days without issues), the problem reemerged; issue was thus not resolved but merely mitigated.

@elupus
Copy link
Contributor

elupus commented Apr 16, 2021

Right. Yes this component is a bit more heavy on access to the tv. I may have to allow turning of the notification system. It will be slower to update, but maybe more stable.

@elupus
Copy link
Contributor

elupus commented Jun 12, 2021

Guys. are you running the TV's on wifi or lan? I just noticed that my TV which is on WIFI, keeps disconnecting from wifi all the time. If this timing wise coincides with a request from home assistant, the TV goes offline in HA.

This would easily explain issues with notification/events features since it will be running LONG queries. Which very likely will be in an open state when the TV looses wifi. It might fail to do proper clean-up then.

@henriklund
Copy link

I run solely on LAN.

Would it be possible to share the queries sent to the TV? That way I could easily check the power off / queries thesis (and also provide Philips with a PoC of how to trigger a fault of the HTTPS server in the TV.

@elupus
Copy link
Contributor

elupus commented Jun 12, 2021

Just turn on debug for the components.

haphilipsjs: debug

@henriklund
Copy link

What I see is
image

None of these seem long running. However, three lines at the end are 'newcomers' (haven't noticed them before).

@elupus
Copy link
Contributor

elupus commented Jun 12, 2021

Those are the long running.

@Sjorsa
Copy link
Contributor Author

Sjorsa commented Jun 12, 2021

My TV is on wifi, but I will put it on lan pretty soon. I will see if that does anything.

@henriklund
Copy link

@elupus, for me to understand you correct; the 8 GET commands listed are the long running queries you are referring to?

@elupus
Copy link
Contributor

elupus commented Jun 12, 2021

No. Only the post of notifyChange

@elupus
Copy link
Contributor

elupus commented Jun 12, 2021

For reference.. hass will issue a http post request to the tv. It will just hang not returning anything untill something changes. At which point it will start writing data to the connection that was opened a long time ago.

@henriklund
Copy link

Ok, got it. Messing around with the remote while watching the log exposed a "...[haphilipsjs] Post succeded: {'notification':...". -> Thanks for that revelation! :)

From my understanding (and a little more WireSharking), the TV is queried with a http://ip_of_tv:1925/6/system, when I restart Home Assistant. The first part of my TVs reply is '{"notifyChange":"http","menulanguage":", and this is the last communication on port 1925 & the last http communication; changing channels (via remote) on the TV shows the "Post succeeded", however, there are no post requests (in WireShark) on port 1925. Wouldn't it be better to run the notifychange on 1925?

@elupus
Copy link
Contributor

elupus commented Jun 13, 2021

I tried. I thought it would be possible
But it doesnt give any other data than is normally available on 1925. Ie just about nothing. You need to be on https to get any actual data.

@henriklund
Copy link

Hmmm...this is interesting (and a bit worrying that Philips is so inconsistent). For me, running the notifychange command (with curl) on either port 1925 or 1926 result in the exact same reply; a reply that only consists of activities/tv (with the two subsets of channel and channellist). I also (based on the log) seem only to be able to trigger the "...[haphilipsjs] Post succeded: {'notification':..." if I change the channel / source.
Based on knowledge gained, I will continue to block Home Assistant <> TV and then try to see if I can replicate the fail situation in a script.

@lweberru
Copy link

lweberru commented Jul 18, 2021

Next to that this component does most often not work at all (same problems), it also does not allow to activate the ambilight as long the TV component is off. My TV is also connected via WLAN, but will connect it via LAN next week and report if this helps.

@elupus
Copy link
Contributor

elupus commented Jul 18, 2021

@lweberru are you running 2021.7 release? if you can't active ambilight when TV is off. Your TV is likely fully turned off. Or buggy as usual.

@henriklund
Copy link

I have upgraded to 2021.7. My conclusion so far is that the integration works far better now since notifications are turned of by default (I checked and did not have to change any setting there). However, after a weeks use (which is more than twice in previous best case scenarios), the problem reemerged and the TV became unresponsive. I have reverted back to a deprecated version which, despite lacking a number of features found in the official integration, for some reason does not trigger the TV to crash port 1926.

@lweberru
Copy link

Yes running 2021.7.2. and TV is not fully off, i can use the philips_js webcalls for example. Just the component brings a popup „TV is not available“.

@elupus
Copy link
Contributor

elupus commented Jul 18, 2021

Well if you get that error it can't access the tv. Maybe it has crashed? Can you fully reboot it an test. Physical unplug or the reboot option in menus if this is an Android tv.

@lweberru
Copy link

lweberru commented Jul 20, 2021

Ok, i now connected the tv via lan. But the result is the same as when connected via wlan. I can only bind the home assistant once per restart of the tv, the control via home assistant is just a random result, changing the ambilight neither possible while tv is on nor while it is off.

@elupus
Copy link
Contributor

elupus commented Jul 20, 2021

@lweberru Not sure what you mean by "bind once"? What type of errors do you get in log. What model tv is this?

@lweberru
Copy link

The TV is a 49PUS7502/12

Binding error:

Logger: aiohttp.server
Source: components/philips_js/config_flow.py:82 
First occurred: 20. Juli 2021, 16:13:31 (2 occurrences) 
Last logged: 20. Juli 2021, 16:17:06

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 61, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 277, in handle_async_request
    ) = await self._pool.handle_async_request(
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 230, in handle_async_request
    response = await connection.handle_async_request(
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 99, in handle_async_request
    self.socket = await self._open_socket(timeout)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 130, in _open_socket
    return await self.backend.open_tcp_stream(
  File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/auto.py", line 44, in open_tcp_stream
    return await self.backend.open_tcp_stream(
  File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/asyncio.py", line 268, in open_tcp_stream
    return SocketStream(
  File "/usr/local/lib/python3.9/contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc) from None
httpcore.ConnectTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 77, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 155, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 63, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 202, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 260, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/philips_js/config_flow.py", line 145, in async_step_user
    return await self.async_step_pair()
  File "/usr/src/homeassistant/homeassistant/components/philips_js/config_flow.py", line 82, in async_step_pair
    self._pair_state = await self._hub.pairRequest(
  File "/usr/local/lib/python3.9/site-packages/haphilipsjs/__init__.py", line 572, in pairRequest
    resp = await self.session.post(self._url("pair/request"), json=data, auth=None)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1747, in post
    return await self.request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1426, in request
    response = await self.send(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1511, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1546, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1580, in _send_handling_redirects
    response = await self._send_single_request(request, timeout)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1621, in _send_single_request
    ) = await transport.handle_async_request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 272, in handle_async_request
    (
  File "/usr/local/lib/python3.9/contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 78, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectTimeout

@lweberru
Copy link

The error using this component looks like this:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/philips_js/light.py:377 
Integration: Home Assistant WebSocket API (documentation, issues) 
First occurred: 17. Juli 2021, 17:55:52 (4 occurrences) 
Last logged: 20. Juli 2021, 20:41:27

[2728530944] TV is not available
[2548470400] TV is not available
[2731599928] TV is not available
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 658, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 811, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 695, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 467, in async_handle_light_off_service
    await light.async_turn_off(**filter_turn_off_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/group/light.py", line 174, in async_turn_off
    await self.hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 658, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 811, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 695, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 467, in async_handle_light_off_service
    await light.async_turn_off(**filter_turn_off_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/group/light.py", line 174, in async_turn_off
    await self.hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 658, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 811, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 695, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 467, in async_handle_light_off_service
    await light.async_turn_off(**filter_turn_off_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/philips_js/light.py", line 377, in async_turn_off
    raise Exception("TV is not available")
Exception: TV is not available

@elupus
Copy link
Contributor

elupus commented Jul 22, 2021

@lweberru if you get connect timeout, you TV (the https endpoint) has crashed and need to be completely restarted before anything at all work again. What triggers the crash is unknown.

@lweberru
Copy link

Might be, that these TVs have some bugs, but the old ambilight and ambilight+hue component worked like a charm, so it should be possible somehow that this component is a bit more fault tolerant or probably has some issues with caching information or so.

@aegjoyce
Copy link

Unfortunately I think it is the Philips JS component that is crashing my TV. I would get lock ups, random app quits and general instability every 2-3 days before I disabled the component - now it has been working without issue for over 2 weeks

@elupus
Copy link
Contributor

elupus commented Jul 31, 2021

@aegjoyce it definitely is the component that causes the crash. But it's a bug in the tv that it crashes.

Sadly I've not been able to pinpoint what causes the crash. It does so much more than the old custom component. So it's not a valid comparison. But if anybody can pinpoint/reproduce it in a reliable way we can possibly work around it.

@aegjoyce
Copy link

Will see what I can do. Only thing I've noticed so far is that after a restart it works fine, only ever had problems after the TV has been in standby for a while

@lweberru
Copy link

lweberru commented Aug 5, 2021

My issue is this one:
#51927
could be fixed if I could change the port from 1926 to 1925 and protocol from https to http.
I just checked the source code, but did not find these settings anywhere. Any tip? I could make a custom component out of it and test it else.

@elupus
Copy link
Contributor

elupus commented Aug 5, 2021

It can't be fixed that way. 1925 does not provide all data. Only some data is available there.

@lweberru
Copy link

lweberru commented Aug 5, 2021

Can u tell me an example api call, what you think is not available? I will test…

@elupus
Copy link
Contributor

elupus commented Aug 5, 2021

I mentioned at least three in the other issue.

@elupus
Copy link
Contributor

elupus commented Aug 5, 2021

Can be added i know this is the case since i have dissasembled source code for the android server software.

@aegjoyce
Copy link

aegjoyce commented Aug 6, 2021

@elupus Can I just check with you how you found the Jointspace commands that this component uses? Only reason for asking is that I've been rewriting one of the old custom components for Ambilight as a temporary workaround for the TV crashes which was using commands from the pylips repository, a lot of which no longer work. I have been sniffing the https requests from the Philips TV Remote app which are very different to most of what I see listed on pylips.

Could using older (pylips) JS commands be causing the API (and TV) to hang and crash?

EDIT: repository is here: https://github.com/aegjoyce/ambilights - I have it set to poll every 30s and it hasn't caused any TV crashes (yet!)

@elupus
Copy link
Contributor

elupus commented Aug 6, 2021

Yes any commands can cause it to crash. My component doesn't do anything different than pylips. Might just be working the apis harder.

You can grab the xtv Android apk from an android tv. Then use an online disassembler to extract the source code.

@elupus
Copy link
Contributor

elupus commented Aug 6, 2021

Well. Actually it does one thing different. It's using httpx instead of requests library to talk to the server.
I wonder if it's one of the authentication bugs that causes issues. Digest doesn't reuse authentication data. encode/httpx#1467

@aegjoyce
Copy link

aegjoyce commented Aug 6, 2021

Don't know if this is helpful but here is a sample POST request from the Philips app - includes details of their auth:

curl 'https://[IP]:1926/6/menuitems/settings/update'
-X POST
-H 'Host: [IP]:1926' 
-H 'Content-Type: application/json' 
-H 'X-Proxyman-Repeated-ID: 9083CA0A' 
-H 'Content-Length: 110' 
-H 'Authorization: Digest username="[USERNAME]", realm="XTV", nonce="[NONCE]", uri="/6/menuitems/settings/update", response="[RESPONSE STRING]", algorithm="MD5", cnonce="[CNONCE]", nc=00000001, qop="auth"' 
-H 'Accept-Language: en-gb' 
-H 'User-Agent: PhilipsTvRemote2/13848 CFNetwork/1240.0.4 Darwin/20.6.0' 
-H 'Connection: close' 
-H 'Accept: */*' 
-d '{"values":[{"value":{"Nodeid":2131230770,"Controllable":true,"Available":true,"data":{"selected_item":201}}}]}'

@elupus elupus mentioned this issue Aug 6, 2021
21 tasks
@elupus
Copy link
Contributor

elupus commented Aug 6, 2021

@aegjoyce if you can test #54176 it would be interesting. This avoids the extra server round trips made for authentication all the time. Unlikely to solve the issues, but worth a test.

@aegjoyce
Copy link

aegjoyce commented Aug 9, 2021

Sure, will keep an eye out for when it gets pushed in an update and will test

@lweberru
Copy link

lweberru commented Sep 8, 2021

Any news here?

@Emrvb
Copy link

Emrvb commented Sep 13, 2021

@aegjoyce

Do you happen to have more captured requests and could you share those? That would save me some time getting captures myself.

@elupus
Copy link
Contributor

elupus commented Sep 24, 2021

I'm going to close this in favor of its twin: #49801 . It's likely not resolved. But I don't know what triggers the fault yet, and i think it's better to keep to one issue.

@elupus elupus closed this as completed Sep 24, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants