Hello and welcome to the forum. I am not a professional and unfortunately I cannot help directly. But maybe that will help you … Go to “Developer Tools” then to “Events” now enter “state_changed” in the field “Event to subscribe to” and press “Start Listening”. Now you start Netflix. An entry would then have to be created here. Maybe this will help you, if not someone who has already set up will get in touch soon …
Have fun continuing to set up HA …
So in the end i didnt manage to figure out a way to “check which app” is running But I managed to find the correct states to switch between the lights.
- id: '1576862696029'
alias: ShieldTV Lights Off
description: ''
trigger:
- entity_id: media_player.nvidia_shield
from: standby
platform: state
to: playing
- entity_id: media_player.nvidia_shield
from: paused
platform: state
to: playing
condition: []
action:
- device_id: 051620551ed94880be6aad00f85e8560
domain: light
entity_id: light.dinner_light
type: turn_off
- id: '1576865173829'
alias: ShieldTV Lights On
description: ''
trigger:
- entity_id: media_player.nvidia_shield
from: playing
platform: state
to: standby
- entity_id: media_player.nvidia_shield
from: playing
platform: state
to: paused
condition: []
action:
- device_id: 051620551ed94880be6aad00f85e8560
domain: light
entity_id: light.dinner_light
type: turn_on
(excuse the amount of bulbs)
my old used “idle” term didnt work and i had to use “standby”.
I’ll keep looking for a way to determine the apps tho, that’d be really helpful.
I’m not at home right now to test, but I belive that the currently running app is represented as an attribute and can be tested with a template. If you go into Developer Tools->States and find your Shield, you should see an attribute with a long string indicating the current app if one is active. For YouTube TV, for instance, you’ll see something like “com.google.android.youtube.tvunplugged”. Strings for other apps can be found here.
You can either use a template trigger or condition to check it. I used to have an automation that did exactly this, but I found that a better way to do what I needed to do and got rid of it.
@rccoleman seeing the app used on a Shield is only possible if you use the Android TV integration and set up an ADB Server. I have that set up and and it works well. I am able to detect whatever app is running on my shield and create automations around them.
Nope, that seems to have changed with 0.101. I have it setup with the Python implementation, and it shows the actually running app as an attribute of the media player entry.
@rccoleman Would you mind sharing your better solution?
I was using a condition in a script to check if an ADB command had actually launched an app because it was not working reliably. It turned out that I had a race condition causing the instability, so I fixed that and removed the extra checks and redundant actions.
Rube Goldberg is sometimes the best approach I swapped to your method actually it works pretty good. ADB sometimes seems a bit “slow” and light-dimming only happens after like 10-20seconds but hey if it works, it works!
it might pick up the change more quickly. I haven’t tested it though. I was unable to find a better way to control lights based on running app but I also stopped when I found that adb method.