Updating node properties programatically

1,834 views
Skip to first unread message

Csongor Varga

unread,
Nov 14, 2016, 4:59:27 AM11/14/16
to Node-RED
Hi All,

Let's say I have a delay which is set to 5 seconds. Can I somehow change that value during runtime? For example if I have a function node? I noticed when I Ctrl+Space in the code editor to bring up the hints, I see the IDs of the flow and the nodes inside. So I was just trying to <flowid>.<nodeid>.timeout = 10; But that is not accepted.

This must be some fundamental node.js or node red thing, but I have not been able to figure out yet.

Regards,
Csongor

Sebastian Barwe

unread,
Nov 14, 2016, 5:25:46 AM11/14/16
to Node-RED
Hi Csongor,

you cannot change configuration dynamically - though some nodes provide reconfiguration by special msg properties.
There is no event for nodes like "configuration changed" to handle such stuff dynamically nor is there some kind of registration known configuration properties - so there is no general possiblity to change it while running as certainly nodes will not support this situation (like reinitialize timers etc.)

Nevertheless you may redeploy a certain node to reiinitialize it with a new confgiguration. See the following post how this can be done:


Br
Seb

Csongor Varga

unread,
Nov 14, 2016, 5:38:09 AM11/14/16
to Node-RED
Thanks a lot. So it seems it is quite difficult to develop flows that respond to parameters set on for example on the UI. Unless it is somehow implemented in the input message which is not the case in most of them.
But I get the idea that you linked and it would work for me too.

Sebastian Barwe

unread,
Nov 14, 2016, 5:46:17 AM11/14/16
to Node-RED
For reference: I just dropped a flow about the idea http://flows.nodered.org/flow/6fe183c197b3464a1fe4d89744e068ff

Dave C-J

unread,
Nov 14, 2016, 6:24:53 AM11/14/16
to node...@googlegroups.com
Hi Csongor, 

a lot of nodes do allow msg properties to set their configuration, but delay does not. This was a deliberate choice as changing delays dynamically could lead to confusing results... for example if I send a load of messages with a 30 sec delay then change to a 2 sec delay - any new messages will arrive before the "old" ones. 
But these things are never set (completely) in stone, and we are happy to discuss changing it.
(Or indeed it's not hard to imagine a function node that uses setTimeout to create a custom delay node...)

Or is your point more general about lots of properties ?

Csongor Varga

unread,
Nov 14, 2016, 9:31:43 AM11/14/16
to Node-RED
Hi Dave,

I am trying to use node red for home automation. I was using another product which is more design on the visuala than programming. This is why I liked node red from the start.

First thing I wanted to do is sprinklers. I would open a valve wait for a few minutes for a zone to get water and turn off the valve. And obviously would like to control the time the zone is on. Hence I was looking at doing this with the delay. But I totally understand potential issues is may cause in a message queue.

Or one more example: I want to start a process and I would change the start time of the inject node. And I would like to do that from the UI.

I am new to node red, so I probably should not recommend any changes, but would love to hear your suggestions for the above cases.

Regards,
Csongor

Dave C-J

unread,
Nov 14, 2016, 10:03:34 AM11/14/16
to node...@googlegroups.com
Hi

the trigger node can be set to turn off again after a suitable delay (and can be re-triggered/extended if required.

There are several timers in the flows.nodered.org site - eg just type scheduler into the searchbox... that can be used to set up all sorts of time sequences. (But yes - are not integrated into the UI)
Message has been deleted

Csongor Varga

unread,
Nov 14, 2016, 1:49:52 PM11/14/16
to Node-RED
Dave, thanks again for your response. I am afraid I am still missing some vital basics (maybe even linux basics). I tried installing a few more nodes, but they are not appearing in note-red and I am getting messages like this:
pi@OpenHAB:~ $ sudo npm install node-red-contrib-calendar-trigger

npm WARN engine node-red-contrib...@0.9.1: wanted: {"node":"^0.12.7"} (current: {"node":"0.10.29","npm":"2.15.11"})
npm WARN unmet dependency /home/pi/node_modules/node-red/node_modules/node-red-node-serialport/node_modules/serialport/node_modules/node-pre-gyp/node_modules/tar-pack requires debug@'~2.2.0' but will load
npm WARN unmet dependency /home/pi/node_modules/debug,
npm WARN unmet dependency which is version 2.3.2
node-red-contrib...@0.9.1 node_modules/node-red-contrib-calendar-trigger
└── cr...@1.1.0 (moment-...@0.3.1)

I hope it is not about an incorrectly installed node-red. I am using a rpi3. But since I have done so much since I started, I don't even remember what article I followed. My node-red is 0.15.2.

Csongor

Peter Scargill

unread,
Nov 14, 2016, 1:54:13 PM11/14/16
to Node-RED
Better still  - type in "bigtimer". Sorry I had to.

Csongor Varga

unread,
Nov 14, 2016, 2:03:06 PM11/14/16
to Node-RED
Pete, I do have big timer, and it is awesome. But my original question is the same for bigtimer.

Peter Scargill

unread,
Nov 14, 2016, 2:06:09 PM11/14/16
to Node-RED
Yes. of course - you are right - well I am stuck with the same basic mechanisms to work with as everyone else.  At this point I don't know how to dynamically change those settings - obviously as you know, BigTimer can accept inputs but that's not what you want - I'll continue to look in here enthusiastically to see if solutions appear.

Dave C-J

unread,
Nov 14, 2016, 2:17:09 PM11/14/16
to node...@googlegroups.com
Hi you need to be in the user Node-RED directory - usually ~/.node-red  when you install any nodes...
or use the new palette manager option in the UI.

Dave C-J

unread,
Nov 14, 2016, 2:21:21 PM11/14/16
to node...@googlegroups.com
no Peter - you didn't really have to - but I knew you would. 8-)

Csongor Varga

unread,
Nov 14, 2016, 2:27:33 PM11/14/16
to Node-RED
Well, is it possible to get this information from the input message? Like if I pass something in which has msg.payload.ontime = 1130, than you change the On time to 11:30?

Csongor Varga

unread,
Nov 14, 2016, 2:35:35 PM11/14/16
to Node-RED
Thanks, I got it now.

Peter Scargill

unread,
Nov 14, 2016, 2:37:27 PM11/14/16
to Node-RED
Am I that predictable :-(

Ok "new palette manager option in the ui" - come on - enlighten us - I updated the dashboard not that long ago and I'm not seeing a 
palette manager??

Peter Scargill

unread,
Nov 14, 2016, 2:39:24 PM11/14/16
to Node-RED
Well I COULD (and Dave will tell me if I'm wrong) but there's no way to make that permanent - ie to use it to go change the defaults that you would set up in the HTML page.

Csongor Varga

unread,
Nov 14, 2016, 2:52:44 PM11/14/16
to Node-RED
So it would be more accurate (and in line with the concept) to have a node which has no property at all (just a name), and the timer function (e.g. on time, off time, lat, long, etc.) get set up by an initial message. And until the message arrives, the node is inactive. 

Peter Scargill

unread,
Nov 14, 2016, 2:54:19 PM11/14/16
to Node-RED
I guess at some time, we'll get non-volatile variables - and if we had those that could be unique to a given instance of a node, then over-writing the defaults would be trivial.

Nicholas O'Leary

unread,
Nov 14, 2016, 3:58:09 PM11/14/16
to Node-RED Mailing List
Peter - palette manager in the editor, not the dashboard. As described in the release blog post - https://nodered.org/blog/2016/10/11/version-0-15-released

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/a561471c-e014-4f93-9d8b-cbfcdadf5899%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Csongor Varga

unread,
Nov 14, 2016, 4:18:33 PM11/14/16
to Node-RED
I think I found a neat solution to the time problem:
I have two sliders on the UI (one for hour, one for minute), I put them together in a function and store the time in a global variable. 
Separately there is an inject which executes every second/minute. The date part is cut from the inject timestamp (using setFullYear(2000,01,01) which I used for the global variable as well). This goes into a swtich where is gets compared with the global variable. Output is either before, or after the time specified on the UI.

Let me know what you think:

[{"id":"463827ad.2066a8","type":"tab","label":"Sprinkler"},{"id":"4075c0aa.96a66","type":"ui_slider","z":"463827ad.2066a8","tab":"156af96f.f8fd27","name":"Hour","topic":"timehour","group":"Sprinkler","order":1,"min":0,"max":"23","x":319,"y":45,"wires":[["a9762b58.fd4138"]]},{"id":"b6f0113b.9ce52","type":"ui_slider","z":"463827ad.2066a8","tab":"156af96f.f8fd27","name":"Minute","topic":"timeminute","group":"Sprinkler","order":1,"min":0,"max":"59","x":318,"y":89,"wires":[["a9762b58.fd4138"]]},{"id":"af4b553a.5c5098","type":"ui_text","z":"463827ad.2066a8","tab":"156af96f.f8fd27","name":"Time:","group":"Sprinkler","order":1,"format":"{{msg.payload}}","x":754,"y":62,"wires":[]},{"id":"a9762b58.fd4138","type":"function","z":"463827ad.2066a8","name":"Calculate time","func":"global.set(msg.topic,msg.payload);\nvar hour = global.get(\"timehour\");\nvar minute = global.get(\"timeminute\");\nif (hour!==undefined && minute!==undefined) {\n    var mytime = new Date();\n    mytime.setHours(hour, minute, 0);\n    mytime.setFullYear(2000,01,01);\n    global.set(\"start\",mytime);\n}\nmsg.payload = hour + \":\" + minute;\nreturn msg;","outputs":1,"noerr":0,"x":561,"y":62,"wires":[["af4b553a.5c5098"]]},{"id":"45bb7d91.870724","type":"inject","z":"463827ad.2066a8","name":"","topic":"TempCheck","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":162,"y":175,"wires":[["b47f53d6.d4f53"]]},{"id":"b47f53d6.d4f53","type":"function","z":"463827ad.2066a8","name":"Remove date","func":"var current = new Date();\ncurrent.setFullYear(2000,01,01);\nmsg.payload = current;\nreturn msg;","outputs":1,"noerr":0,"x":412,"y":175,"wires":[["d1e5d210.8c577"]]},{"id":"d1e5d210.8c577","type":"switch","z":"463827ad.2066a8","name":"Before or after start","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"start","vt":"global"},{"t":"gte","v":"start","vt":"global"}],"checkall":"true","outputs":2,"x":235,"y":280,"wires":[["78a687e8.08d5b8"],["d54c52a0.ca542"]]},{"id":"78a687e8.08d5b8","type":"change","z":"463827ad.2066a8","name":"Change to ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":486,"y":246,"wires":[["88e90c1f.59a64"]]},{"id":"d54c52a0.ca542","type":"change","z":"463827ad.2066a8","name":"Change to OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":484,"y":299,"wires":[["88e90c1f.59a64"]]},{"id":"88e90c1f.59a64","type":"rpi-gpio out","z":"463827ad.2066a8","name":"","pin":"11","set":"","level":"0","out":"out","x":714,"y":282,"wires":[]},{"id":"156af96f.f8fd27","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":"1"}]


Csongor Varga

unread,
Nov 14, 2016, 4:20:23 PM11/14/16
to Node-RED
I think I made an issue posting the code:

[{"id":"463827ad.2066a8","type":"tab","label":"Sprinkler"},{"id":"4075c0aa.96a66","type":"ui_slider","z":"463827ad.2066a8","tab":"156af96f.f8fd27","name":"Hour","topic":"timehour","group":"Sprinkler","order":1,"min":0,"max":"23","x":319,"y":45,"wires":[["a9762b58.fd4138"]]},{"id":"b6f0113b.9ce52","type":"ui_slider","z":"463827ad.2066a8","tab":"156af96f.f8fd27","name":"Minute","topic":"timeminute","group":"Sprinkler","order":1,"min":0,"max":"59","x":318,"y":89,"wires":[["a9762b58.fd4138"]]},{"id":"af4b553a.5c5098","type":"ui_text","z":"463827ad.2066a8","tab":"156af96f.f8fd27","name":"Time:","group":"Sprinkler","order":1,"format":"{{msg.payload}}","x":754,"y":62,"wires":[]},{"id":"a9762b58.fd4138","type":"function","z":"463827ad.2066a8","name":"Calculate time","func":"global.set(msg.topic,msg.payload);\nvar hour = global.get(\"timehour\");\nvar minute = global.get(\"timeminute\");\nif (hour!==undefined && minute!==undefined) {\n    var mytime = new Date();\n    mytime.setHours(hour, minute, 0);\n    mytime.setFullYear(2000,01,01);\n    global.set(\"start\",mytime);\n}\nmsg.payload = hour + \":\" + minute;\nreturn msg;","outputs":1,"noerr":0,"x":561,"y":62,"wires":[["af4b553a.5c5098"]]},{"id":"45bb7d91.870724","type":"inject","z":"463827ad.2066a8","name":"","topic":"TempCheck","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":162,"y":175,"wires":[["b47f53d6.d4f53"]]},{"id":"b47f53d6.d4f53","type":"function","z":"463827ad.2066a8","name":"Remove date","func":"var current = new Date();\ncurrent.setFullYear(2000,01,01);\nmsg.payload = current;\nreturn msg;","outputs":1,"noerr":0,"x":412,"y":175,"wires":[["d1e5d210.8c577"]]},{"id":"d1e5d210.8c577","type":"switch","z":"463827ad.2066a8","name":"Before or after start","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"start","vt":"global"},{"t":"gte","v":"start","vt":"global"}],"checkall":"true","outputs":2,"x":235,"y":280,"wires":[["78a687e8.08d5b8"],["d54c52a0.ca542"]]},{"id":"78a687e8.08d5b8","type":"change","z":"463827ad.2066a8","name":"Change to ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":486,"y":246,"wires":[["88e90c1f.59a64"]]},{"id":"d54c52a0.ca542","type":"change","z":"463827ad.2066a8","name":"Change to OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":484,"y":299,"wires":[["88e90c1f.59a64"]]},{"id":"88e90c1f.59a64","type":"rpi-gpio out","z":"463827ad.2066a8","name":"","pin":"11","set":"","level":"0","out":"out","x":714,"y":282,"wires":[]},{"id":"156af96f.f8fd27","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":"1"}]


Colin Law

unread,
Nov 14, 2016, 4:38:17 PM11/14/16
to node...@googlegroups.com
Just a note on this, I find that for entering times, drop down lists of hours and minutes (I allow every 5 mins) to be much easier to select than a slider, particularly if the interface is being viewed on a mobile device.

For example

[
    {
        "id": "1983c4da.542823",
        "type": "ui_dropdown",
        "z": "8c466a64.fc1548",
        "name": "First on time hours",
        "label": "First On Time",
        "group": "1215b940.cc16e7",
        "order": 3,
        "width": "4",
        "height": "1",
        "options": [
            {
                "label": "00",
                "value": "0"
            },
            {
                "label": "01",
                "value": "1"
            },
            {
                "label": "02",
                "value": "2"
            },
            {
                "label": "03",
                "value": "3"
            },
            {
                "label": "04",
                "value": "4"
            },
            {
                "label": "05",
                "value": "5"
            },
            {
                "label": "06",
                "value": "6"
            },
            {
                "label": "07",
                "value": "7"
            },
            {
                "label": "08",
                "value": "8"
            },
            {
                "label": "09",
                "value": "9"
            },
            {
                "label": "10",
                "value": "10"
            },
            {
                "label": "11",
                "value": "11"
            },
            {
                "label": "12",
                "value": "12"
            },
            {
                "label": "13",
                "value": "13"
            },
            {
                "label": "14",
                "value": "14"
            },
            {
                "label": "15",
                "value": "15"
            },
            {
                "label": "16",
                "value": "16"
            },
            {
                "label": "17",
                "value": "17"
            },
            {
                "label": "18",
                "value": "18"
            },
            {
                "label": "19",
                "value": "19"
            },
            {
                "label": "20",
                "value": "20"
            },
            {
                "label": "21",
                "value": "21"
            },
            {
                "label": "22",
                "value": "22"
            },
            {
                "label": "23",
                "value": "23"
            }
        ],
        "payload": "",
        "topic": "tydwr/boiler/schedule/1/on/hours",
        "x": 407.5,
        "y": 47,
        "wires": [
            [
                "f688cafd.aba258"
            ]
        ]
    },
    {
        "id": "4e3c2f27.2bb9d",
        "type": "ui_dropdown",
        "z": "8c466a64.fc1548",
        "name": "First on time mins",
        "label": "",
        "group": "1215b940.cc16e7",
        "order": 3,
        "width": "2",
        "height": "1",
        "options": [
            {
                "label": "00",
                "value": "0"
            },
            {
                "label": "05",
                "value": "5"
            },
            {
                "label": "10",
                "value": "10"
            },
            {
                "label": "15",
                "value": "15"
            },
            {
                "label": "20",
                "value": "20"
            },
            {
                "label": "25",
                "value": "25"
            },
            {
                "label": "30",
                "value": "30"
            },
            {
                "label": "35",
                "value": "35"
            },
            {
                "label": "40",
                "value": "40"
            },
            {
                "label": "45",
                "value": "45"
            },
            {
                "label": "50",
                "value": "50"
            },
            {
                "label": "55",
                "value": "55"
            }
        ],
        "payload": "",
        "topic": "tydwr/boiler/schedule/1/on/mins",
        "x": 401.5,
        "y": 102,
        "wires": [
            [
                "f688cafd.aba258"
            ]
        ]
    },
    {
        "id": "1215b940.cc16e7",
        "type": "ui_group",
        "z": "8c466a64.fc1548",
        "name": "Schedule",
        "tab": "e6337ca6.1d8f68",
        "disp": false,
        "width": "6"
    },
    {
        "id": "e6337ca6.1d8f68",
        "type": "ui_tab",
        "z": "8c466a64.fc1548",
        "name": "Schedule",
        "icon": "dashboard"
    }
]


Colin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Peter Scargill

unread,
Nov 15, 2016, 3:15:43 AM11/15/16
to Node-RED
Ah, when it said UI I thought... MAGIC - I've been using ADMIN but it doesn't' work properly - that's GREAT.


On Monday, 14 November 2016 20:58:09 UTC, Nick O'Leary wrote:
Peter - palette manager in the editor, not the dashboard. As described in the release blog post - https://nodered.org/blog/2016/10/11/version-0-15-released

Nick
On 14 November 2016 at 19:37, 'Peter Scargill' via Node-RED <node...@googlegroups.com> wrote:
Am I that predictable :-(

Ok "new palette manager option in the ui" - come on - enlighten us - I updated the dashboard not that long ago and I'm not seeing a 
palette manager??



On Monday, 14 November 2016 19:21:21 UTC, Dave C-J wrote:
no Peter - you didn't really have to - but I knew you would. 8-)

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Csongor Varga

unread,
Nov 15, 2016, 1:15:11 PM11/15/16
to Node-RED
Hi Colin,

Do you remember which package contains the dropdown and the group UI control that you used here? I have node-red-contrib-ui_j installed.

Thanks,
Csongor
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Colin Law

unread,
Nov 15, 2016, 3:37:16 PM11/15/16
to node...@googlegroups.com
On 15 November 2016 at 18:15, Csongor Varga <csongo...@gmail.com> wrote:
Hi Colin,

Do you remember which package contains the dropdown and the group UI control that you used here? I have node-red-contrib-ui_j installed.

It is node-red-dashboard

Colin
 
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Reply all
Reply to author
Forward
0 new messages