I'd like to display the voltage measured by a sonoff pow r2 displayed in a graph.
I have captured the msg.payload in json format and made two input nodes with it, so you can see
how the data is made up. I just want a function which takes out the voltage to make a graph with it in
the gui.
Here is my flow:
`[{"id":"75df3d17.fc49ec","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"e318257b.48a138","type":"inject","z":"75df3d17.fc49ec","name":"testdataSENSOR","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"tele/sonoff2/SENSOR","payload":"{\"Time\":\"2020-08-22T19:16:33\",\"ENERGY\":{\"TotalStartTime\":\"2020-08-20T16:12:14\",\"Total\":0.003,\"Yesterday\":0,\"Today\":0,\"Period\":0,\"Power\":0,\"ApparentPower\":0,\"ReactivePower\":0,\"Factor\":0,\"Voltage\":230,\"Current\":0}}","payloadType":"json","x":222.1666717529297,"y":203.16665649414062,"wires":[["c4021a8e.ae7d68"]]},{"id":"eac79629.fc0f6","type":"inject","z":"75df3d17.fc49ec","name":"testdataSTATE","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"tele/sonoff2/STATE","payload":"{\"Time\":\"2020-08-22T19:16:33\",\"ENERGY\":{\"TotalStartTime\":\"2020-08-20T16:12:14\",\"Total\":0.003,\"Yesterday\":0,\"Today\":0,\"Period\":0,\"Power\":0,\"ApparentPower\":0,\"ReactivePower\":0,\"Factor\":0,\"Voltage\":230,\"Current\":0}}","payloadType":"json","x":220,"y":140,"wires":[["c4021a8e.ae7d68"]]},{"id":"c4021a8e.ae7d68","type":"debug","z":"75df3d17.fc49ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":180,"wires":[]},{"id":"75836fb9.c2c8c","type":"ui_chart","z":"75df3d17.fc49ec","name":"Voltage sonoff2","group":"cd3ce492.ee804","order":4,"width":0,"height":0,"label":"Voltage sonoff2","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"250","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":640,"y":300,"wires":[[]]},{"id":"dba3ade3.57e96","type":"mqtt in","z":"75df3d17.fc49ec","name":"","topic":"tele/sonoff2/#","qos":"0","datatype":"auto","broker":"f56d1a7c.e35768","x":190,"y":60,"wires":[["b836be04.6530d8"]]},{"id":"b836be04.6530d8","type":"json","z":"75df3d17.fc49ec","name":"","property":"payload","action":"","pretty":false,"x":390,"y":60,"wires":[["c4021a8e.ae7d68"]]},{"id":"d928f648.1f4df8","type":"function","z":"75df3d17.fc49ec","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":300,"wires":[["75836fb9.c2c8c"]]},{"id":"cd3ce492.ee804","type":"ui_group","z":"","name":"sonoff2","tab":"d2e4816a.0ecad","order":2,"disp":true,"width":"6","collapse":false},{"id":"f56d1a7c.e35768","type":"mqtt-broker","z":"","name":"localhost:1883","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"d2e4816a.0ecad","type":"ui_tab","z":"","name":"sonoff","icon":"dashboard","order":8,"disabled":false,"hidden":false}]`
could anybody here help me with this function?
kind regards,
Hugo