node-red
node-red copied to clipboard
Change node not returning boolean if search/replace against regular expression is used
trafficstars
Current Behavior
Using change node. Search using regular expression (heat_cool|cool|heat|dry|fan_only) Replace with boolean (true) The output is string and not bolean
Expected Behavior
Result shoud be bolean as configured on the replace option
Steps To Reproduce
No response
Example flow
[{"id":"37eb6fa406834825","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"5b862c03f9935627","type":"inject","z":"37eb6fa406834825","name":"cool","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"cool","payloadType":"str","x":210,"y":260,"wires":[["1cf78297ad82816e"]]},{"id":"2c0458a574c287d5","type":"inject","z":"37eb6fa406834825","name":"off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":210,"y":300,"wires":[["1cf78297ad82816e"]]},{"id":"1cf78297ad82816e","type":"change","z":"37eb6fa406834825","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"false","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"heat_cool|cool|heat|dry|fan_only","fromt":"re","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":325,"y":280,"wires":[["0bc99ad65bc3fa1f"]],"l":false},{"id":"0bc99ad65bc3fa1f","type":"debug","z":"37eb6fa406834825","name":"debug 939","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":405,"y":280,"wires":[],"l":false}]
Environment
- Node-RED version: 3.1.0
- Node.js version: 16.20.2
- npm version:
- Platform/OS: docker image over armv6
- Browser: Chrome 117.0.5938.92
I noticed exactly the same problem. I hope there will be a fix soon.
For me, with 4.0.0-Beta.1 it still (or again) isn't working. As I see it, in the example flow, "Off" should be replaced with false, and "cool" and the other options in the regex should be replaced with true. In v4.0.0-beta.1 both are being replaced with false.