forked from josuebecerra7/Cozy_Room_App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_app_using_api.json
1 lines (1 loc) · 10.5 KB
/
user_app_using_api.json
1
[{"id":"35ba5f50.a8d188","type":"tab","label":"User APP","disabled":false,"info":""},{"id":"aee3ff7.f0fd7","type":"http request","z":"35ba5f50.a8d188","name":"Get latest","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://localhost:8081/api/last","tls":"","persist":false,"proxy":"","authType":"","x":260,"y":140,"wires":[["419bc73c.aff238"]]},{"id":"419bc73c.aff238","type":"json","z":"35ba5f50.a8d188","name":"","property":"payload","action":"","pretty":false,"x":410,"y":140,"wires":[["f40b7f62.e7572","8d507b0b.66e108","9484425d.b807e","7e980467.6fb67c","f60ad9d2.3aa128"]]},{"id":"eaf8b30b.06b39","type":"inject","z":"35ba5f50.a8d188","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":220,"wires":[["aee3ff7.f0fd7","f7ed537d.73887","cc3d7e4b.4198e","d2e4d172.2de9b"]]},{"id":"6f6c246f.78f9ec","type":"ui_text","z":"35ba5f50.a8d188","group":"7e1e4e2d.3e483","order":1,"width":0,"height":0,"name":"Time ","label":"","format":"{{msg.payload.timestamp}}","layout":"col-center","x":770,"y":100,"wires":[]},{"id":"f40b7f62.e7572","type":"function","z":"35ba5f50.a8d188","name":"transform unix","func":"var a = new Date(msg.payload.time);\nvar months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];\nvar year = a.getFullYear();\nvar month = months[a.getMonth()];\nvar date = a.getDate();\nvar hour = a.getHours();\nvar min = ('0'+ a.getMinutes()).slice(-2);\nvar sec = ('0'+ a.getSeconds()).slice(-2);\nif (min.lenght<10) {min = \"0\" + min}\nif (sec.lenght<10) {sec = \"0\" + sec}\nvar time = date + ' ' + month + ' ' + year + '\\n' + hour + ':' + min + ':' + sec ;\nmsg.payload = {\"timestamp\" : time, \"len\": min}\nreturn msg\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":100,"wires":[["6f6c246f.78f9ec"]]},{"id":"8d507b0b.66e108","type":"ui_gauge","z":"35ba5f50.a8d188","name":"temperature gauge","group":"7e1e4e2d.3e483","order":2,"width":"4","height":"3","gtype":"gage","title":"Temperature","label":"ºC","format":"{{msg.payload.temperature}}","min":"-5","max":"30","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":730,"y":140,"wires":[]},{"id":"9484425d.b807e","type":"ui_gauge","z":"35ba5f50.a8d188","name":"humidity gauge","group":"7e1e4e2d.3e483","order":2,"width":"4","height":"3","gtype":"gage","title":"Humidity","label":"%","format":"{{msg.payload.humidity.toFixed(2)}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":740,"y":180,"wires":[]},{"id":"7e980467.6fb67c","type":"function","z":"35ba5f50.a8d188","name":"Heat Index","func":"if (msg.payload.temperature>26){\nvar T = (msg.payload.temperature*(9/5))+32;\nvar RH = msg.payload.humidity;\nvar HI = -42.379 + 2.04901523*T + 10.14333127*RH - .22475541*T*RH - .00683783*T*T - .05481717*RH*RH + .00122874*T*T*RH + .00085282*T*RH*RH - .00000199*T*T*RH*RH; \nvar OUT = (HI+T)/2;\nmsg.payload = {\"heat_index\":((OUT-32)*(5/9)).toFixed(2)}\n}\nelse{msg.payload ={\"heat_index\": msg.payload.temperature}}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":530,"y":220,"wires":[["ea7a752b.95c2f8","c9f63d5e.f55c8"]]},{"id":"ea7a752b.95c2f8","type":"ui_gauge","z":"35ba5f50.a8d188","name":"Heat gauge","group":"438cdf8b.0c6a6","order":2,"width":"9","height":"4","gtype":"gage","title":"Real Feel:","label":"ºC","format":"{{msg.payload.heat_index}}","min":"-5","max":"30","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":750,"y":220,"wires":[]},{"id":"cec87f43.eacdf","type":"ui_chart","z":"35ba5f50.a8d188","name":"","group":"a611f497.f3df88","order":3,"width":"9","height":"3","label":"Previous Temperature in the Room","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"5","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":840,"y":280,"wires":[[]]},{"id":"c9f63d5e.f55c8","type":"function","z":"35ba5f50.a8d188","name":"","func":"msg.payload = msg.payload.heat_index;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":280,"wires":[["cec87f43.eacdf"]]},{"id":"6eabc3ae.a7f80c","type":"function","z":"35ba5f50.a8d188","name":"Get weather","func":"var tiempo = {}\nvar forecast_temp = [];\nvar forecast_w = [];\n//var icon_w = []\n\n//msg.payload = flow.get(\"weather\") || {};\n\nfor(var i=0; i<24 ; i++)\n{\n forecast_temp.push(msg.payload.hourly[i].temp);\n forecast_w.push(msg.payload.hourly[i].weather[0].main);\n // icon_w.push(msg.payload.hourly[i].weather[0].icon);\n}\n\ntiempo = {\"forecast_temp\":forecast_temp,\n \"forecast_w\" : forecast_w\n // \"icon_w\" : icon_w\n};\n\nmsg.payload = tiempo;\nflow.set(\"weather\",tiempo);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":550,"y":400,"wires":[["8a5c202b.a9341"]]},{"id":"f7ed537d.73887","type":"http request","z":"35ba5f50.a8d188","name":"weather","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://api.openweathermap.org/data/2.5/onecall?lat=48.663656&lon=6.157039&exclude={minutely,daily,alerts}&appid=19b95aac5112a86dc2b778349192a13d&units=metric","tls":"","persist":false,"proxy":"","authType":"","x":240,"y":400,"wires":[["b144ce50.52df6"]]},{"id":"b144ce50.52df6","type":"json","z":"35ba5f50.a8d188","name":"","property":"payload","action":"","pretty":false,"x":390,"y":400,"wires":[["6eabc3ae.a7f80c"]]},{"id":"8a5c202b.a9341","type":"function","z":"35ba5f50.a8d188","name":"weather now","func":"\nmsg.payload = flow.get(\"weather\") || {};\n\n\n/*msg.payload = msg.payload.forecast_temp[0];*/\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":750,"y":400,"wires":[["b85c352e.514ea8","2217b523.86a3ca","f0686326.6ccec"]]},{"id":"b85c352e.514ea8","type":"function","z":"35ba5f50.a8d188","name":"select icon","func":"//https://openweathermap.org/weather-conditions#Weather-Condition-Codes-2\nvar current = msg.payload.forecast_w[0];\n\nif(current = \"Clouds\"){msg.payload=7}\nelse if (current = \"Rain\") {msg.payload=10} \nelse if(current = \"Thunderstorm\") {msg.payload=11} \nelse if(current = \"Snow\") {msg.payload=3} \nelse if(current = \"Clear\") {msg.payload=0} \nelse if(current = \"Fog\") {msg.payload=6} \nelse {msg.payload=0}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":250,"y":500,"wires":[["2742251f.660cfa"]]},{"id":"70f31843.a26708","type":"ui_template","z":"35ba5f50.a8d188","group":"a169147b.3a0718","name":"Weather Icon Image","order":2,"width":"4","height":"3","format":"<div style=\"display: flex;height: 100%;justify-content: center;align-items: center;\">\n<i class=\"fa-4x wi {{msg.payload}}\"></i>\n</div>","storeOutMessages":false,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":780,"y":500,"wires":[[]]},{"id":"2742251f.660cfa","type":"function","z":"35ba5f50.a8d188","name":"Look up Weather Icon","func":"var weathericons = flow.get( \"weathericons\");\nmsg.payload = weathericons[msg.payload];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":500,"y":480,"wires":[["70f31843.a26708"]]},{"id":"cc3d7e4b.4198e","type":"ui_template","z":"35ba5f50.a8d188","group":"a169147b.3a0718","name":"Load CSS","order":3,"width":"0","height":"0","format":"<link rel=\"stylesheet\" href=\"/weather-icons-lite/css/weather-icons-lite.min.css\">\n<style>\n .nr-dashboard-theme-dark ui-card-panel {\n \tbackground-color: #222;\n \toutline: 1px solid #cccccc;\n \t }\n</style>\n","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":270,"y":600,"wires":[[]]},{"id":"a7d9fda6.54232","type":"xml","z":"35ba5f50.a8d188","name":"","attr":"","chr":"","x":440,"y":640,"wires":[["f788af5.7bc085"]]},{"id":"d2e4d172.2de9b","type":"http request","z":"35ba5f50.a8d188","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/Paul-Reed/weather-icons-lite/master/xml/weather-icons-lite.xml","tls":"","persist":false,"proxy":"","authType":"","x":280,"y":640,"wires":[["a7d9fda6.54232"]]},{"id":"f788af5.7bc085","type":"function","z":"35ba5f50.a8d188","name":"Array of Weather Icon names","func":"var weathericons = [];\nvar icon_name;\nfor( var i = 0; i < msg.payload.resources.string.length; i++ ) {\n // Replace all of the \"wi_day_sunny\" with \"wi-day-sunny\"\n // Except when the icon name should actually be wi-wu-nt_*\n icon_name = msg.payload.resources.string[i].$.name.replace(/_/g,\"-\");\n icon_name = icon_name.replace(/nt-/g,\"nt_\");\n weathericons.push(icon_name);\n\n}\n\nmsg.payload = weathericons;\nflow.set(\"weatherIcons\", weathericons );\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":650,"y":640,"wires":[["5991cd08.c25eb4"]]},{"id":"5991cd08.c25eb4","type":"change","z":"35ba5f50.a8d188","name":"","rules":[{"t":"set","p":"weathericons","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":640,"wires":[[]]},{"id":"2217b523.86a3ca","type":"ui_gauge","z":"35ba5f50.a8d188","name":"","group":"a169147b.3a0718","order":4,"width":"4","height":"4","gtype":"gage","title":"Temperature Outside","label":"Cº","format":"{{msg.payload.forecast_temp[0]}}","min":"0","max":"35","colors":["#53d5fd","#77bb41","#ca3838"],"seg1":"","seg2":"","x":960,"y":340,"wires":[]},{"id":"f0686326.6ccec","type":"ui_text","z":"35ba5f50.a8d188","group":"a169147b.3a0718","order":1,"width":"4","height":"1","name":"","label":"Current Weather:","format":"{{msg.payload.forecast_w[0]}}","layout":"col-center","x":950,"y":400,"wires":[]},{"id":"f60ad9d2.3aa128","type":"debug","z":"35ba5f50.a8d188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":380,"y":60,"wires":[]},{"id":"7e1e4e2d.3e483","type":"ui_group","name":"Current","tab":"ae5c94a3.42c948","order":1,"disp":true,"width":"4","collapse":false},{"id":"438cdf8b.0c6a6","type":"ui_group","name":"Heat Index","tab":"ae5c94a3.42c948","order":2,"disp":true,"width":"9","collapse":false},{"id":"a611f497.f3df88","type":"ui_group","name":"Previous data","tab":"ae5c94a3.42c948","order":3,"disp":false,"width":"9","collapse":false},{"id":"a169147b.3a0718","type":"ui_group","name":"Outside Weather","tab":"ae5c94a3.42c948","order":4,"disp":false,"width":"4","collapse":false},{"id":"ae5c94a3.42c948","type":"ui_tab","name":"User APP","icon":"home","order":2,"disabled":false,"hidden":false}]