Trying to chart high/low temp

Try this, it's a further development of your version.

[{"id":"1cab0dd86162fd95","type":"function","z":"a987d3a0e0ae852c","name":"function 1","func":"// Look in On Start\nlet old = context.get('Day')\nlet day = new Date().getDay()\n\nif (old != day) {\n    context.set('Day', day)\n    context.set(\"Min\", 100)\n    context.set(\"Max\", -100)\n}\n\nmsg.min = context.get('Min')\nmsg.max = context.get('Max')\n\nconst Tmp = msg.payload\nmsg.topic = 'Tmp'\nnode.send(msg)\n\nif (Tmp < msg.min)  {\n    context.set('Min', Tmp)\n    msg.min = Tmp\n    msg.topic = 'Min'\n    node.send([null, msg])\n}\n\n\n\nif (Tmp > msg.max) {\n    msg.max = Tmp\n    msg.topic = 'Max'\n    node.send([null, msg])\n    context.set('Max', Tmp)\n}\n","outputs":2,"timeout":0,"noerr":0,"initialize":"//if (context.get(\"Day\") === undefined)\n    context.set(\"Day\", -1);\n    context.set(\"Min\", 100)\n    context.set(\"Max\", -100)\n    ","finalize":"","libs":[],"x":300,"y":1000,"wires":[["a7ecd84ed7c81fe8"],["f03eada3305694ef","6769276dd1369687","0c4ade7db34f8987","3155dd6e832f91d2","96f552e00a05af0a","0b63aaca4c03436a"]]},{"id":"b079c63558100c2d","type":"mqtt in","z":"a987d3a0e0ae852c","name":"Temperature","topic":"Outside/temperature","qos":"2","datatype":"auto-detect","broker":"b8758158381423f0","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":1000,"wires":[["1cab0dd86162fd95"]]},{"id":"a7ecd84ed7c81fe8","type":"debug","z":"a987d3a0e0ae852c","name":"tmp","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":470,"y":920,"wires":[]},{"id":"f03eada3305694ef","type":"ui_text","z":"a987d3a0e0ae852c","group":"b5f7f90a2f77ea3d","order":2,"width":0,"height":0,"name":"","label":"Today's Min","format":"{{msg.min}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":490,"y":960,"wires":[]},{"id":"6769276dd1369687","type":"bar-chart-data2","z":"a987d3a0e0ae852c","name":"bar-chart-data2","x_interval":"days","x_size":24,"unit":"","precision":2,"is_meter_reading":"False","agg_by":"min","x":500,"y":1000,"wires":[["42d05518f43a7dec"]]},{"id":"0c4ade7db34f8987","type":"debug","z":"a987d3a0e0ae852c","name":"min","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"min","targetType":"msg","statusVal":"payload","statusType":"auto","x":670,"y":980,"wires":[]},{"id":"3155dd6e832f91d2","type":"ui_text","z":"a987d3a0e0ae852c","group":"b5f7f90a2f77ea3d","order":1,"width":0,"height":0,"name":"","label":"Today's Max","format":"{{msg.max}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":490,"y":1040,"wires":[]},{"id":"96f552e00a05af0a","type":"bar-chart-data2","z":"a987d3a0e0ae852c","name":"bar-chart-data2","x_interval":"days","x_size":24,"unit":"","precision":2,"is_meter_reading":"False","agg_by":"max","x":500,"y":1080,"wires":[["42d05518f43a7dec"]]},{"id":"0b63aaca4c03436a","type":"debug","z":"a987d3a0e0ae852c","name":"max","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"max","targetType":"msg","statusVal":"payload","statusType":"auto","x":670,"y":1100,"wires":[]},{"id":"42d05518f43a7dec","type":"ui_chart","z":"a987d3a0e0ae852c","name":"","group":"b5f7f90a2f77ea3d","order":3,"width":"18","height":"4","label":"Chart","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":710,"y":1040,"wires":[[]]},{"id":"b8758158381423f0","type":"mqtt-broker","name":"Local Broker","broker":"localhost","port":1883,"clientid":"","autoConnect":true,"usetls":false,"protocolVersion":4,"keepalive":60,"cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"b5f7f90a2f77ea3d","type":"ui_group","name":"Group 1","tab":"eaa84631f407bcd4","order":1,"disp":true,"width":"18","collapse":false,"className":""},{"id":"eaa84631f407bcd4","type":"ui_tab","name":"daily temperatures","icon":"dashboard","order":5,"disabled":false,"hidden":false},{"id":"2d18058014e53e6e","type":"global-config","env":[],"modules":{"node-red-dashboard":"3.6.6","node-red-contrib-dashboard-bar-chart-data2":"0.9.101"}}]

1 Like

ill give it a try thanks
martin

hi the max min seems to be working great (max 11.8 min 6.2) but the chart minimum is 9.6 , any ideas , thanks
martin

I can see the problem. It must be in the Chart node.
Since it is from dashboard 1, it is unlikely to be fixed.

I'm interested.

Mind sharing what you think is the problem?

After further investigation, the chart node can only receive an array, so 2 bar-chart-data2 in parallel will not work.
I have put a function between the 2 bar-chart-data2 and the chart node.
Here I collect data from max and min, and then arrange them in an array that is sent to the chart node.

I also discovered that max in the bar-char-data2 node cannot go below 0. When I try with -100, it always returns 0.

I have created an issue in github, so it is a question of whether it will be fixed.

[{"id":"70e897e9e8a1a731","type":"function","z":"f33939d8b218d5fd","name":"function 21","func":"// Look in On Start\nlet msg1 = {}\nlet msg2 = {}\nlet msg3 = {}\nlet old = context.get('Day')\nlet day = new Date().getDay()\n\nif (old != day) {\n    context.set('Day', day)\n    context.set(\"Max\", -100)\n    context.set(\"Min\", 100)\n}\n\nlet max = context.get('Max')\nlet min = context.get('Min')\n\nconst Tmp = msg.payload\n\nif (Tmp > max) {\n    max = Tmp\n    context.set('Max', Tmp)\n}\n\nif (Tmp < min)  {\n    min = Tmp\n    context.set('Min', Tmp)\n}\n\nmsg1.payload = Tmp\nmsg1.topic = 'Tmp'\nmsg2.payload = max\nmsg2.topic = 'Max'\nmsg3.payload = min\nmsg3.topic = 'Min'\nreturn [msg1, msg2, msg3]\n","outputs":3,"timeout":0,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\n\ncontext.set(\"Day\", -1)\n ","finalize":"","libs":[],"x":290,"y":160,"wires":[["db7ec5ab6005988c"],["7696de8c1da514ac","bf1a7a98861b667d"],["9b62186e11c934a7","a309726b17fa5617"]]},{"id":"e0b6c165b5e62718","type":"mqtt in","z":"f33939d8b218d5fd","name":"Temperature","topic":"Outside/temperature","qos":"2","datatype":"auto-detect","broker":"b8758158381423f0","nl":false,"rap":true,"rh":0,"inputs":0,"x":110,"y":160,"wires":[["70e897e9e8a1a731"]]},{"id":"db7ec5ab6005988c","type":"junction","z":"f33939d8b218d5fd","x":160,"y":80,"wires":[["1d0b34a749e05e78","83cdccbd49e8b005"]]},{"id":"7696de8c1da514ac","type":"junction","z":"f33939d8b218d5fd","x":380,"y":80,"wires":[["d132b963077709cc","f95d9224f1d98454"]]},{"id":"bf1a7a98861b667d","type":"bar-chart-data2","z":"f33939d8b218d5fd","name":"bar-chart-data2","x_interval":"days","x_size":24,"unit":"","precision":"3","is_meter_reading":"False","agg_by":"max","x":480,"y":140,"wires":[["cfad343ea416b306"]]},{"id":"9b62186e11c934a7","type":"bar-chart-data2","z":"f33939d8b218d5fd","name":"bar-chart-data2","x_interval":"days","x_size":24,"unit":"","precision":"3","is_meter_reading":"False","agg_by":"min","x":480,"y":180,"wires":[["cfad343ea416b306"]]},{"id":"a309726b17fa5617","type":"junction","z":"f33939d8b218d5fd","x":380,"y":240,"wires":[["1a892abbfa729ab9","69f55f02a9771cfc"]]},{"id":"1d0b34a749e05e78","type":"ui_text","z":"f33939d8b218d5fd","group":"c716d8f1.4bb848","order":1,"width":"0","height":"0","name":"","label":"Today's Temp","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":280,"y":60,"wires":[]},{"id":"83cdccbd49e8b005","type":"debug","z":"f33939d8b218d5fd","name":"tmp","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":250,"y":100,"wires":[]},{"id":"d132b963077709cc","type":"ui_text","z":"f33939d8b218d5fd","group":"c716d8f1.4bb848","order":2,"width":"0","height":"0","name":"","label":"Today's Max","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":490,"y":60,"wires":[]},{"id":"f95d9224f1d98454","type":"debug","z":"f33939d8b218d5fd","name":"max","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":470,"y":100,"wires":[]},{"id":"43567f3c3d6f72b4","type":"inject","z":"f33939d8b218d5fd","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"clear","payloadType":"str","x":270,"y":220,"wires":[["bf1a7a98861b667d","9b62186e11c934a7"]]},{"id":"cfad343ea416b306","type":"function","z":"f33939d8b218d5fd","name":"","func":"let msg1 = {}\nlet invar = msg.payload\n\nif (msg.topics == undefined) { return }\nlet topic = msg.topics[0]\n\ncontext.data = context.data ?? {}\n\nswitch (topic) {\n  case 'Max':\n    context.data.max = invar\n  break\n \n  case 'Min':\n    context.data.min = invar\n  break\n}\n\nlet max = {}\nlet min = {}\nlet mm = {}\n\nif (context.data.max != null && context.data.min != null) {\n\n  max.labels = context.data.max[0].labels\n  max.series = [context.data.max[0].series[0]]\n  max.data = [context.data.max[0].data[0]]\n\n  min.labels = context.data.min[0].labels\n  min.series = [context.data.min[0].series[0]]\n  min.data = [context.data.min[0].data[0]]\n\n  mm.labels = min.labels\n  mm.series = [max.series[0], min.series[0]]\n  mm.data = [max.data[0], min.data[0]]\n    \n  msg1.payload = [mm]\n  return msg1\n}\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":160,"wires":[["d3d77514291cea01"]]},{"id":"1a892abbfa729ab9","type":"debug","z":"f33939d8b218d5fd","name":"min","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":470,"y":260,"wires":[]},{"id":"69f55f02a9771cfc","type":"ui_text","z":"f33939d8b218d5fd","group":"c716d8f1.4bb848","order":3,"width":"0","height":"0","name":"","label":"Today's Min","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":490,"y":220,"wires":[]},{"id":"d3d77514291cea01","type":"junction","z":"f33939d8b218d5fd","x":760,"y":160,"wires":[["2bf79b664f30ac2f","de20dce601df1703"]]},{"id":"d862a992b1da4125","type":"ui_button","z":"f33939d8b218d5fd","name":"","group":"c716d8f1.4bb848","order":5,"width":0,"height":0,"passthru":false,"label":"Clear All","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"[]","payloadType":"json","topic":"","topicType":"str","x":660,"y":200,"wires":[["d3d77514291cea01"]]},{"id":"2bf79b664f30ac2f","type":"ui_chart","z":"f33939d8b218d5fd","name":"","group":"c716d8f1.4bb848","order":4,"width":"24","height":"5","label":"","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"30","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":850,"y":160,"wires":[[]]},{"id":"de20dce601df1703","type":"debug","z":"f33939d8b218d5fd","name":"debug 63","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":120,"wires":[]},{"id":"b8758158381423f0","type":"mqtt-broker","name":"Local Broker","broker":"localhost","port":1883,"clientid":"","autoConnect":true,"usetls":false,"protocolVersion":4,"keepalive":60,"cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"c716d8f1.4bb848","type":"ui_group","name":"bar-chart","tab":"957fd14a.a1277","order":1,"disp":true,"width":"24","collapse":false,"className":""},{"id":"957fd14a.a1277","type":"ui_tab","name":"bar-chart","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"30463937c1486b48","type":"global-config","env":[],"modules":{"node-red-contrib-dashboard-bar-chart-data2":"0.9.101","node-red-dashboard":"3.6.6"}}]

thank you I will give it a try
martin