Closed albaintor closed 7 months ago
I've finished the Apple TV rewrite and will focus next on the Android TV. Not having any command errors in the logs is suspicious. I have a Shield TV as well and try to reproduce it. It's possible that some return state isn't checked or a disconnect event is missed...
Hi Markus, did you manage to find the problem ? I have this issue regularly (every day or 2 days). Just after reboot of the remote, the integration works fine. Even after stop/restart of the shield activity it still works correctly, even after a few hours.
This is really weird as the driver receives the commands order and seem to process them with no error : intg-androidtv INFO INFO:driver:Got 00044BE87F74 command request: home None
It is as if the transport stream didn't work behind ? maybe a disconnection which is not caught ?
Update : while started (and not working) commands responded again after 20 minutes Here are the logs : the first lines around 11:05 are the working commands, whereas at 10:53 they were not. UCR2_logs_2024-03-27 (2).zip
Could it be related to keys press / release mechanism ?
I couldn't reproduce it so far, but I've also been working on PR #34 for a while which changed the connection & reconnection logic. Maybe it's fixed, otherwise I'll investigate it further after the new features have been merged.
I have just set up your modifications in an external driver and configured it as my main entity for the Shield. I'll let you know
I could reproduce two issues where communication breaks and no error is returned for several minutes from the communication library:
I'm a bit surprised about the first case, since I thought there's a keep-alive ping in the background. Maybe that changed, or I confuse it with the Android TV integration in Home Assistant. I'll investigate it after the multi-device PR is merged.
One issue is in the androidtvremote2
library: sending a command is just fire and forget without a return value, even if the library determines that there's no connection :-(
_send_message
in base.py
https://github.com/tronikos/androidtvremote2/blob/e54e33772e61e4ccb24b0c5ba6e0f2ad3efb2547/src/androidtvremote2/base.py#L66-L79 if not self.transport or self.transport.is_closing():
LOGGER.debug("Connection is closed!")
return
I've added a transport check workaround and will most likely submit a patch for the send_key_command
method.
The case when network interface changes (LAN to WIFI) should not occur in my setup (plugged in ethernet) but I guess that my ISP router may sometimes have dropouts. There is indeed no reconnection logic in the library which should be done on lower level inside the library. Thank you for raising this and making a workaround
I've started a new branch fix/28_lost-connection
for refactoring and improving the connection logic. This should fix the dead connection issue and give immediate feedback, if a command couldn't be sent to the device because there's not transport available.
This requires more testing before I'll merge it into the main branch.
The main branch already contains debug logging of the androidtvremote2 library to better see what's going on (or not).
Changed IP addresses are still only handled after wakeup of the remote. Devices are disconnected before sleep, then reconnected after wakeup. IP change detection is included in the initial connection logic. Unfortunately the reconnection task of androidtvremote2 only has a callback handler for authentication errors and doesn't provide more events. It can only be stopped by calling disconnect().
Hi Markus, ok I have just applied your branch on my external integration. Something that I would suggest that has disappeared from the previous PR I submitted : the profiles files are read from the $HOME folder, whereas they should read from the integration folder. On my setup the docker loads the integration files from an external mount, so that it is easier to update. This is not a common use I agree but as the profiles folder sits next to the intg-XXX driver files, one would expect to put them all in the same folder. So I had applied a condition load on profile files from driver.py. What do you think ? (in that case if it fails to load from config_dir path it will check after the current path)
# Internal driver mode
profile_path = os.path.join(api.config_dir_path, "config/profiles")
# External driver mode
if not os.path.exists(profile_path):
profile_path = "config/profiles"
device_profile.load(profile_path)
This is already handled with ENV variables: https://github.com/unfoldedcircle/integration-python-library?tab=readme-ov-file#environment-variables and implemented in the Python integration library.
When running in a container you can simply set the UC_CONFIG_HOME
or HOME
environment variable to your mountpoint.
This is required for the correct runtime behaviour on the Remote Two.
The profile loading path is currently not correct and will fix it tomorrow:
profile_path = os.path.join(api.config_dir_path, "config/profiles")
it may not contain the config/
prefix to run correctly on the Remote Two.
Ok thanks it works
Description
Hi, my android (shield) TV integration stops working randomly
From the logs I have this repetitive warning, don't know why I have this as Android does not support now playing image:
then key pressed but nothing happens on AndroidTV's side :
Here are the logs :
UCR2_logs_2024-03-08.zip
How to Reproduce
1/ Launch an activity with TV + Android TV (nvidia shield) integration + HT receiver (media player entity from home assistant) 2/ Use the shield : navigate through menus, launch media 3/ After a while (happens randomly), the commands are not processed (play, pause, down arrow...)
I have set up the remote to go to sleep after 30min. In the activities I didn't enable the option to prevent sleeping, so maybe the remote goes to sleep during 2/ and 3/
Expected behavior
Android TV integration keeps on working
Integration version
No response
Additional context
No response