dwaan / homebridge-adb

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

Question - Update of status of accessorie #6

Closed facutopa closed 4 years ago

facutopa commented 4 years ago

Hi, one easy doubt, I use Broadlink plugin, and with that I can control with IR the TV and other things. This plugin update the status of the accesorie every 20 seconds (or the time you want through the IP).

Is the update through the Homebridge-ADB IP supposed to work the same way? Because sometimes when I turn off through the plugin the Broadlink does not update the Homebridge-ADB status.

Thanks and regards!

dwaan commented 4 years ago

Yes. This plugins update the device status every 5 seconds by default. You can set the interval via config.json as low as 300 ms. In my experience 5 seconds are good enough.

But instead of using IP, this plugins send ADB command to check if the device screen is turned off or not. I haven’t intensively test on every Android TV, but maybe your device produce different output and the plugins didn’t recognize it.

You can try run this command to see the output it produce:

adb -s ipaddress shell “dumpsys power | grep mHoldingDisplay | cut -d = -f 2”

This should produce true or false. If not, can you share your output after you run this command:

adb -s ipaddress shell “dumpsys power | grep mHoldingDisplay”

facutopa commented 4 years ago

Hi! Thanks for your answer. I tried your commands:

pi@homebridge:/var/lib/homebridge $ adb -s myip shell "dumpsys power | grep mHoldingDisplay | cut -d = -f 2"
true
pi@homebridge:/var/lib/homebridge $ adb -s myip shell "dumpsys power | grep mHoldingDisplay"
  mHoldingDisplaySuspendBlocker=true
dwaan commented 4 years ago

So your TV actually produce expected result. The "true" result means that the device screen is on, and "false" means the screen is off.

Can you help me to debug this result, so maybe I can produce workaround. Using the same command:

  1. Turn off your TV using the broadlink plugins, and run the command, what is the result?
  2. Turn off your TV using this plugins, and run the command, what is the result? Does your TV turned off also?

I was wondering maybe the broadlink plugins which probably using IR command might completely turn off your TV so there is no network connection. As this plugins requires network connection to work, the only answer why this plugins didn't report it status after you turn off your TV using broadlink plugins is that the TV completely turn off and didn't accept any network connection.

facutopa commented 4 years ago

I did the steps that you mentioned:

  1. Turn off TV with broadlink plugin:
    pi@homebridge:/var/lib/homebridge $ adb -s my-ip shell "dumpsys power | grep mHoldingDisplay | cut -d = -f 2"
    **nothing returns and is "processing" I guess**

    When I did that the log of homebridge was:

    [9/7/2020, 14:22:04] [BroadlinkRM] Tele sendHex (192.168.0.10; a7:df:24:7a:7f:13) 2600a2007f8312421141134211431121122112421122114212211143112211211223112111221142114311221142122112421122114212000115868412421143114212421122112112421122114113211242112211221124112111221142124211221143112112421122114211000119858312421043124211431121122013421122114212211242112211211223112111231042124211221142122112421122114212000d0500000000
    [9/7/2020, 14:22:28] [BroadlinkRM] Tele getSwitchState: false
    [9/7/2020, 14:22:43] [BroadlinkRM] Tele getSwitchState: false

    After that I just restart homebridge because I can´t execute other command on terminal. When start the Homebridge-ADB didn´t work so I do the process with the commands: adb tcpip 5555 adb connect your-device-ip adb kill-server And restart and now work.

Now I turn off the tv with the broadlink plugin and execute the other command: And same happen like the first command:

pi@homebridge:/var/lib/homebridge $ adb -s my-ip shell "dumpsys power | grep mHoldingDisplay"
**nothing returns and is "processing" I guess**
  1. Turn off your TV using this plugins The broadlink detect the change of status [9/7/2020, 14:34:25] [BroadlinkRM] Tele getSwitchState: false

But with the command happened the same of step1, freeze the terminal. I needed to re-configure the same commands of the ip:

pi@homebridge:/var/lib/homebridge $ adb tcpip 5555
error: no devices/emulators found
pi@homebridge:/var/lib/homebridge $ adb connect my-ip
connected to 192.168.0.5:5555
pi@homebridge:/var/lib/homebridge $ adb kill-server
pi@homebridge:/var/lib/homebridge $ adb connect my-ip
* daemon not running; starting now at tcp:5037
* daemon started successfully
connected to my-ip:5555
pi@homebridge:/var/lib/homebridge $ 

I hope help you with the debug.

dwaan commented 4 years ago

I update the plugins so it can detect if the device connection is dropped, in this case when your device is turned off and it drop its network connection. After that, you need to turn on your device manually before you can use this plugin again. You can try it and see If it works.

facutopa commented 4 years ago

Solved! Thanks you sooo much @dwaan!