How to change Input_Select value in Node-RED

Change the data field to JSON and not J:expression where you use {{payload}}

New there would have been something i missed! Thanks for pointing that out. Once i did that i got this error.

Call-service error. expected float for dictionary value @ data[‘value’]

so changed my data field to {“value”: {{ payload }}} and thats done the trick!

Thank you very much!

Fonctionne pour moi, merci !

Thanks all for sharing !!

Second time I landed on this thread after searching for a solution to structure input data with flexible values from Node-Red. Old thread but still helpful. Trying to understand how the input from node-red will match the HA yaml when using the service call node wasn’t obvious to me at first. Took a while for my slow brain.

:man_teacher: Adding to what is already in this thread, to help others… here it is.

Node-Red to feed Dropdown Helper in Home Assistant with flexible options.
Structure of the payload to the HA websocket-node.

The case: The options in the dropdown needs to change depending on what items are available. Example current online/reachable entities (ex lights in IKEA dirigera). Or in a timer function showing what timer events are created and active.

Created a Dropdown Helper in HA for the Fronted.

dropdownImage

First testing: In Node-Red use a basic payload + an empty service call node with your server selected (only). Example:
Flow

Instead of setting up all data in the HA Service Call Node i work with function Nodes and here is the input. Makes it easier to undertand if you see this structure and can compare with the yaml format.

Link to see Yaml in HA: Home Assistant Documentation “Input Select”
Under the example " To dynamically set the input_select options"

Function Node Payload to - HA Service Call Node:
payload image

Explained

Similar to the Yaml config this looks the same. Starts and ends with brackets. The items separated by comma. Names as always with quote signs.

"options": ["Timer 1","Timer 2","Timer 3"]

This Format shows the array in a row and how its similar to the J: expressions shown in other examples in the thread.

Now, change the source to getting the options from another input.
dataOptionChanged
Changing the sections with the brackets to the input of a variable or msg.payload containing an array with the options presented in the select menu. In my case msg.idNameArray.

  1. Objets with my list of timer action events (from a database or context)
  2. Pick the fields to use for my menu and create a new array, forwarded in the flow to the function node with payload feeding the service call node.

First to show the source. Second image to the right how it picks up the array created.

Details

I created a new array from the “timername” in the objects that will be forwarded to options. This array contains the names to be displayed. As this will be different depending on how many items available it will keep your list flexible in the dropdown menu if you keep it up-to-date.

So hopefully this will help you get started and setup your flexible ha dropdown helper easy and fast. Something that can appear so simple when you understand how to. :face_with_monocle:
Good luck.