Pass value from one node to another [SOLVED]

I’m trying to create a flow that limits the max volume of the living room tv based off of a slider on the front end. These are the entities I have

media_player.living_room (sonos playbar)
sensor.living_room_tv_volume (Template sensor that extracts the volume_level attribute from the device media_player.living_room. Value range is 0 to 1)
input_number.tv_volume_slider (front end slider that gives a value of 0 to 1)

The way I picture the flow to work is when the tv volume is changed, if it’s over the value of the slider then set the tv volume to whatever value the slider is set to. This would keep the tv volume to whatever lever the slider is set to.

Any idea how I can create this flow? I have a rough idea but I can’t figure out how to get the vol slider value into the set volume data for media_player.living_room.

image

[{"id":"294f6938.97b976","type":"server-state-changed","z":"316b7737.65f728","name":"TV Volume","version":1,"entityidfilter":"sensor.living_room_tv_volume","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"$entities(\"input_number.tv_volume_slider\").state","halt_if_type":"jsonata","halt_if_compare":"gt","outputs":2,"output_only_on_state_change":true,"x":110,"y":1360,"wires":[["b2ecc7e5.707958"],[]]},{"id":"b2ecc7e5.707958","type":"api-call-service","z":"316b7737.65f728","name":"","version":1,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.living_room ","data":"{\"volume_level\": $entities(\"input_number.tv_volume_slider\").state}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":354,"y":1360,"wires":[[]]}]

When I import your flow the entity gets removed from the svc node. When I try to re-enter the entity, media_player.living_room, I get an error message:

Error merging entity id into data

Also… as a side note, I did manage to get this to work. But it’s not nearly as simple as your solution. And it does have one bug. If I change the slider value then I have to change the tv volume twice before it works. Weird.

[{"id":"875c92de.4a269","type":"tab","label":"Livimg Room TV Volume Lock","disabled":false,"info":""},{"id":"17e41324.d0a2ad","type":"server-state-changed","z":"875c92de.4a269","name":"LR TV Volume","server":"d4312745.318c28","version":1,"entityidfilter":"sensor.living_room_tv_volume","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":180,"y":200,"wires":[["a3bd7efe.cc71b8","fbcf0a6e.ca31b8"]]},{"id":"a3bd7efe.cc71b8","type":"api-current-state","z":"875c92de.4a269","name":"Vol Slider State","server":"d4312745.318c28","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_number.tv_volume_slider","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":240,"y":280,"wires":[["a8010aca.364f08"]]},{"id":"a8010aca.364f08","type":"change","z":"875c92de.4a269","name":"","rules":[{"t":"set","p":"slider_level","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":280,"wires":[[]]},{"id":"fbcf0a6e.ca31b8","type":"switch","z":"875c92de.4a269","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"slider_level","vt":"flow"}],"checkall":"true","repair":false,"outputs":1,"x":470,"y":200,"wires":[["8dbc1f34.7f9a2"]]},{"id":"8dbc1f34.7f9a2","type":"change","z":"875c92de.4a269","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"slider_level","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":200,"wires":[["6056e8f4.48014"]]},{"id":"6056e8f4.48014","type":"api-call-service","z":"875c92de.4a269","name":"","server":"d4312745.318c28","service_domain":"media_player","service":"volume_set","data":"{\"entity_id\":\"media_player.living_room\",\"volume_level\":\"{{payload}}\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":820,"y":320,"wires":[[]]},{"id":"d4312745.318c28","type":"server","z":"","name":"Home Assistant"}]

I would guess you’re using an old version of node-red-home-assistant-websocket

You guessed right. Was running 4. something. I updated to the latest 5.0.2 and I still gives me the same error.

I was referring to node-red-contrib-home-assistant-websocket, not the hass.io addon, but I believe 5.0.2 of the addon has the latest release in it.

That error message no longer appears in the latest release make sure you have refreshed the node-red UI after you upgraded.

That was it! Works like a champ. And so much simpler than what I came up with. Thanks!!