While experimenting with the status display provided by the function node in the editor, I have run into some odd results that occur when properties of the status object are undefined or invalid. This flow tries to capture what happens in the most interesting cases. (The name of each function node is the argument of its node.status function.)
[{"id":"fb6c0922.e11b38","type":"function","z":"62978e96.1c89f","name":"{fill:\"red\"}","func":"node.status({fill:\"red\"});\nreturn msg;","outputs":1,"noerr":0,"x":240,"y":360,"wires":[["38cf5db5.98a862"]]},{"id":"d4b794b2.9df69","type":"inject","z":"62978e96.1c89f","name":"case 1","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":360,"wires":[["fb6c0922.e11b38"]]},{"id":"1e8b1284.f41ecd","type":"function","z":"62978e96.1c89f","name":"{shape:\"dot\"}","func":"node.status({shape:\"dot\"});\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":420,"wires":[["ef5d16ef.9cb35"]]},{"id":"ef5d16ef.9cb35","type":"function","z":"62978e96.1c89f","name":"{shape:\"ring\"}","func":"node.status({shape:\"ring\"});\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":420,"wires":[["e760db6e.badde"]]},{"id":"77adb04c.a684e8","type":"inject","z":"62978e96.1c89f","name":"case 2","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":420,"wires":[["1e8b1284.f41ecd"]]},{"id":"20f640c.eaee74","type":"inject","z":"62978e96.1c89f","name":"case 3","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":480,"wires":[["c9cda5b1.27882"]]},{"id":"2b51cc4f.8b3d34","type":"function","z":"62978e96.1c89f","name":"{shape:\"ring\",fill:\"goo\"}","func":"node.status({shape:\"ring\",fill:\"goo\"});\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":480,"wires":[["7326b634.6000f"]]},{"id":"c9cda5b1.27882","type":"function","z":"62978e96.1c89f","name":"{shape:\"banana\",fill:\"red\"}","func":"node.status({shape:\"banana\",fill:\"red\"});\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":480,"wires":[["2b51cc4f.8b3d34"]]},{"id":"dd9677c9.66ef8","type":"inject","z":"62978e96.1c89f","name":"case 4","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":540,"wires":[["69dfa7c1.c9c0b8"]]},{"id":"69dfa7c1.c9c0b8","type":"function","z":"62978e96.1c89f","name":"{shape:\"banana\",fill:\"goo\",text:\"hello world\"}","func":"node.status({shape:\"banana\",fill:\"goo\",text:\"hello world\"});\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":540,"wires":[["77062052.14f61"]]},{"id":"38cf5db5.98a862","type":"function","z":"62978e96.1c89f","name":"{fill:\"green\"}","func":"node.status({fill:\"green\"});\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":360,"wires":[["5d79e49.8f77c9c"]]},{"id":"5d79e49.8f77c9c","type":"function","z":"62978e96.1c89f","name":"{fill:\"goo\"}","func":"node.status({fill:\"goo\"});\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":360,"wires":[[]]},{"id":"e760db6e.badde","type":"function","z":"62978e96.1c89f","name":"{shape:\"banana\"}","func":"node.status({shape:\"banana\"});\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":420,"wires":[[]]},{"id":"77062052.14f61","type":"function","z":"62978e96.1c89f","name":"{shape:\"banana\",fill:\"goo\",text:\"\"}","func":"node.status({shape:\"banana\",fill:\"goo\",text:\"\"});\nreturn msg;","outputs":1,"noerr":0,"x":680,"y":540,"wires":[[]]},{"id":"7326b634.6000f","type":"function","z":"62978e96.1c89f","name":"{shape:\"banana\",fill:\"goo\"}","func":"node.status({shape:\"banana\",fill:\"goo\"});\nreturn msg;","outputs":1,"noerr":0,"x":780,"y":480,"wires":[[]]}]
Some generalizations seem to apply:
- If only the
fill
is given, the status usesdot
for theshape
. - If only the
shape
is given, thefill
isgrey
. - If the
shape
is invalid, nothing is displayed, EXCEPT 4. - If both the
shape
andfill
are invalid, agrey
dot
is displayed. - If the
fill
is invalid and theshape
is valid, thefill
isgrey
. - If
text
is also given, the results are mostly what one would expect from the above, EXCEPT that if bothshape
andfill
are invalid and thetext
string is empty, a warning message appears.
I suspect that these results come from the logic used to parse the status object and might occur in other nodes that display their status in the editor. I'm not sure whether this should just be documented or treated as a bug.