I was chatting with @markus (surpise you?) and we were discussing boolean and strings. Generally, in Node-RED things tend to flow better as boolean as you’re only dealing with true and false. But, in order to do that, you have to figure out how to convert these. This will convert a true or false string and make it a boolean. 3 different use cases.
only convert if it is a string and that string content is either true or false only. Otherwise do nothing.
A thing to note about dicts and booleans in js, when you set a dict key to a boolean it will actually use the string representation of the boolean. If you use both ‘true’ and the boolean true they are the same value and would be duplicate keys. The beauty is that it also works when referencing it, so if you try to access with the boolean true or the string ‘true’ you’ll get the same item. With that said, the above dict works also for boolean input for the previously described reason, not just the strings.
You can test the above statement with the following in a function node: