Problem comparing an attribute of a HA entity

I’m just starting into node-RED, and having trouble accessing the value of an attribute of a Home Assistant entity.

In this case I am wanting to check whether my nVidia ShieldTV is currently playing the desired TV/streaming channel/app.

  • On entering the flow I saved the desired target “app_name” to msg.app_name.
  • I use a HA “current state” node on Entity ID: media_player.shield_tv and outputting msg.data = entity
  • In the debug window, drilling down in the objects shows that data.attributes.app_name does contain the current ShieldTV entity.
  • However when I compare these two values in a switch node, the “otherwise” branch is taken.

Would someone please enlighten me on where I have gone wrong.

the == box you would choose string instead of msg and use the value you want to find, TV 9now, netflix, hbo, etc.

Sorry if I didn’t make my question clear.

I already have a switch node with 17 rules comparing app_name with the various TV channel names, in order to setup the adb_commands to start the various apps on the ShieldTV.
What I am wanting to do here is check whether the desired app is already running (or has been started correctly).

Somehow I doubt that node-RED developers included an option for “msg.” prefix if “==” can only be used to compare with a literal string.

Then the way you have it but there is a misspelling. Is app-name turning into app_name when you choose the copy path option? That dash is likely the cause of the problem.

DOH !!! I was sure I had double-checked the spelling and punctuation.

After 30-odd years programming I do know better !
The old case of a second pair of eyes :wink: Thank you !

1 Like

That was it !. I also took the opportunity to change the name of the name of “app-name” to “target_app”, since that is the name of the app I am wanting to run on the ShieldTV. Tested and working well.

thanks again