dwaan / homebridge-adb

Homebridge script to control remote ADB enabled Android device
MIT License
76 stars 15 forks source link

v2 - WOL/ADB power ON - not working properly #84

Open obs945 opened 2 years ago

obs945 commented 2 years ago

Describe the bug Directly upgrade to v2.0.0 and homebridge-adb not work anymore.

Expected behavior My tv sideloaded wakelock v3 and homebridge-adb v1.5.5 did all the trick but cannot work after upgrade to latest version 2.0.0. I tried add mac address on v2.0.0 setting and WOL function works (can turn on tv), however, the system cannot get status from my tv. TV toggle always showed off on Homekit app. But I went back to v1.5.5 (remove WOL setting code) and all worked again.

Log output v..2.0.0 log [abnormal status] [14/05/2022, 09:18:15] [HomebridgeADB] Mi TV - Trying to turn ON accessory. This will take awhile, please wait... [14/05/2022, 09:18:29] [HomebridgeADB] Mi TV - Power On - Failed [14/05/2022, 09:18:29] [HomebridgeADB] Mi TV - Power on error message: Failed [14/05/2022, 09:18:39] [HomebridgeADB] Mi TV - Trying to turn ON accessory. This will take awhile, please wait... [14/05/2022, 09:18:53] [HomebridgeADB] Mi TV - Power On - Failed [14/05/2022, 09:18:53] [HomebridgeADB] Mi TV - Power on error message: Failed

v.1.5.5 log [normal status] [14/05/2022, 09:20:32] [HomebridgeADB] Mi TV - Trying to Turn On device [14/05/2022, 09:20:32] [HomebridgeADB] Mi TV - Running - adb -s 192.168.1.147 shell "input keyevent KEYCODE_POWER" [14/05/2022, 09:20:33] [HomebridgeADB] Mi TV - ADB - Power On [14/05/2022, 09:20:34] [HomebridgeADB] Mi TV - checkPower - true [14/05/2022, 09:20:34] [HomebridgeADB] Mi TV - checkInput - using dumpsys window [14/05/2022, 09:20:34] [HomebridgeADB] Mi TV - Current app - home [14/05/2022, 09:20:44] [HomebridgeADB] Mi TV - Trying to Turn Off device [14/05/2022, 09:20:45] [HomebridgeADB] Mi TV - ADB - Power Off [14/05/2022, 09:20:45] [HomebridgeADB] Mi TV - checkPower - false

Config "accessories": [ { "name": "Mi TV", "ip": "192.168.1.147", "timeout": 5000, "interval": 500, "category": "TELEVISION", "inputs": [ { "name": "Netflix", "id": "com.netflix.ninja" }, { "name": "Youtube", "id": "com.google.android.youtube.tv" }, { "name": "Disney+", "id": "com.disney.disneyplus" }, { "name": "Apple TV+", "id": "com.apple.atve.androidtv.appletv" }, { "name": "Input Source", "id": "com.mediatek.wwtv.tvcenter" } ], "debug": true, "backbutton": "KEYCODE_BACK", "playpausebutton": "KEYCODE_MEDIA_PLAY_PAUSE", "infobutton": "KEYCODE_HOME", "poweron": "KEYCODE_POWER", "poweroff": "KEYCODE_POWER" } ], "platform": "HomebridgeADB" },

dwaan commented 2 years ago

Hey Thank you for the report. Just to clarified:

v2

V1.5.5

obs945 commented 2 years ago

In order to more clearly clarify the status I test several combinations. Please referred to below

====

I execute wakelock v3 to prevent homebridgeADB missing connection to tv messages pop up during sleeping mode (but missing connection messages will pop up after power off till to next power on).

[14/05/2022, 13:33:22] [HomebridgeADB] MiTV - missing port in specification: tcp:192.168.1.147 [14/05/2022, 13:33:22] [HomebridgeADB] MiTV - Reconnected [14/05/2022, 13:33:22] [HomebridgeADB] MiTV - Reconnecting...

My working setting on V1.5.5 "poweron": "KEYCODE_POWER", "poweroff": "KEYCODE_POWER" I didn't set MAC address and keep TV in sleeping mode (not totally turn off). -> Turn on/off with ADB: work. Home status: work Turn on with WOL: doesn’t use. Home app status: work

Partial working setting on V1.5.5 "poweron": "KEYCODE_POWER" or "KEYCODE_WAKEUP", "poweroff": "KEYCODE_SLEEP" Set MAC for WOL function. -> Turn on with ADB: doesn't work, Turn off with ADB: work. Home status: work Turn on with WOL: work (but cannot turn on again with ADB after turn off). Home app status: work


There is no need to execute wakelock v3. There will no missing connection to tv message showed in log even power off the tv.

Partial working setting on V2 "poweron": "KEYCODE_POWER", "poweroff": "KEYCODE_POWER" or "poweron": "KEYCODE_POWER" or "KEYCODE_WAKEUP", "poweroff": "KEYCODE_SLEEP" Set MAC for WOL function. -> Turn on/off with ADB: doesn't work. Home app status: doesn’t work Turn on with WOL: work (but cannot turn on/off again with ADB). Home app status: doesn’t work.

Although Homebridge log showed as below, WOL function always doing great. [14/05/2022, 14:18:00] [HomebridgeADB] MiTV - Wake On LAN - Sending magic [14/05/2022, 14:18:00] [HomebridgeADB] MiTV - Wake On LAN - Failed [14/05/2022, 14:18:00] [HomebridgeADB] MiTV - WOL error message: Device is not connected

ahmadnazirafiq commented 2 years ago

Had to downgrade to version 1.5.5. Seems like it doesn’t work at all on version 2.

halk1982 commented 2 years ago

I have the exact same issue on one of my devices (it was fine on 1.5.5). Specifically, while the device remain attached and connected (adb connect response is : already connected), when I try to wakeup the device I'm getting "error: closed" in response (device is a Samsung tablet SM-T235). Then if I kill and start server or if I disable and then enable USB debugging on the device, everything goes back to normal. This is so strange because on another tablet I have (BMAX MaxPad I10) everything works fine, with no issue at all. Just installed 2.1.2, no change. @dwaan any thoughts ?