Good afternoon,
I'm trying to collect data for a power consumption on a easy way just to be shown on a chart on node red.
I try to get a report on the average per day, one per week an one per month.
Per day and week was easy just doing a inject a specific time a day to enable reading and inject to disable one minute later and at that time resetting the average however to get this done monthly I find the problem that inject longer period of time is once per week and I can not do it every 4 weeks or every specific day of the month (what should be great) and now I'm wonder if someone did already something like this and can bring me some idea.
The flow I did for day and week is:
[{"id":"b61f55fb.64fec8","type":"average","z":"aa1ac307.b2cbd","name":"","topic":"","x":340,"y":840,"wires":[["45f21625.37a828","db9084cf.a88288"]]},{"id":"93230056.24fcb","type":"inject","z":"aa1ac307.b2cbd","name":"","topic":"","payload":"msg.reset","payloadType":"str","repeat":"","crontab":"00 00 * * *","once":false,"x":130,"y":840,"wires":[["b61f55fb.64fec8"]]},{"id":"45f21625.37a828","type":"switch","z":"aa1ac307.b2cbd","name":"diario","property":"medida_diaria","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","outputs":1,"x":510,"y":840,"wires":[["38466dc4.989882"]]},{"id":"ddd2cb39.396ab8","type":"inject","z":"aa1ac307.b2cbd","name":"activar lectura","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"58 23 * * *","once":false,"x":140,"y":900,"wires":[["5cd7c879.b78038"]]},{"id":"5cd7c879.b78038","type":"change","z":"aa1ac307.b2cbd","name":"","rules":[{"t":"set","p":"medida_diaria","pt":"flow","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":900,"wires":[[]]},{"id":"38466dc4.989882","type":"delay","z":"aa1ac307.b2cbd","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"3","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":680,"y":840,"wires":[["77efc366.c3715c"]]},{"id":"bce5d0c4.3de43","type":"change","z":"aa1ac307.b2cbd","name":"","rules":[{"t":"set","p":"medida_diaria","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":940,"wires":[[]]},{"id":"43ca2de7.2d53b4","type":"inject","z":"aa1ac307.b2cbd","name":"desactivar lectura","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"59 23 * * *","once":false,"x":150,"y":940,"wires":[["bce5d0c4.3de43"]]},{"id":"77efc366.c3715c","type":"function","z":"aa1ac307.b2cbd","name":"custom function","func":"// declare place holder variables\nvar originalval = msg.payload;\nvar temp = \"\";\n\n\n// convert string of originalval to float with 1 decimal place\n// run originalval thru a simple minus operation to form the 'temp' number\ntemp = parseFloat(originalval/1000).toFixed(1) ;\n\n// output the originalval after deduction \nmsg.payload = temp;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":840,"wires":[["14a0e538.be052b"]]},{"id":"20cfa3bd.47496c","type":"ui_gauge","z":"aa1ac307.b2cbd","name":"","group":"2ebc9347.9cd16c","order":0,"width":0,"height":0,"gtype":"gage","title":"Valor Promedio diario acumulado","label":"KWh","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1040,"y":900,"wires":[]},{"id":"14a0e538.be052b","type":"ui_chart","z":"aa1ac307.b2cbd","name":"consumo diario","group":"2ebc9347.9cd16c","order":0,"width":0,"height":0,"label":"Consumo diario","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"0","ymax":"10","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":1100,"y":840,"wires":[[],[]]},{"id":"17e62a98.a36e75","type":"average","z":"aa1ac307.b2cbd","name":"","topic":"","x":320,"y":1100,"wires":[["3d3f567b.e5b2ba","e878bf3.b6b014"]]},{"id":"90ad3cc9.480cb","type":"inject","z":"aa1ac307.b2cbd","name":"","topic":"","payload":"msg.reset","payloadType":"str","repeat":"","crontab":"00 00 * * 1","once":false,"x":110,"y":1100,"wires":[["17e62a98.a36e75"]]},{"id":"3d3f567b.e5b2ba","type":"switch","z":"aa1ac307.b2cbd","name":"semanal","property":"medida_semanal","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","outputs":1,"x":500,"y":1100,"wires":[["726ecc07.83b394"]]},{"id":"490aeb72.305d24","type":"inject","z":"aa1ac307.b2cbd","name":"activar lectura","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"58 23 * * 0","once":false,"x":120,"y":1160,"wires":[["c2f62a95.03aa88"]]},{"id":"c2f62a95.03aa88","type":"change","z":"aa1ac307.b2cbd","name":"","rules":[{"t":"set","p":"medida_semanal","pt":"flow","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":1160,"wires":[[]]},{"id":"726ecc07.83b394","type":"delay","z":"aa1ac307.b2cbd","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"3","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":660,"y":1100,"wires":[["b639912b.e21e7"]]},{"id":"39ec2129.d64abe","type":"change","z":"aa1ac307.b2cbd","name":"","rules":[{"t":"set","p":"medida_semanal","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":1200,"wires":[[]]},{"id":"598c28e3.c78f58","type":"inject","z":"aa1ac307.b2cbd","name":"desactivar lectura","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"59 23 * * 0","once":false,"x":130,"y":1200,"wires":[["39ec2129.d64abe"]]},{"id":"b639912b.e21e7","type":"function","z":"aa1ac307.b2cbd","name":"custom function","func":"// declare place holder variables\nvar originalval = msg.payload;\nvar temp = \"\";\n\n\n// convert string of originalval to float with 1 decimal place\n// run originalval thru a simple minus operation to form the 'temp' number\ntemp = parseFloat(originalval/1000).toFixed(1) ;\n\n// output the originalval after deduction \nmsg.payload = temp;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":1100,"wires":[["a011351e.2d7538"]]},{"id":"c50efd08.607bc","type":"ui_gauge","z":"aa1ac307.b2cbd","name":"","group":"2ebc9347.9cd16c","order":0,"width":0,"height":0,"gtype":"gage","title":"Valor Promedio semanal acumulado","label":"KWh","format":"{{value}}","min":0,"max":"75","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1030,"y":1160,"wires":[]},{"id":"a011351e.2d7538","type":"ui_chart","z":"aa1ac307.b2cbd","name":"Consumo semanal","group":"2ebc9347.9cd16c","order":0,"width":0,"height":0,"label":"Consumo semanal","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":1090,"y":1100,"wires":[[],[]]},{"id":"576eebf2.e54cb4","type":"comment","z":"aa1ac307.b2cbd","name":"consumo diario","info":"","x":160,"y":780,"wires":[]},{"id":"21f3c894.e69c88","type":"comment","z":"aa1ac307.b2cbd","name":"consumo semanal","info":"","x":200,"y":1040,"wires":[]},{"id":"e878bf3.b6b014","type":"function","z":"aa1ac307.b2cbd","name":"custom function","func":"// declare place holder variables\nvar originalval = msg.payload;\nvar temp = \"\";\n\n\n// convert string of originalval to float with 1 decimal place\n// run originalval thru a simple minus operation to form the 'temp' number\ntemp = parseFloat(originalval/1000).toFixed(1) ;\n\n// output the originalval after deduction \nmsg.payload = temp;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":1160,"wires":[["c50efd08.607bc"]]},{"id":"db9084cf.a88288","type":"function","z":"aa1ac307.b2cbd","name":"custom function","func":"// declare place holder variables\nvar originalval = msg.payload;\nvar temp = \"\";\n\n\n// convert string of originalval to float with 1 decimal place\n// run originalval thru a simple minus operation to form the 'temp' number\ntemp = parseFloat(originalval/1000).toFixed(1) ;\n\n// output the originalval after deduction \nmsg.payload = temp;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":760,"y":900,"wires":[["20cfa3bd.47496c"]]},{"id":"2ebc9347.9cd16c","type":"ui_group","z":"","name":"Consumo","tab":"49f882f0.c51aec","order":1,"disp":true,"width":"6"},{"id":"49f882f0.c51aec","type":"ui_tab","z":"","name":"CONSUMO","icon":"fa-plug","order":6}]
Any sugegstion considering my knowledge is very limited is welcome.
Thanks in advance