# Visually optimize my flow to reduce the number of nodes used

**URL:** <https://discourse.nodered.org/t/visually-optimize-my-flow-to-reduce-the-number-of-nodes-used/81003>\
**Category:** General\
**Tags:** home-assistant\
**Created:** [3 September 2023 12:28 UTC](https://discourse.nodered.org/t/visually-optimize-my-flow-to-reduce-the-number-of-nodes-used/81003 "2023-09-03T12:28:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [3 September 2023 12:28 UTC](https://discourse.nodered.org/t/visually-optimize-my-flow-to-reduce-the-number-of-nodes-used/81003/1 "2023-09-03T12:28:04Z")

</div>

Good morning and happy Sunday.

I have several (many) home assistant call service node to modify a value in Home Assistant entity. It works.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6ee897023729c7964cfd16ef9b408458fab4d68b.png)

What I'm trying to do is visually optimize my flow.  
I would like to be able to enter the dynamic "Data" field. So I can pass it values like, 48,49,50,51,etc ... and have only one generic node instead of 30 static ones.

The value circled in red would be dynamic

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b87745d0c89ccbfd4e9988fc6c78a80c92d41ff6.png)

Do you have any idea how to pass these values to the nodes? In this example, I'm using an inject node to clarify my request  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/acea423468b5f67eea495fb87bff3a62b7b01838.png)  
It doesn't work, but that's the final idea  
Thanks

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [3 September 2023 13:08 UTC](https://discourse.nodered.org/t/visually-optimize-my-flow-to-reduce-the-number-of-nodes-used/81003/2 "2023-09-03T13:08:11Z")

</div>

The JSONata would be

```auto
{"option": $$.payload}

```

Assuming the input is msg.payload. There should be no need for the value change node.

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [3 September 2023 13:18 UTC](https://discourse.nodered.org/t/visually-optimize-my-flow-to-reduce-the-number-of-nodes-used/81003/3 "2023-09-03T13:18:04Z")

</div>

and ... 🎼 **it works** as suggested. That's just great.  
Many thanks @E1cid for the quick and functional response

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 September 2023 13:18 UTC](https://discourse.nodered.org/t/visually-optimize-my-flow-to-reduce-the-number-of-nodes-used/81003/4 "2023-09-17T13:18:57Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
