biddster / node-red-contrib-time-range-switch

A simple Node-RED node that routes messages depending on the time.
17 stars 7 forks source link

Programmatic Configuration of the Node #38

Open MedusaLu opened 3 years ago

MedusaLu commented 3 years ago

Hi , I am to set the parameters of the node by passing the config object. I am passing a message with an included config object and a payload, but the message is not routed according the passed config parameters nor is thte __config object removed from the message as outlined by the documentation.

Any hints on this?

Thanks a lot.

Regards, Robert

bigfeetneedbigboots commented 1 year ago

The msg.__config works for me. Have a look at this I made for you:

[{"id":"9158a5b58f0b9a16","type":"change","z":"ef611c41c0ce69f5","name":"setup time range with msg.__config to all day","rules":[{"t":"set","p":"__config.startTime","pt":"msg","to":"00:00","tot":"str"},{"t":"set","p":"__config.endTime","pt":"msg","to":"23:59","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":3060,"wires":[["bbced30f0cf09146"]]},{"id":"bbced30f0cf09146","type":"time-range-switch","z":"ef611c41c0ce69f5","name":"time range","lat":"-33.870453","lon":"151.208755","startTime":"23:59","endTime":"23:59","startOffset":0,"endOffset":"1","x":1130,"y":3000,"wires":[["504e82d5d5e9674c"],["a33aa441f4869362"]]},{"id":"fa3d871882bd5182","type":"inject","z":"ef611c41c0ce69f5","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"a","payloadType":"str","x":550,"y":3000,"wires":[["bbced30f0cf09146"]]},{"id":"129219d4729b028b","type":"inject","z":"ef611c41c0ce69f5","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"b","payloadType":"str","x":550,"y":3060,"wires":[["9158a5b58f0b9a16"]]},{"id":"504e82d5d5e9674c","type":"debug","z":"ef611c41c0ce69f5","name":"within","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1470,"y":3000,"wires":[]},{"id":"a33aa441f4869362","type":"debug","z":"ef611c41c0ce69f5","name":"outside","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1480,"y":3060,"wires":[]},{"id":"4e9a03a037f882f3","type":"change","z":"ef611c41c0ce69f5","name":"setup time range with msg.__config to midnight/nill","rules":[{"t":"set","p":"__config.startTime","pt":"msg","to":"00:00","tot":"str"},{"t":"set","p":"__config.endTime","pt":"msg","to":"00:00","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":3120,"wires":[["bbced30f0cf09146"]]},{"id":"67588179028b8969","type":"inject","z":"ef611c41c0ce69f5","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"c","payloadType":"str","x":550,"y":3120,"wires":[["4e9a03a037f882f3"]]}]