Triggering a flow when TV input changes

You can see in picture below, when TV is on Peacock, source lists it as such.

What would I setup to start an automation right when the source is switched to Peacock? All I can think is having an inject node check every 1 min, but theres gotta be some way I can use the events: state node; I just cant figure it out.

[{"id":"d5a8639e.d33e","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"c8fb8893.957528","type":"inject","z":"d5a8639e.d33e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1213,"y":45,"wires":[["4fb664dc.480cec"]]},{"id":"4fb664dc.480cec","type":"api-current-state","z":"d5a8639e.d33e","name":"","server":"ab3e2c53.e3491","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.tv_living_room","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1125,"y":144,"wires":[["4a922c9b.139044"]]},{"id":"4a922c9b.139044","type":"switch","z":"d5a8639e.d33e","name":"Check if source is Peacock","property":"data.attributes.source","propertyType":"msg","rules":[{"t":"cont","v":"Peacock","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1147,"y":225,"wires":[["cc7b8f92.f30f1"],[]]},{"id":"cc7b8f92.f30f1","type":"api-call-service","z":"d5a8639e.d33e","name":"Toggle test3","server":"ab3e2c53.e3491","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"toggle","entityId":"input_boolean.test3","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1133,"y":306,"wires":[[]]},{"id":"ab3e2c53.e3491","type":"server","name":"AvilaSmartHomeRpi","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

[{"id":"afc18ade.35ef38","type":"server-state-changed","z":"f61766ce.f85398","name":"","server":"","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.tv_living_room","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":250,"y":2496,"wires":[["37d7304f.70e51"],[]]},{"id":"37d7304f.70e51","type":"switch","z":"f61766ce.f85398","name":"","property":"data.new_state.attributes.source","propertyType":"msg","rules":[{"t":"eq","v":"Peacock","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":514,"y":2496,"wires":[["a05642f1.8ce7c"]]},{"id":"a05642f1.8ce7c","type":"debug","z":"f61766ce.f85398","name":"do things","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":668,"y":2496,"wires":[]},{"id":"13db27b3.64a7e8","type":"server-state-changed","z":"f61766ce.f85398","name":"","server":"","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.tv_living_room","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"$entity().attributes.source = \"Peacock\"","halt_if_type":"jsonata","halt_if_compare":"jsonata","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":250,"y":2544,"wires":[["b64d459a.116798"],[]]},{"id":"b64d459a.116798","type":"debug","z":"f61766ce.f85398","name":"do things","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":668,"y":2544,"wires":[]},{"id":"e930076a.668138","type":"trigger-state","z":"f61766ce.f85398","name":"","server":"","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"media_player.tv_living_room","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"property","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"Peacock","propertyValue":"new_state.attributes.source"}],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":240,"y":2592,"wires":[["cc6cac04.07a01"],[]]},{"id":"cc6cac04.07a01","type":"debug","z":"f61766ce.f85398","name":"do things","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":668,"y":2592,"wires":[]}]
1 Like

I swear, posting my question makes me able to figure it out on my own…sometimes.

I came up with your first option as well. But kudos to you for knowing the msg would now include new_state! That wasnt even in my screenshot and I didnt figure it out till I did an events: all debug.