Halt if msg.payload not equal true

I just started using node red and thought i would tinker by converting my movie light automation to a node red flow. At a basic level it works great, play dims, pause/stop return to full brightness.

The issue i’m having is I only want this to occur if the media_content_type equals “movie”. I used get template node to get a boolen based on {{ states.media_player.xboxone.attributes.media_content_type == “movie” }}, if a movie is playing this outputs true anything else is false.

I can’t seem to figure out how to pass or halt the payload based on that template output.

In your current flow you would just drop in a switch node between the get template node and the call-service node and check for payload equals true. For your information is would be faster to use a current-state node the get the media_player.xboxone.attributes then using the get-template node.

My recommendation since you’re already using a trigger-state node is to add the check for it in there.

1 Like

I had tried using the constraints initially but i see now I was using the wrong state type and property. Will give that try. Thanks so much!

Hmmm. Actually i don’t see that state type selection. Not sure if it matters or not.

Yeah my screenshot is from https://github.com/zachowj/node-red-contrib-home-assistant-websocket not sure what version you are using.

Getting the same error I was initially getting.

constraint comparator: failed entity "media_player.xboxone" property 
"new_states.attributes.media_content_type" with value undefined failed "is" check against (str) movie

new_state not new_states

ahh. thanks.

One issue is when i stop the movie the constraint fails because technically that attribute no longer exists.

could move it to an output, so you have two custom outputs one for media_content_type is movie and one state is stopped

1 Like

Ohh. Ok. I didn’t fully understand the outputs section of the trigger node. I see now. Thanks again.