-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to help with state detection! #12
Comments
Thi I get when I get properties on playing video on vlc On paused custom_components.androidtv.media_player] Output of command 'GET_PROPERTIES' from 'media_player.minim8s2': {'screen_on': True, 'awake': True, 'wake_lock_size': 1, 'media_session_state': 2, 'current_app': {'package': 'org.videolan.vlc', 'activity': 'org.videolan.vlc.gui.video.VideoPlayerActivity'}, 'audio_state': 'idle', 'device': 'hdmi', 'muted': False, 'volume_level': 4} What should be added or change in order to get proper player status |
It looks like the python-androidtv/androidtv/firetv.py Lines 150 to 155 in 38ac4fc
It would be great if you could fork the repo, make some changes, test it yourself, have others test it, and submit a pull request! |
@earth08 the "state-detection" branch should yield better results. |
@earth08 is it working now? Is the state detection working for VLC? |
Sorry to reply it lately, |
this are the results from some few apps here are 2019-03-16 08:01:53 INFO (SyncWorker_4) [custom_components.androidtv.media_player] Output of command 'GET_PROPERTIES' from outpt at homescreen 2019-03-16 08:03:40 INFO (SyncWorker_6) [custom_components.androidtv.media_player] Output of command 'GET_PROPERTIES' from output on vlc it does shows as standby 2019-03-16 08:15:10 INFO (SyncWorker_9) [custom_components.androidtv.media_player] Output of command 'GET_PROPERTIES' from output when playing on vlc 2019-03-16 08:17:02 INFO (SyncWorker_11) [custom_components.androidtv.media_player] Output of command 'GET_PROPERTIES' from output when vlc paused 2019-03-16 08:18:13 INFO (SyncWorker_12) [custom_components.androidtv.media_player] Output of command 'GET_PROPERTIES' from |
I removed some posts that weren't directly related to state detection. I'm leaving it up to you and the community as a whole to collect data (as you've done) and implement better state detection. It's not that hard to modify the code, and as long as you don't have any syntax or programming errors, nothing catastrophic will happen if your state detection logic is flawed. |
After some study on my output, EDIT: please use code blocks! else:
if wake_lock_size == 1:
state = constants.STATE_PAUSED
elif wake_lock_size == 2:
state = constants.STATE_PLAYING
else:
state = constants.STATE_STANDBY
# ### else:
# ### if wake_lock_size == 1:
# ### state = constants.STATE_PLAYING
# ### else:
# ### state = constants.STATE_PAUSED |
state off is now working well |
I've also found (with the Jellyfin app), that there are two wake locks when playing, and one when paused. Perhaps the default of "1 wake lock == paused" should be changed, or was that value chosen specifically? This was on a Fire TV stick. |
'Unavailable' means that the ADB connection is not intact. Since HA can't turn the device on, I think unavailable is the appropriate state. But that has to do with the Home Assistant component, not this package. |
That is the logic used in the I think the
|
Great, I'll do that shortly |
I've raised #17 to fix this for Jellyfin |
Hi, Unfortunately, some changes in the state logic made it "playing" all the time instead of "pause" for my case (Philips TV). It was some version when it was correct playing/pause section, but I cannot find that vestion anymore.
Any idea what is wrong? |
You're not using the right component. Use the official component. |
Just chirping in to confirm that
Is the way to go for Amazon Video too on a Fire TV 4K |
Hi Jeff, I have a Kogan TV (I think it's a rebranded TCL, or similar... not really sure who manufactured it as Kogan uses a few OEMs) and currently the The following adb command does work, if I patch it into the python on my instance:
How can I go about getting this into the package for TVs that it works on? |
This issue needs to be done first: #255 After that's done, it shouldn't be too hard to customize the command used the get the HDMI input and the code that processes the result. |
State detection diagnostics
Assuming you're using the Home Assistant Android TV component, here's how you can help improve state detection.
This package determines the state in the
AndroidTV.update
/FireTV.update
methods using a collection of properties and reports that state to Home Assistant. You can see what those properties are by using the HA serviceandroidtv.adb_command
with"GET_PROPERTIES"
as thecommand
argument -- they will be logged at the INFO level and they will be stored in the media player'sadb_response
attribute (HA 0.94+), which can easily be viewed on the States tab. You can read more about theandroidtv.adb_command
service at the bottom of the Android TV documentation.The state detection logic will differ depending on the app. So open an app, send the
"GET_PROPERTIES"
command a few times while it's idle / on standby, playing, and paused, and try to figure out a better way to determine the state. Pull requests are welcome!The text was updated successfully, but these errors were encountered: