Flume Water Monitor
Flow to connect to your Flume account, and retrieve Year, Month and Day useage. Then has 3 Dashboard nodes to display on the Dashboard.
Uses Credential node to store secrets.
Updates every 2 minutes. You can change the query in JSonata to whatever parts you want to see from Flume.
API reference: https://flumetech.readme.io/reference#introduction
[{"id":"33292b7b.b59f84","type":"tab","label":"Flume","disabled":false,"info":""},{"id":"367cb4e0.0d6d3c","type":"inject","z":"33292b7b.b59f84","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":240,"y":180,"wires":[["b145c119.50994"]]},{"id":"b145c119.50994","type":"credentials","z":"33292b7b.b59f84","name":"Flume credentials","props":[{"value":"payload.client_id","type":"msg"},{"value":"payload.client_secret","type":"msg"},{"value":"payload.username","type":"msg"},{"value":"payload.password","type":"msg"}],"x":430,"y":180,"wires":[["7a3c7dfa.56cee4"]]},{"id":"3d892f97.4a878","type":"http request","z":"33292b7b.b59f84","name":"Get Flume access token","method":"POST","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":950,"y":180,"wires":[["d1adc24a.47f7f","4a11aaf.a3b4a54","7f8ff546.a56b1c"]]},{"id":"d1adc24a.47f7f","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1290,"y":120,"wires":[]},{"id":"7a3c7dfa.56cee4","type":"change","z":"33292b7b.b59f84","name":"Set Flume URL query","rules":[{"t":"set","p":"url","pt":"msg","to":"https://api.flumewater.com/oauth/token","tot":"str"},{"t":"set","p":"headers.Content-Type","pt":"msg","to":"application/json","tot":"str"},{"t":"set","p":"payload.grant_type","pt":"msg","to":"password","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":180,"wires":[["b0f2dd47.24915","3d892f97.4a878"]]},{"id":"b0f2dd47.24915","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":900,"y":80,"wires":[]},{"id":"4a11aaf.a3b4a54","type":"change","z":"33292b7b.b59f84","name":"Store tokens in Flow globals","rules":[{"t":"set","p":"access_token","pt":"flow","to":"payload.data[0].access_token","tot":"msg"},{"t":"set","p":"refresh_token","pt":"flow","to":"payload.data[0].refresh_token","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":180,"wires":[["fce7dd2c.3a126"]]},{"id":"fce7dd2c.3a126","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1510,"y":120,"wires":[]},{"id":"7f8ff546.a56b1c","type":"change","z":"33292b7b.b59f84","name":"Decode JWT","rules":[{"t":"set","p":"jwt","pt":"msg","to":"$base64decode($split ($.payload.data[0].access_token, \".\")[1])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":240,"wires":[["3e3addae.43e122"]]},{"id":"4e58e2ac.fffbbc","type":"inject","z":"33292b7b.b59f84","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"*/2 7-21 * * *","once":true,"onceDelay":"5","topic":"","payload":"{}","payloadType":"json","x":130,"y":560,"wires":[["f31c3fa5.b793b"]]},{"id":"1058f420.b44e0c","type":"change","z":"33292b7b.b59f84","name":"Create devices query URL","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"url","pt":"msg","to":"'https://api.flumewater.com/users/' & $.user.user_id & '/devices'","tot":"jsonata"},{"t":"set","p":"method","pt":"msg","to":"GET","tot":"str"},{"t":"set","p":"headers.Authorization","pt":"msg","to":"'Bearer ' & $.bearer","tot":"jsonata"},{"t":"set","p":"headers.Content-Type","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":360,"wires":[["ea14ba2a.3e45a8","17464db2.8df372"]]},{"id":"ea14ba2a.3e45a8","type":"http request","z":"33292b7b.b59f84","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1010,"y":360,"wires":[["5caa43c5.f30a8c","eb12c76c.aff5e8"]]},{"id":"a2fe198d.ec7fa8","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1850,"y":360,"wires":[]},{"id":"eb12c76c.aff5e8","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":300,"wires":[]},{"id":"2be7e33e.3d4f7c","type":"change","z":"33292b7b.b59f84","name":"Get flow globals","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"user","pt":"msg","to":"jwt","tot":"flow"},{"t":"set","p":"bearer","pt":"msg","to":"access_token","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":360,"wires":[["9b980878.c246a8","1058f420.b44e0c"]]},{"id":"9b980878.c246a8","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":600,"y":280,"wires":[]},{"id":"3e3addae.43e122","type":"json","z":"33292b7b.b59f84","name":"","property":"jwt","action":"","pretty":false,"x":1490,"y":240,"wires":[["5c15078e.98f718"]]},{"id":"5c15078e.98f718","type":"change","z":"33292b7b.b59f84","name":"","rules":[{"t":"set","p":"jwt","pt":"flow","to":"jwt","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1650,"y":240,"wires":[["fce7dd2c.3a126","2be7e33e.3d4f7c"]]},{"id":"f496b9b.2a4bc48","type":"split","z":"33292b7b.b59f84","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1490,"y":360,"wires":[["b3e1b192.ca34d","ae135af2.1ec348"]]},{"id":"5caa43c5.f30a8c","type":"change","z":"33292b7b.b59f84","name":"Move device array to payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":360,"wires":[["f496b9b.2a4bc48"]]},{"id":"b3e1b192.ca34d","type":"switch","z":"33292b7b.b59f84","name":"Is Sensor?","property":"payload.type","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":1670,"y":360,"wires":[[],["a2fe198d.ec7fa8","c16db366.978b8"],[]],"outputLabels":["Bridge","Sensor","unknown"]},{"id":"2f46949.7893c6c","type":"change","z":"33292b7b.b59f84","name":"Create data query URL","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"url","pt":"msg","to":"'https://api.flumewater.com/users/' & $.user.user_id & '/devices/' & $.payload.id & '/query'","tot":"jsonata"},{"t":"set","p":"method","pt":"msg","to":"POST","tot":"str"},{"t":"set","p":"headers.Authorization","pt":"msg","to":"'Bearer ' & $.bearer","tot":"jsonata"},{"t":"set","p":"headers.Content-Type","pt":"msg","to":"application/json","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\t \"queries\":[\t {\t \"bucket\":\"DAY\",\t \"since_datetime\": $now(\"[Y0001]-[M01]-[D01] 00:00:01\", \"-0500\"),\t \"request_id\":\"day\"\t },\t {\t \"bucket\":\"MON\",\t \"since_datetime\": $now(\"[Y0001]-[M01]-[D01] 00:00:01\"),\t \"request_id\":\"month\"\t },\t {\t \"bucket\":\"YR\",\t \"since_datetime\": $now(\"[Y0001]-[M01]-[D01] 00:00:01\"),\t \"request_id\":\"year\"\t },\t {\t \"bucket\":\"HR\",\t \"since_datetime\": $now(\"[Y0001]-[M01]-[D01] [H01]:00:00\", \"-0500\"),\t \"request_id\":\"hour\"\t },\t {\t \"bucket\":\"MIN\",\t \"since_datetime\": $now(\"[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]\", \"-0500\"),\t \"request_id\":\"minute\"\t }\t ]\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":480,"wires":[["9ce8c736.1f8b48","5d6d5e3d.7337"]]},{"id":"a444be8f.8613d","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1010,"y":480,"wires":[]},{"id":"5d6d5e3d.7337","type":"http request","z":"33292b7b.b59f84","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":750,"y":480,"wires":[["a444be8f.8613d","e21191d0.a9ddb"]]},{"id":"9ce8c736.1f8b48","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":560,"wires":[]},{"id":"303537b3.702fc8","type":"ui_gauge","z":"33292b7b.b59f84","name":"","group":"32b1de46.ed09d2","order":3,"width":"6","height":"6","gtype":"donut","title":"Day","label":"Gallons","format":"{{msg.payload.day | number:1}}","min":0,"max":"200","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1190,"y":600,"wires":[]},{"id":"9a3e5fe4.f5d04","type":"ui_gauge","z":"33292b7b.b59f84","name":"Month","group":"32b1de46.ed09d2","order":2,"width":"6","height":"6","gtype":"donut","title":"Month","label":"Gallons","format":"{{msg.payload.month | number:1}}","min":0,"max":"2500","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1190,"y":660,"wires":[]},{"id":"fa943d85.a8acb","type":"ui_gauge","z":"33292b7b.b59f84","name":"","group":"32b1de46.ed09d2","order":1,"width":"6","height":"6","gtype":"donut","title":"Year","label":"Gallons","format":"{{msg.payload.year | number:1}}","min":0,"max":"30000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1190,"y":720,"wires":[]},{"id":"e21191d0.a9ddb","type":"change","z":"33292b7b.b59f84","name":"Get Totals","rules":[{"t":"set","p":"payload.day","pt":"msg","to":"payload.data[0].day[0].value","tot":"msg"},{"t":"set","p":"payload.month","pt":"msg","to":"payload.data[0].month[0].value","tot":"msg"},{"t":"set","p":"payload.year","pt":"msg","to":"payload.data[0].year[0].value","tot":"msg"},{"t":"set","p":"payload.hour","pt":"msg","to":"payload.data[0].hour[0].value","tot":"msg"},{"t":"set","p":"payload.minute","pt":"msg","to":"payload.data[0].minute[0].value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":560,"wires":[["303537b3.702fc8","9a3e5fe4.f5d04","fa943d85.a8acb","c563ea9.d254418","cf400c0e.4a131"]]},{"id":"c563ea9.d254418","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1070,"y":760,"wires":[]},{"id":"4f84282c.984c68","type":"catch","z":"33292b7b.b59f84","name":"","scope":null,"uncaught":false,"x":490,"y":760,"wires":[["e2d7f955.8b7998"]]},{"id":"e2d7f955.8b7998","type":"debug","z":"33292b7b.b59f84","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":720,"y":760,"wires":[]},{"id":"c16db366.978b8","type":"change","z":"33292b7b.b59f84","name":"Store device id","rules":[{"t":"set","p":"device_id","pt":"flow","to":"payload.id","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1880,"y":420,"wires":[[]]},{"id":"ae135af2.1ec348","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1650,"y":440,"wires":[]},{"id":"f31c3fa5.b793b","type":"change","z":"33292b7b.b59f84","name":"Get flow globals","rules":[{"t":"set","p":"user","pt":"msg","to":"jwt","tot":"flow"},{"t":"set","p":"bearer","pt":"msg","to":"access_token","tot":"flow"},{"t":"set","p":"payload.id","pt":"msg","to":"device_id","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":560,"wires":[["2f46949.7893c6c"]]},{"id":"17464db2.8df372","type":"debug","z":"33292b7b.b59f84","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":400,"wires":[]},{"id":"cf400c0e.4a131","type":"ui_gauge","z":"33292b7b.b59f84","name":"","group":"32b1de46.ed09d2","order":4,"width":"6","height":"6","gtype":"donut","title":"Hour","label":"Gallons","format":"{{msg.payload.hour | number:1}}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1190,"y":540,"wires":[]},{"id":"32b1de46.ed09d2","type":"ui_group","name":"Water Usage","tab":"e0955c05.a0ea2","order":1,"disp":true,"width":"24","collapse":false},{"id":"e0955c05.a0ea2","type":"ui_tab","name":"Water","icon":"fa-tint","order":9,"disabled":false,"hidden":false}]