dwaan / homebridge-adb

Homebridge script to control remote ADB enabled Android device
MIT License
75 stars 14 forks source link

Adb commands after restart homebridge #11

Closed facutopa closed 3 years ago

facutopa commented 3 years ago

Hi! Maybe this is a suggestion or I don't know. The plugin work perfect, but sometimes when I restart homebridge for other things, the plugin don´t work well and drop the next log:

[9/18/2020, 14:12:46] [BroadlinkRM] Tele getSwitchState: true
[9/18/2020, 14:12:53] [HomebridgeADB] 192.168.0.5 - No response, please check your ADB connection
[9/18/2020, 14:12:53] [HomebridgeADB] 192.168.0.5 - TCL power is set to false

This problem it's solved with the commands that you suggest on the readme file.

Some Android device doesn't have remote debug by default. If your device is one of them, connect your device with USB cable to your server (or any computer with ADB installed) and run this command:

 **adb tcpip 5555**

after that, just disconnect the USB cable from your server.

Optionally, run this command to make sure you can connect to device:

 **adb connect your-device-ip**

If all goes well, there will be a popup window in your android device asking for debug permission. After you accept the request, you might want to do kill the adb server to make a fresh connection

 **adb kill-server**

I don´t know the exactly correct order of the commands but should be great that commands would be executed alone when someone restart the server, right?

I don´t know Regards

dwaan commented 3 years ago

Hey. Thank you for the info. This is something new to me, in my experience doing “adb tcpip 5555” once should be good until I reset my adb permission from Developer Setting in my android device. So I never include it inside the plugin.

By the look of it, did you restarted the homebridge when the TV is on?

Anyway, The only command that you need to enable remote ADB is actually “adb tcpip 5555”, the other commands is just to make sure that the adb are restarted.

ahmadnazirafiq commented 3 years ago

In my case, I didn't even restart Homebridge. Just by turning off and on the TV stick severs the connection. I'm using Xiaomi's Mi TV Stick which is running Android TV OS. I need to constantly revoke USB debugging in the stick, run adb connect 192.168.X.XXX followed by adb tcpip 5555 command to be able to control the stick in the Home app; again.

Hopefully there's some workaround. I couldn't afford a new TV and who knows when the new Apple TV will come.

dwaan commented 3 years ago

Please check the newest version to see if this problem still exist or not.

ahmadnazirafiq commented 3 years ago

Thank you for your swift response! New update fixed it, no need to revoke and reregister ADB again.

A question though: if i turn the stick off thru Home app, does it turn off completely? Because my stick disconnects from WiFi when I did that. Doesn’t the button simulate “sleep” instead of “off”?

dwaan commented 3 years ago

I think it’s depend on the device. The off command is actually similar to turning off screen if the device have screen, or put it in sleep in most of Android box, but never intended to make the device turned off completely.

I’m using this command to make the device sleep: adb -s ip-address shell "input keyevent KEYCODE_SLEEP"

ahmadnazirafiq commented 3 years ago

I guess I had to keep the stick always on. Btw, I’m using shortcuts to set up to launch a specific input: eg Netflix but the last update seems to broke this functionality. When I open the Home app, it does display current input but the stick does not switch to it unless I manually toggle it again. Not sure if its related.

D6C66EFF-8807-4C15-AF4D-8E8E06ABFAED

dwaan commented 3 years ago

I guess I had to keep the stick always on. Btw, I’m using shortcuts to set up to launch a specific input: eg Netflix but the last update seems to broke this functionality. When I open the Home app, it does display current input but the stick does not switch to it unless I manually toggle it again. Not sure if its related.

Thank you for the information. Yes you're correct, turn out the input switching had a bug when executed via automation, the newer version fix this bug.

ahmadnazirafiq commented 3 years ago

After several testing and rebooting, the latest update is the most stable version yet. I’m able to use these shortcuts to boot the device as well as input switching. Pretty quick and smooth!

01E1B388-4603-44DC-B6A5-58FB2E2A34C7

I noticed that whenever I installed some plugins on Homebridge and rebooted, the input number returns despite after renaming it without one manually. Hopefully you could provide an option to remove input number as I like it clean without one.

Still, I’m loving this plugin so much! I appreciate all your hard work 👏👏👏