[{"id":"01d3348b76537132","type":"tab","label":"random / step function","disabled":false,"info":"","env":[]},{"id":"5a9e42e240b0d7e8","type":"function","z":"01d3348b76537132","name":"random set temperature","func":"msg.payload = (getRandomInt(msg.payload));\nreturn msg;\n\n//console.log(Math.random());\n// expected output: a number from 0 to <1\n\nfunction getRandomInt(max) {\n return Math.floor(Math.random() * max);\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":220,"wires":[["9bac5667383dbff3"]]},{"id":"c78aeeb0fe70b03b","type":"inject","z":"01d3348b76537132","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"25","payloadType":"num","x":130,"y":220,"wires":[["5a9e42e240b0d7e8"]]},{"id":"99f872c3240b22ac","type":"function","z":"01d3348b76537132","name":"step & linear function","func":"if (msg.topic === 'step'){\n let newValueStep = msg.payload;\n node.send({payload:context.get('lastValueStep'),topic:'step'});\n node.send({payload:newValueStep,topic:'step'});\n context.set('lastValueStep',newValueStep);\n node.send({ payload: context.get('lastValueLinear'), topic: 'linear' }); \n}\nif (msg.topic === 'linear') {\n let newValueLinear = msg.payload;\n node.send({payload:newValueLinear, topic:'linear' });\n context.set('lastValueLinear', newValueLinear);\n node.send({ payload: context.get('lastValueStep'), topic: 'step' }); \n}\nreturn null;","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\ncontext.set('lastValueStep',0);\ncontext.set('lastValueLinear', 0);\n//flow.set('lastValue', 0);","finalize":"","libs":[],"x":740,"y":240,"wires":[["28c0a277320a082f"]]},{"id":"28c0a277320a082f","type":"ui_chart","z":"01d3348b76537132","name":"","group":"7583c03b62c2607d","order":3,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"40","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#ff0f1b","#44fb41","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":950,"y":240,"wires":[[]]},{"id":"5619cd93f1ac5dd4","type":"inject","z":"01d3348b76537132","name":"reset chart","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[]","payloadType":"jsonata","x":780,"y":120,"wires":[["28c0a277320a082f"]]},{"id":"e1cb2dedea1ef3be","type":"function","z":"01d3348b76537132","name":"init color","func":"node.send({topic:'step'}); //red\nnode.send({ topic:'linear'}); //green\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":160,"wires":[["28c0a277320a082f"]]},{"id":"c0bb37c34640951a","type":"inject","z":"01d3348b76537132","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":620,"y":160,"wires":[["e1cb2dedea1ef3be"]]},{"id":"bceaecfe53bb6c22","type":"function","z":"01d3348b76537132","name":"random actual temperatur","func":"msg.payload = (getRandomInt(msg.payload));\nreturn msg;\n\n//console.log(Math.random());\n// expected output: a number from 0 to <1\n\nfunction getRandomInt(max) {\n return Math.floor(Math.random() * max);\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":260,"wires":[["797ef5e854c966f2"]]},{"id":"54b251942d954871","type":"inject","z":"01d3348b76537132","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"30","payloadType":"num","x":130,"y":260,"wires":[["bceaecfe53bb6c22"]]},{"id":"9bac5667383dbff3","type":"change","z":"01d3348b76537132","name":"topic step","rules":[{"t":"set","p":"topic","pt":"msg","to":"step","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":220,"wires":[["99f872c3240b22ac"]]},{"id":"797ef5e854c966f2","type":"change","z":"01d3348b76537132","name":"topic linear","rules":[{"t":"set","p":"topic","pt":"msg","to":"linear","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":260,"wires":[["99f872c3240b22ac"]]},{"id":"7583c03b62c2607d","type":"ui_group","name":"step chart","tab":"55c65f4e033571fe","order":1,"disp":true,"width":"14","collapse":false,"className":""},{"id":"55c65f4e033571fe","type":"ui_tab","name":"chart","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
1 Like