Getting media player source in node red

I’d like to make an automation based on the current source of my vizio tv using the Vizio Smartcast integration.

The integration works great and I already have an automation on my Windows10 machine using MQTT and EventGhost to change the source based on an MQTT event. However, I cannot figure out how to “get” the source in node-red. How do I find out if the TV is set to say “HDMI-2”

image

Use an event state node and connect it to a DEBUG node. on the debug node select complete msg object. Now change the input on the TV and watch the debug and look at the data that comes out.

1 Like

I’ve got it coming through a template node now.

Now, my next hurdle is when the TV is already on and the source changes, it does not pick that up. How would I be able to capture when the source changes when the TV is already on?

From my experience, you need to go into the event state node for that and untick the “Output only on state change” option. That should allow it to trigger the flow any time an attribute changes as well.

Brilliant. That was exactly what I needed!

1 Like

May you please explain me how you get the source status with the template node?
i do not get how it’s working :slight_smile:
Is it possible for you to share thoses blocks?

I got this working using the Trigger State node and constraint like the following:

image

I also added another constraint to check if the old state was different, just to prevent excess trigging of this when other attributes get changed

Layout ends up nice and simple

This also triggers when the TV is turned on and off as well (if you don’t want that, then add more constraints to check for the TV state).

Thanks for your help!

In case of need, i did it this way:
image

A trigger state filters only the changes of the amp, and then the switch check for the new_state value then output depending on wanted values.

@

Here is the code to import both blocks in node red to easilly reproduce :slight_smile:

[{"id":"dacff821.ec7bd8","type":"trigger-state","z":"332a7a59.32aba6","name":"amp","server":"1a8176b8.732339","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"media_player.amp_salon","entityidfiltertype":"exact","debugenabled":true,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":90,"y":580,"wires":[["371ff164.badaa6","40018cc1.8c9eec"],[]]},{"id":"371ff164.badaa6","type":"switch","z":"332a7a59.32aba6","name":"amp_source","property":"data.event.new_state.attributes.source","propertyType":"msg","rules":[{"t":"eq","v":"Moode-Audio","vt":"str"},{"t":"eq","v":"PC","vt":"str"},{"t":"eq","v":"Switch","vt":"str"},{"t":"eq","v":"tv","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":250,"y":640,"wires":[["b4b2e337.6a1aa"],["54c33909.592638"],["54c33909.592638"],["54c33909.592638"]]},{"id":"1a8176b8.732339","type":"server","z":"","name":"Home Assistant","addon":true}]

Hope it helps!

Hey guys,

Can I use any tricks with the current state node to get this?

For example, I want to Spotify to change to an Alexa, but not if the source is my iPhone?