I have a Sony Android TV with built-in Chromecast. The Chromecast integration provides lot of information about which app is playing content on the TV. I see something like this in the events capture:
I want to create different actions in automation depending on the state and app_name. So, if state is playing and app_name is Plex, then do some action. If state is playing but app_name is Netflix then do something else. I can use the state in condition clause of automation and set it to playing but how do I use the app_name attribute?
condition: state
entity_id: media_player.bedroom_tv
state: playing
This can also be done using a State or Numeric State condition, by simply adding āattributeāā¦ or using the drop down āAttributeā selector in the UI editor.
condition: state
entity_id: media_player.bedroom_tv
attribute: app_name
state: Plex
I want to be able to check status if my roku is playing, and if it is then do nothing else if not playing then hit select on roku remote to select profile. At the end of the day, i am trying to play a show in the morning for the kids automatically but with disney plus and other apps requiring you to select a profile, I need to hit select if it is asking for a profile. my issue is that it doesnt ALWAYS ask what profile because it will remember. Here is what I been using but has been hit or miss.
Can you format your code so it is readable please?
Highlight it and click this
Your question really has nothing to do with this thread. Youāre asking for a condition based on the state of the media_player not one of itās attributes.
I think standby/home are the correct state for a Roku, at least on my Roku TV it is.
I think I misunderstood the first time I read your question. If you only want to the remote command to run if itās not playing you donāt need the if / else, just a not condition if this is the last thing to run in the script/automation.
Did you click the little arrow beside āScript Snippetā? If I understood what you were asking for correctly, I think I already answered your question.
im a couple months new to any scripting at all but was forced by insteon shutdown. at the end of the day didnt realize how much i was missing. thanks for bareing with me on learning terms liker attributes and coding
No worries. I realized there was an error (I changed something and didnāt finish). Make sure you grab the edited version basically you just need this before the remote.send_commend call.
- not:
- condition: state
entity_id: media_player.woody_s_new_stick_in_the_living_rm
state:
- standby
- home
How would you do this using av numeric state condition?
Iām trying to read the set temperature from a climate entity, where the entity name is āclimate.heating_bathroomā and the attribute is āTemperatureā. I like to make a condition that checks if the attribute is a certain number, for instance ā22ā, and checing it by using a Value Template.
Numeric state conditions are used for mathematical comparisons āabove/greater thanā or ābelow/less thanā. This type of condition can use value templates to modify the value before testing it.
State conditions are used to check if a state or attribute is equal to a given value.
Template conditions can perform both of the types of logical checks described above but use a value template.