dwaan / homebridge-adb

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

Trigger for playback activity #15

Closed grgmll closed 3 years ago

grgmll commented 4 years ago

Could you add a occupancy sensor to monitor Amazon Video playback activity (com.amazon.avod/.playbackclient.FireTvPlaybackActivity) in order to do an automation in homekit?

Thanks

dwaan commented 4 years ago

Hey. I think it can be done. It might be an update or a new plugins in the future.

I did similar thing with my NVIDIA Shield on separate script to monitor app that play sound so I can switch on/off my receiver automatically.

But the playback activities that you mention might be device specific? Could you explain more what kind of variable/string that needed to be monitor via ADB?

For example, there’s an ADB command that can return current app id that is on foreground or app id that currently playing sound, just like what I wrote in README.md. Those are available in all android devices.

grgmll commented 4 years ago

adb -s your-device-ip shell dumpsys media_session | grep "state=PlaybackState"

return:
state=PlaybackState {state=3, position=569, buffered position=0, speed=1.0, updated=164836137, actions=173350, custom actions=[], active item id=-1, error=null}

state=3 => play state=2 => pause and stop

grgmll commented 3 years ago

thank you for adding this feature.

dwaan commented 3 years ago

You’re welcome