How to conditionally pass-through a numeric value

I want logic that will pass-through a numeric value input if an input_boolean is true.

I have a feeling the Switch node is an appropriate node, but am having trouble defining the condition correctly.

Should I be selecting the Property type as Global ? That is: "Global.input_boolean.test_mode"

So you have a msg being passed thru the wires. Let’s say the msg has a msg.payload which is a number 55. And the msg has a msg.test property that is a Boolean and in this case it is true.

You could easily use a `switch node to test msg.test to see if it was a Boolean and in this case the msg would be passed on to the next node.

thanks for your response zenofmud.

So I would use a Change node (for example) to add the boolean property to the message, and then use a switch node to test that property? It seems like an extra step than should be needed, but if it works, I'm happy. However, I still have the same issue in the change node in referring to the input_boolean value. JSON, Jsonata etc are all a bit of an unknown to me. However, if it I could work-out how to read the value of the input_boolean in a Change node, I could probably use the same method to refer to the input_boolean in the switch node? - and miss the extra step of the Change node ?

ah - I found it. You can refer to an input_boolean in Jsonata with the following: $globalContext("homeassistant.homeAssistant.states[''].state")

I was able to use this in a Switch node so that the message value would only pass through if the input_boolean is true.

Problem solved.

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