Use Apple TV current App as trigger with Node RED

Hi,

In the development tools under attribute my Apple TV shows the current opened App with for example “app_name: YouTube”

I tried to use it in an automation using the current state node. Unfortunate it didn’t work. Is there any other way to use “app_name:” as a trigger or using the current state?

Thanks for your help!

Use a trigger state. In the condition set to property then add the attribute path in the box. It should auto populate.

Thank you! This works so far and I can differentiate between the apps. I actually only need it to check if a specific App is open or not within a workflow and want the node only be “active” when there is a trigger on the input. At the moment the node triggers like every second which is not usable at the moment. Is there any way I can make it work only if there is a trigger on the input?

Where it says condition there is a little + button. Add the condition for old_state of the same attribute is not youtube

Edit: Since I am unsure of why it keeps triggering, an event state has a lot of variables that can be covered by checking the boxes.

I use the trigger:stade node where I don’t have the checkbox. I tried it like you said but this just blocks everything and the node does not what it is supposed to do.

BTW: I use app_id because not every app does show its name in the attribute.

To make clear what my goal is. When there is an Alexa announcement I want to check whether there is a streaming app like Youtube or an app for live TV open. In case of a streaming app I want to pause the stream and in case of a live TV app I only want the sound to be muted.

Okay so the event will start with an alexa announcement, then check the current state of the media player. From the current state you will get the value of app_id then in the switch depending on the value you can do different things.

image

[{"id":"04d1c13dbe23b951","type":"server-state-changed","z":"60f2d2277843c698","name":"alexa event","server":"6b1110b5.183a4","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":630,"y":640,"wires":[["9208d927eb2fb6b4"]]},{"id":"9208d927eb2fb6b4","type":"api-current-state","z":"60f2d2277843c698","name":"media player","server":"6b1110b5.183a4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"media player here","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$entity().attributes.app_id","valueType":"jsonata"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":850,"y":640,"wires":[["0deaa236a9fc2a3b"]]},{"id":"0deaa236a9fc2a3b","type":"switch","z":"60f2d2277843c698","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"youtube","vt":"str"},{"t":"eq","v":"live tv","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":1070,"y":640,"wires":[[],[],[]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]
1 Like

You are my hero :smiling_face:. This is exactly what I am looking for. Works perfect. Thank You :pray:.