Hi everyone. Can you help me please?First i am sorry for my english.
I would like to create a graph from my "smart home unit Athom" Homey. I successfully create a json file. but i have a trouble with reading of this file to graph. Can you help how can i do it or where is my issue? Debugger gives me a error: "ReferenceError: data is not defined (line 9, col 42)".
Thanks for your help.
Here is my nodes:
[{"id":"57fda489.419f3c","type":"mqtt in","z":"dc26b425.e05be8","name":"coffeeplug/measure-power","topic":"homie/homey-5ac5f38e42b2c4296e150d77/coffeeplug/measure-power","qos":"2","datatype":"auto","broker":"f18ffc79.bc2648","x":260,"y":600,"wires":[["c44b087.0631e78","4aee7d24.6bc194","73880317.157a24"]]},{"id":"73880317.157a24","type":"function","z":"dc26b425.e05be8","name":"Modify Payload","func":"var today = new Date();\nvar date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate()+',';\nvar time = today.getHours() + \":\" + today.getMinutes() + \":\" + today.getSeconds();\nvar dateTime = date+' '+time;\nvar data=[];\nvar series=[\"Data\"];\nvar labels=[\"Labels\"];\nvar values = ({\n \"dateTime\": dateTime,\n \"payload\": msg.payload,\n}); \n\nmsg.payload = [{series,values,labels}];\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":590,"wires":[["c6ec3305.53a418"]]},{"id":"c6ec3305.53a418","type":"json","z":"dc26b425.e05be8","name":"","property":"dateTime,payload","action":"","pretty":false,"x":950,"y":590,"wires":[["5ba76edf.d9686"]]},{"id":"5ba76edf.d9686","type":"file","z":"dc26b425.e05be8","name":"","filename":"/home/pi/logs/test.log","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":1120,"y":590,"wires":[["3b46a832.6825a"]]},{"id":"3b46a832.6825a","type":"change","z":"dc26b425.e05be8","name":"Data Array","rules":[{"t":"set","p":"data","pt":"msg","to":"$.values.{\"dateTime\":dateTime, \"payload\":data}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1320,"y":590,"wires":[["8983f082.d731d8"]]},{"id":"8983f082.d731d8","type":"function","z":"dc26b425.e05be8","name":"Setup payload","func":"series = [];\npayload = [];\nlabels = [];\n\nseries.push(\"Data\");\npayload.push(\"Values\");\nlabels.push(\"Label\");\n\nmsg.payload = [{\"series\":series,\"Values\":data,\"labels\":labels}];\n\nreturn msg;","outputs":1,"noerr":0,"x":1510,"y":590,"wires":[["e8d22e12.54e158","b723c505.8152a8"]]},{"id":"e8d22e12.54e158","type":"debug","z":"dc26b425.e05be8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1730,"y":540,"wires":[]},{"id":"b723c505.8152a8","type":"ui_chart","z":"dc26b425.e05be8","name":"","group":"2cdaed12.b6920a","order":3,"width":0,"height":0,"label":"payload","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1710,"y":610,"wires":[[]]},{"id":"f18ffc79.bc2648","type":"mqtt-broker","z":"","name":"Homey MQTT","broker":"192.168.1.4","port":"1883","tls":"","clientid":"","usetls":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"2cdaed12.b6920a","type":"ui_group","z":"","name":"Coffee","tab":"57d4c334.8436d4","order":5,"disp":true,"width":4,"collapse":false},{"id":"57d4c334.8436d4","type":"ui_tab","z":"","name":"Energy","icon":"fa-1x fa-bolt","order":3,"disabled":false,"hidden":false}]