-
Notifications
You must be signed in to change notification settings - Fork 61
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
State of media_player very often changes from "turned off" to "unavailable" #29
Comments
Thanks for the log! Could you try this custom component and see if it fixes the issue (HACS compatible): https://github.com/JeffLIrion/ha-androidtv |
In your log from above, you keep getting this error:
What's happening is:
I saw that you opened this issue: home-assistant/core#23820 I don't see anything wrong, it seems like your device just takes a long time to respond sometimes. |
* Only read 'OKAY' responses in '_open'; remove unreachable code * Remove unused variable * Update documentation * Test for issue #29 (#30) * Working on tests for issue 29 * Change '\xa2' to '\x99' * More unit testing for issue 29 * Update documentation for '_read_until_close' * Rename test * Annotate test for issue 27 * Consolidate tests for issue #29 * Delete log.txt
Component with adb server works quite well. In HA 0.100 you made a lot of changes and I wanted to test them without an adb server. In fact, it seems to me that my device in standby mode responds with a very long delay or doesn't respond at all. |
I don't know why it doesn't reconnect. In your log, it looked like it would reconnect but then encounter that timeout error and become unavailable again. You could play around with the custom component: https://github.com/JeffLIrion/ha-androidtv/tree/master/custom_components/androidtv The first thing I would try is, in You could look into the You could look into the Lastly, you could look into the |
@bieniu Have you ever debugged this issue? I am running into the same issue. My Sony Bravia TV (KD65A1) works fine when I:
However, after I have had my TV off for a while, the home assistant entity keeps changing from unavailable to unknown and back. If you haven't resolved this issue yet, I'll try the @JeffLIrion 's suggestions when I get home tonight and see if I can find some useful information. |
You could try this custom component: https://github.com/JeffLIrion/ha-androidtv/tree/tcptimeout Note that it's the It implements my first suggestion from above. It's more of a workaround than a fix, but maybe it will avoid the issue. |
@JeffLIrion Tried this, it works once I restart HA while my TV is on. However, when my tv has been off for a while it pops back to unavailable/unknown. When I turn on my TV, it doesn't auto-reconnect to my TV and keeps repeating this in the log: 2019-11-07 16:20:26 WARNING (SyncWorker_19) [custom_components.androidtv.androidtv.adb_manager] Couldn't connect to host 192.168.178.54:5555, error: Socket not connected Any idea? |
You didn’t get this “Socket not connected” error message before trying this custom component? I'm not sure what the error is. I need debug logs for |
Yeah I did before trying the custom component as well, which was the whole reason of me trying the custom component in the first place :).How do I enable debug logging and pull those logs? |
Right, but I'm asking specifically about the "Socket not connected" error message. Did you get that error message before or only with the custom component? For setting log levels: https://www.home-assistant.io/integrations/logger/ |
Sorry if my previous message wasn't clear. I did get the 'socket not connected' message before the custom component as well after my TV had been off for a while. |
Your problem seems like it might be different than the problem in the first post -- he doesn't have any "Socket not connected" error messages. Without logs, there's no way to tell what happened. |
home-assistant.log |
I don't see any errors or warnings in that log. |
Hm. Any other ideas on how to debug this issue? Also, should home assistant keep a connection to Android TV even when the TV is off? Because it looks like my Android TV closes sockets after being in standby mode for a while. |
You could use the
It's not wrong if the device goes to unavailable, since HA can't control it (e.g., turn it back on). What is wrong is that it doesn't reconnect. A lot of devices (such as my Fire TV sticks) don't turn off completely, but rather go into a sleep mode. So HA can turn the device back on and never loses the connection. I've heard there are apps for Android that prevent the device from turning off completely, allowing the ADB connection to stay intact. |
So I did manage to No matter what I do, I cannot seem to get an error to log on the HA side, which makes me feel like Sony doesn't properly close connections when the TV enters deep sleep, causing HA to think the current socket connection is still valid. Is there any way I can help to validate this theory? |
I pushed an update to the custom component, so please update that (use the When it gets into this error state, try setting the log level for the custom component ( |
Hi ! FWIW, I have the same issue with a MiBox. I believe these boxes do not respect the "Do not sleep" setting. Even when set to on, if you put them in standby, they become unreachable (tested with ping and monitoring wifi connection from AP). I thus believe the issue may be more on the Xiaomi side ? Edit: Workaroud looks like to install a WakeLock app : see JeffLIrion/python-androidtv#18 (comment) |
@Twanislas yeah, that would have been my first suggestion. Please report back and let me know if that fixes the issue. |
@JeffLIrion It's been 4 hours without a single disconnect, and I can turn on or off both my (Mi)boxes ! :) |
That's good to hear! Please report back in a couple days to let me know if it's still working. If so, I'll close this issue. |
4 days later, still working like a charm. Cheers ! |
@Twanislas thanks for the update! I'll go ahead and close this. |
For me Wakelock app also fixed this issue. Thanks @Twanislas |
Original credits go to @CultusMechanicus from JeffLIrion/python-androidtv#18 (comment) :) |
HA: 0.100.1
adb-shell: 0.0.4
Device: Xiaomi Mi Box TV 4K
Configuration:
After turning off device (via remote) its media_player entity very often changes states from "turned off" to "unavailable". Wi-Fi connection is still active when device is off.
Debug log:
The text was updated successfully, but these errors were encountered: