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.15k stars 29.83k forks source link

Android TV integration - TV unavailable when turned off #107649

Open n3on4s opened 8 months ago

n3on4s commented 8 months ago

The problem

So I encoutered problem with my Android TV (TCL), where whenver I shutdown TV, it becomes unavailable in HA:

image

I did some debuging, and narrowed down problem to android TV itself.

When TV is on, NMAP results:

nmap 192.168.0.82
Starting Nmap 7.80 ( https://nmap.org ) at 2024-01-09 14:42 FLE Standard Time
Nmap scan report for 192.168.0.82
Host is up (0.0017s latency).
Not shown: 995 closed ports
PORT     STATE SERVICE
5555/tcp open  freeciv
8008/tcp open  http
8009/tcp open  ajp13
8443/tcp open  https-alt
9000/tcp open  cslistener
MAC Address: XX:XX:XX:XX:XX:XX

After TV gets shutdown, by any way remote/HA/auto sleep:

nmap 192.168.0.82
Starting Nmap 7.80 ( https://nmap.org ) at 2024-01-09 14:47 FLE Standard Time
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 1.02 seconds

I tried to change every tipe of settings in Android TV and nothing helped.

After some time I tried to wake up TV with WakeOnLan option and at first seems like TV had'nt woke up, however, nmap started responding with OK results, and TV become available (visible as turned off again) in HA again:

image

nmap 192.168.0.82
Starting Nmap 7.80 ( https://nmap.org ) at 2024-01-09 14:53 FLE Standard Time
Nmap scan report for 192.168.0.82
Host is up (0.00017s latency).
Not shown: 995 closed ports
PORT     STATE SERVICE
5555/tcp open  freeciv
8008/tcp open  http
8009/tcp open  ajp13
8443/tcp open  https-alt
9000/tcp open  cslistener
MAC Address:

I know this happend not to all android TVs, however maybe you could add configuration option to enable, automaticaly resending WakeUpOnLan command, before the Heartbeat request, if tv is in Off/unavailable state?

What version of Home Assistant Core has the issue?

core-2024.1.0

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

Android TV Remote

Link to integration documentation on our website

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

Diagnostics information

config_entry-androidtv_remote-369036337b86e55921657a6ff3d5d5b9.json.txt

Example YAML snippet

No response

Anything in the logs that might be useful for us?

[Living Room TV(192.168.0.82):8009] Heartbeat timeout, resetting connection
2:43:35 PM – (WARNING) /usr/local/lib/python3.11/site-packages/pychromecast/socket_client.py - message first occurred at 1:28:34 PM and shows up 25 times
Disconnected from Living Room TV at 192.168.0.82
2:38:41 PM – (WARNING) Android TV Remote - message first occurred at 1:28:30 PM and shows up 47 times
[Living Room TV(192.168.0.82):8009] Failed to connect to service ServiceInfo(type='mdns', data='Smart-TV-Pro-6e0231880edf1cc85f26ad05671960b1._googlecast._tcp.local.'), retrying in 5.0s
2:20:49 PM – (ERROR) /usr/local/lib/python3.11/site-packages/pychromecast/socket_client.py - message first occurred at 1:29:04 PM and shows up 14 times

Additional information

For anyone looking for fast fix, setting automation every 10s. to send magic wakeup packet, to TV's MAC when TV is off/unavailable fixed the issue for me.

ggaltqq commented 4 months ago

I got a Xiaomi device, so integration becomes unavailable after turn off, and the bigger problem is that it never comes back. By never, I mean - even if the tv is on and ADB is available. It's not a solution for this particular issue , but I ended up having a script that turns on tv using IR remote and then reloading config entity of Android TV remote integration.

saschachina commented 4 months ago

On my Philips I've changed the developer setting, reinstalled Android TV Remote, reconfigured it in HA and disabled power optimization for the remote app. Unfortunately nothing has worked for me.

If you have a Philips TV, please try this like @AssenDimitrov mentioned in his previous poste!

TV settings menu, I clicked "Android Settings" > "Device Settings", then Developer Options > Enable screen on when charging (or something like that).

Did you try it?

ltjessem commented 4 months ago

Yes, unfortunately it didn't help for me.

tronikos commented 3 months ago

Can someone update the documentation with the workarounds mentioned so far?

tronikos commented 3 months ago

Here is how to edit the documentation and create a pull request:

  1. Click edit at the bottom left of https://www.home-assistant.io/integrations/androidtv_remote/
  2. Click the pencil edit icon at the top right
  3. Edit the documentation
  4. Click on commit changes and then propose changes
  5. Click on create pull request
  6. Edit title and description
  7. Click on create pull request
tronikos commented 3 months ago

@home-assistant rename Android TV integration - TV unavailable when turned off

Juchar commented 3 months ago

Not sure if it helps, but probably something to validate: I use the official philips integration, where the button to turn on the TV also regularily disappeared - until I turned on USB Debugging on the TV (NOT Enable screen on when charging, this is off on my TV).

AlekBarta commented 2 months ago

Nothing helped, still TV Off/Unavailable, over and over. I've even tried setting the TV to a static IP address on both the TV and the router, nothing helps.

Chaoscontrol commented 2 months ago

I have this issue but not as consistently and mentioned in this thread. It disconnects once in a while, but it keeps doing it every few days/hours. But clearly not every time it goes off.

Mine is a Chromecast with Google TV. I have turn off after 15min inactive, but that doesn't seem to be related. There's no "Screennless" option on mine.

Any ideas how to fix it? Is it a different issue?

BardaktakiAdam commented 1 month ago

I solved this problem with my TCL Android TV by activating the following option hidden far away here:

Settings -> System -> Network & Internet -> activate checkbox “Network Standby”

IT WORKS FOR ME %100

TCL ANDROID TV.

THANK YOU

insane66613 commented 3 weeks ago

Only working way I found for deep sleep problem is using Wakelock Revamped. It is on Play store, but not compatible with Android TV. So you have to sideload APK using flashdisk and any working file manager (Solid or X-Plore are TV compatible). You can download latest version of APK from developer Github. What this app does is keep wakelock or state of CPU/WiFi component out of sleep. Which is crucial, because then system doesn't run night cycles and your TV is powered much faster.

Tip for running it on TV as it seems to be setup as system app, not directly supporting Android TV, you wont find it in installed apps. Found workaround how to run it, go to: Settings -> Android settings -> Device preferences -> Storage -> Internal storage -> Apps -> See all apps -> scroll to bottom System apps -> scroll down to Wakelock v3 and click -> Open. Voila. Great UX!

pablosuarez999 commented 4 days ago

I think I found one solution using adb in my TCL TV, asked chatGPT and sent me this commands: you should install adb in your computer through cmd, then connect to your IP like this: adb connect [your TV IP]

adb shell settings put global stay_on_while_plugged_in 3

adb shell dumpsys power | grep mWakefulness adb shell dumpsys deviceidle disable

adb shell svc power stayon true

adb shell dumpsys power

adb shell settings put global sleep_timeout 0

I has just sent all these commands and it solved the problem, none of the solutions worked for me, neither using wakelock, TCL seems not to like using this app or something about the android version, let me know if it works!

rutj87 commented 4 days ago

Thanks for sharing.

This command didn't work - "adb shell dumpsys power | grep mWakefulness"

Rest of commands were accepted but the device is still becoming unavailable.

On Tue, 10 Sept 2024 at 08:51, pablosuarez999 @.***> wrote:

I think I found one solution using adb in my TCL TV, asked chatGPT and sent me this commands: you should install adb in your computer, then connect to your IP like this: adb connect [your TV IP]

adb shell settings put global stay_on_while_plugged_in 3

adb shell dumpsys power | grep mWakefulness adb shell dumpsys deviceidle disable

adb shell svc power stayon true

adb shell dumpsys power

adb shell settings put global sleep_timeout 0

I has just sent all these commands and it worked for me, any of all the solutions worked for me, neither using wakelock, TCL seems not to like using this app or something about the android version, let me know if it works for some of you!

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/107649#issuecomment-2339288148, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARVUAIULH7APR2MFYXELVLLZVYRAFAVCNFSM6AAAAABBTCVLTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZZGI4DQMJUHA . You are receiving this because you commented.Message ID: @.***>

pablosuarez999 commented 4 days ago

@rutj87 I have wakelock v3 installed with processor turned on, if you wanna make sure...