johnwalicki / node-red-contrib-twc-weather

Node-RED nodes for The Weather Company and Weather Underground Personal Weather Station APIs
Apache License 2.0
10 stars 11 forks source link

twc kills node red #6

Open daniceguy1612 opened 3 years ago

daniceguy1612 commented 3 years ago

Hi, if got these exit several times: Aug 23 20:56:44 smarthome node-red[28675]: 23 Aug 20:56:44 - [red] Uncaught Exception: Aug 23 20:56:44 smarthome node-red[28675]: 23 Aug 20:56:44 - TypeError: Cannot read property 'data' of undefined Aug 23 20:56:44 smarthome node-red[28675]: at /mnt/dietpi_userdata/node-red/node_modules/node-red-contrib-twc-weather/pws-current.js:60:40 Aug 23 20:56:44 smarthome node-red[28675]: at runMicrotasks () Aug 23 20:56:44 smarthome node-red[28675]: at processTicksAndRejections (node:internal/process/task_queues:94:5) Aug 23 20:56:44 smarthome systemd[1]: node-red.service: Main process exited, code=exited, status=1/FAILURE Aug 23 20:56:44 smarthome systemd[1]: node-red.service: Failed with result 'exit-code'.

Ive got no Idea why this happens.

johnwalicki commented 3 years ago

Hi @daniceguy1612 - Can you provide some additional information about how you were calling the PWS Observations node? What version of Node-RED are you running? What version of node-red-contrib-twc-weather ?

Line 60 is the console.log() call in the catch()

          try {
            const response = await axios.get('https://api.weather.com/v2/pws/observations/current?stationId=' + curStationId +'&format=json&units='+msg.twcparams.units+'&apiKey='+apiKey);
            //console.log(response.data)
            msg.payload = response.data;
            node.send(msg);
          } catch (error) {
            console.log(error.response.data);
            //console.log(error.response.status);
            node.warn(error.response.data);
            node.send(msg);
          }
daniceguy1612 commented 3 years ago

thanks for your attention! node red v 1.2.9 twc 0.4.1 Node.js version: v15.13.0

in my pws-current.js is exactly what you post, what should i try?

heres my flow:

[{"id":"2bdd775d.9b8cb8","type":"tab","label":"Wetter","disabled":false,"info":""},{"id":"4118ba23.e1e234","type":"pws-observations","z":"2bdd775d.9b8cb8","name":"","stationid":"IOSCHE1","units":"m","apikey":"ba693fed.4c01f8","x":375,"y":120,"wires":[["8a74e813.b77cc8","8db68e90.e9147","fec0eea.eb7211","a13631a4.67eb9","bec5e8b1.234e18"]],"l":false},{"id":"86fc3eea.7823f","type":"ui_gauge","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":4,"width":6,"height":3,"gtype":"gage","title":"Temperatur","label":"°C","format":"{{value}}","min":"-35","max":"40","colors":["#001eb3","#35ed5a","#ca3838"],"seg1":"-5","seg2":"25","x":1070,"y":20,"wires":[]},{"id":"fec0eea.eb7211","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":430,"y":40,"wires":[]},{"id":"8a74e813.b77cc8","type":"change","z":"2bdd775d.9b8cb8","name":"Temperatur","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.observations[0].metric.temp","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":60,"wires":[["86fc3eea.7823f","1c8320ac.ff1faf"]]},{"id":"8db68e90.e9147","type":"change","z":"2bdd775d.9b8cb8","name":"Niederschlag","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.observations[0].metric.precipTotal","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":100,"wires":[["9aa55f59.1da7c"]]},{"id":"1563cf4e.fa8d21","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":340,"wires":[]},{"id":"9aa55f59.1da7c","type":"ui_gauge","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":6,"width":6,"height":3,"gtype":"wave","title":"Regen","label":"mm","format":"{{value}}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1050,"y":100,"wires":[]},{"id":"a13631a4.67eb9","type":"change","z":"2bdd775d.9b8cb8","name":"Wind","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.observations[0].metric.windSpeed","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":180,"wires":[["97baf1d5.7e78c","ef93ee2c.cd614"]]},{"id":"ef93ee2c.cd614","type":"ui_gauge","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":8,"width":6,"height":3,"gtype":"compass","title":"Wind ","label":"km/h","format":"{{value}}","min":0,"max":"35","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1050,"y":180,"wires":[]},{"id":"92ad2057.1631f","type":"ui_button","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":3,"width":2,"height":1,"passthru":false,"label":"Wetter","tooltip":"","color":"","bgcolor":"","icon":"wi-wu-cloudy","payload":"","payloadType":"date","topic":"","topicType":"str","x":35,"y":80,"wires":[["4118ba23.e1e234"]],"l":false},{"id":"97baf1d5.7e78c","type":"ui_chart","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":9,"width":0,"height":0,"label":"Wind km/h","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"warte auf Daten","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":1070,"y":220,"wires":[[]]},{"id":"a809ce7c.8ec05","type":"trigger","z":"2bdd775d.9b8cb8","name":"","op1":"","op2":"0","op1type":"date","op2type":"str","duration":"-5","extend":false,"overrideDelay":false,"units":"min","reset":"0","bytopic":"all","topic":"topic","outputs":1,"x":230,"y":160,"wires":[["4118ba23.e1e234"]]},{"id":"4ff21b4f.de6b74","type":"ui_slider","z":"2bdd775d.9b8cb8","name":"","label":"Auto","tooltip":"","group":"62acffe6.21fe7","order":1,"width":3,"height":1,"passthru":true,"outs":"end","topic":"topic","topicType":"msg","min":0,"max":"1","step":1,"x":70,"y":120,"wires":[["a809ce7c.8ec05"]]},{"id":"519cc84e.b15c68","type":"ui_chart","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":7,"width":0,"height":0,"label":"Regen mm/h","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"warte auf Daten","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":1070,"y":140,"wires":[[]]},{"id":"bec5e8b1.234e18","type":"change","z":"2bdd775d.9b8cb8","name":"Niederschlag","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.observations[0].metric.precipRate","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":140,"wires":[["519cc84e.b15c68"]]},{"id":"1c8320ac.ff1faf","type":"ui_chart","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":5,"width":0,"height":0,"label":"Temperaturverlauf","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"warte auf Daten","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":1090,"y":60,"wires":[[]]},{"id":"ba693fed.4c01f8","type":"pwsapikey","name":"IOSCHE1"},{"id":"62acffe6.21fe7","type":"ui_group","name":"W1","tab":"81002e94.47829","order":1,"disp":false,"width":"6","collapse":false},{"id":"81002e94.47829","type":"ui_tab","name":"Wetter","icon":"wi-wu-clear","order":2,"disabled":false,"hidden":false}]

johnwalicki commented 3 years ago

I will let your flow run for a while. It seems to be working fine on my system.

10 Sep 14:12:45 - [info] Node-RED version: v2.0.5
10 Sep 14:12:45 - [info] Node.js  version: v14.17.0
10 Sep 14:12:45 - [info] Linux 5.13.14-200.fc34.x86_64 x64 LE
daniceguy1612 commented 2 years ago

It`s me again. Moved System from RPi to VM on QNAP NAS. Still the same Probleme here. Any suggestions?

Apr 14 12:24:43 DietPi node-red[1608]: (Use node --trace-deprecation ... to show where the warning was created) Apr 14 12:24:43 DietPi node-red[1608]: 14 Apr 12:24:43 - [info] Apr 14 12:24:43 DietPi node-red[1608]: Willkommen bei Node-RED! Apr 14 12:24:43 DietPi node-red[1608]: =================== Apr 14 12:24:43 DietPi node-red[1608]: 14 Apr 12:24:43 - [info] Node-RED Version: v1.3.7 Apr 14 12:24:43 DietPi node-red[1608]: 14 Apr 12:24:43 - [info] Node.js Version: v16.14.2 Apr 14 12:24:43 DietPi node-red[1608]: 14 Apr 12:24:43 - [info] Linux 5.10.0-13-amd64 x64 LE Apr 14 12:24:44 DietPi node-red[1608]: 14 Apr 12:24:44 - [info] Paletten-Nodes werden geladen Apr 14 12:24:45 DietPi node-red[1608]: 14 Apr 12:24:45 - [info] Dashboard version 3.1.6 started at /ui Apr 14 12:24:45 DietPi node-red[1608]: 14 Apr 12:24:45 - [info] Einstellungsdatei: /mnt/dietpi_userdata/node-red/settings.js Apr 14 12:24:45 DietPi node-red[1608]: 14 Apr 12:24:45 - [info] Kontextspeicher: default [module=memory] Apr 14 12:24:45 DietPi node-red[1608]: 14 Apr 12:24:45 - [info] Benutzerverzeichnis: /mnt/dietpi_userdata/node-red Apr 14 12:24:45 DietPi node-red[1608]: 14 Apr 12:24:45 - [warn] Projekte deaktiviert: editorTheme.projects.enabled=false Apr 14 12:24:45 DietPi node-red[1608]: 14 Apr 12:24:45 - [info] Flow-Datei: /mnt/dietpi_userdata/node-red/flows_DietPi.json Apr 14 12:24:45 DietPi node-red[1608]: 14 Apr 12:24:45 - [info] Server wird jetzt auf http://127.0.0.1:1880/ ausgeführt Apr 14 12:24:45 DietPi node-red[1608]: 14 Apr 12:24:45 - [warn] Apr 14 12:24:45 DietPi node-red[1608]: --------------------------------------------------------------------- Apr 14 12:24:45 DietPi node-red[1608]: Die Datei mit den Flow-Berechtigungen wird mit einem vom System Apr 14 12:24:45 DietPi node-red[1608]: generierten Schlüssel verschlüsselt. Apr 14 12:24:45 DietPi node-red[1608]: Wenn der vom System generierte Schlüssel aus irgendeinem Grund Apr 14 12:24:45 DietPi node-red[1608]: verloren geht, kann die Datei mit den Berechtigungen nicht Apr 14 12:24:45 DietPi node-red[1608]: wiederhergestellt werden. Sie muss dann gelöscht und die Apr 14 12:24:45 DietPi node-red[1608]: Berechtigungen müssen erneut eingestellt werden. Apr 14 12:24:45 DietPi node-red[1608]: Es sollte ein eigener Schlüssel mit Hilfe der Option Apr 14 12:24:45 DietPi node-red[1608]: 'credentialSecret' in der Einstellungsdatei vorgegeben werden. Apr 14 12:24:45 DietPi node-red[1608]: Node-RED wird dann die Datei mit den Flow-Berechtigungen Apr 14 12:24:45 DietPi node-red[1608]: bei der nächsten Übernahme (deploy) einer Änderung erneut Apr 14 12:24:45 DietPi node-red[1608]: verschlüsseln. Apr 14 12:24:45 DietPi node-red[1608]: --------------------------------------------------------------------- Apr 14 12:24:46 DietPi node-red[1608]: 14 Apr 12:24:46 - [info] Flows werden gestartet Apr 14 12:24:46 DietPi node-red[1608]: 14 Apr 12:24:46 - [info] Flows sind gestartet Apr 14 12:24:46 DietPi node-red[1608]: 14 Apr 12:24:46 - [info] [mqtt-broker: MQTT Mosquitto] Verbindung zum Broker nodered@mqtt://192.168.1.7:1883 aufgebaut Apr 16 08:24:27 DietPi node-red[1608]: 16 Apr 08:24:27 - [red] Uncaught Exception: Apr 16 08:24:27 DietPi node-red[1608]: 16 Apr 08:24:27 - TypeError: Cannot read properties of undefined (reading 'data') Apr 16 08:24:27 DietPi node-red[1608]: at /mnt/dietpi_userdata/node-red/node_modules/node-red-contrib-twc-weather/pws-current.js:79:40 Apr 16 08:24:27 DietPi node-red[1608]: at runMicrotasks () Apr 16 08:24:27 DietPi node-red[1608]: at processTicksAndRejections (node:internal/process/task_queues:96:5) Apr 16 08:24:27 DietPi systemd[1]: node-red.service: Main process exited, code=exited, status=1/FAILURE Apr 16 08:24:27 DietPi systemd[1]: node-red.service: Failed with result 'exit-code'. Apr 16 08:24:27 DietPi systemd[1]: node-red.service: Consumed 18min 5.866s CPU time.

I think my Flow is nearly the same: [{"id":"2bdd775d.9b8cb8","type":"tab","label":"Wetter","disabled":false,"info":""},{"id":"2cb86ffa.4dd2c","type":"pws-historical","z":"2bdd775d.9b8cb8","name":"","stationid":"IOSCHE1","units":"m","date":"","range":"hourly","apikey":"ba693fed.4c01f8","x":520,"y":540,"wires":[["fa69dfbd.1046d"]]},{"id":"35b66e17.220042","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":500,"wires":[]},{"id":"ec8b6d.de05c49","type":"comment","z":"2bdd775d.9b8cb8","name":"Query Historical Data from PWS","info":"","x":170,"y":500,"wires":[]},{"id":"fc48ec69.f807c","type":"pws-forecast","z":"2bdd775d.9b8cb8","name":"","units":"m","locationtype":"postalKey","location":"39387:DE","lang":"de-DE","apikey":"ba693fed.4c01f8","x":400,"y":660,"wires":[["1815de5c.7bbe12","f6f0d626.ef0168","676d6cb3.041684"]]},{"id":"e636f9e8.4dc928","type":"comment","z":"2bdd775d.9b8cb8","name":"5 Day Forecast","info":"","x":120,"y":620,"wires":[]},{"id":"9fd8e27.fd2fb2","type":"comment","z":"2bdd775d.9b8cb8","name":"Recent PWS Observations","info":"","x":150,"y":320,"wires":[]},{"id":"58e4ad6f.0675d4","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":870,"y":360,"wires":[]},{"id":"e1f2d161.f5c29","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":360,"wires":[]},{"id":"2ce72545.c0af4a","type":"ui_button","z":"2bdd775d.9b8cb8","name":"","group":"1bba4345.fa4d15","order":1,"width":0,"height":0,"passthru":false,"label":"Today Forecast","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":120,"y":660,"wires":[["fc48ec69.f807c"]]},{"id":"369ef6eb.74f97a","type":"ui_button","z":"2bdd775d.9b8cb8","name":"","group":"a91cd93c.4ca95","order":7,"width":0,"height":0,"passthru":false,"label":"7 Day PWS Hourly Summary","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":160,"y":360,"wires":[["6b5171b0.82599"]]},{"id":"5a59e080.e6225","type":"function","z":"2bdd775d.9b8cb8","name":"Get HourlyAvgTemp","func":"if( typeof( msg.payload.observations) == 'undefined') {\n return null;\n}\n\nvar HourlyAvgTempChart = [{\n \"series\":[\"7 Day Hourly Summary\"],\n \"data\":[[]],\n \"labels\":[\"Hourly Avg Temp\"]\n}];\n\n\nfor( var i=0; i < msg.payload.observations.length; i++) {\n AvgTemp = {\"x\":msg.payload.observations[i].epoch,\"y\":msg.payload.observations[i].imperial.tempAvg};\n HourlyAvgTempChart[0].data[0].push(AvgTemp) ;\n}\n\nmsg.payload = HourlyAvgTempChart;\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":400,"wires":[["58e4ad6f.0675d4","85c7a9d2.7b4be8"]]},{"id":"85c7a9d2.7b4be8","type":"ui_chart","z":"2bdd775d.9b8cb8","name":"","group":"ada0ce32.b103c","order":2,"width":"12","height":"4","label":"7 Day PWS Hourly Avg Temp","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"x":920,"y":400,"wires":[[]]},{"id":"71858b5c.c5d634","type":"ui_date_picker","z":"2bdd775d.9b8cb8","name":"","label":"Historical Date","group":"a91cd93c.4ca95","order":4,"width":0,"height":0,"passthru":true,"topic":"","x":120,"y":540,"wires":[["61aee12c.77c45"]]},{"id":"61aee12c.77c45","type":"change","z":"2bdd775d.9b8cb8","name":"Set twcparams","rules":[{"t":"set","p":"twcparams","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"twcparams.date","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"twcparams.StationID","pt":"msg","to":"StationID","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":540,"wires":[["2cb86ffa.4dd2c","454274ab.8ceb2c"]]},{"id":"454274ab.8ceb2c","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":490,"y":500,"wires":[]},{"id":"fa69dfbd.1046d","type":"change","z":"2bdd775d.9b8cb8","name":"Historical Date AvgTemp ","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.observations[0].imperial.tempAvg","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":540,"wires":[["c84baeee.f868f","35b66e17.220042"]]},{"id":"c84baeee.f868f","type":"ui_gauge","z":"2bdd775d.9b8cb8","name":"","group":"a91cd93c.4ca95","order":5,"width":0,"height":0,"gtype":"gage","title":"Historical Date AvgTemp","label":"F","format":"{{value}}","min":0,"max":"100","colors":["#0054ff","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1010,"y":540,"wires":[]},{"id":"1815de5c.7bbe12","type":"function","z":"2bdd775d.9b8cb8","name":"Narrative","func":"var Days = [];\nvar MyForecastStr;\nfor( var i=0; i < msg.payload.dayOfWeek.length; i++) {\n MyForecastStr = msg.payload.dayOfWeek[i] +\" : \"+msg.payload.narrative[i];\n Days.push(MyForecastStr)\n}\n\nreturn [{\"payload\":Days[0]},\n {\"payload\":Days[1]},\n {\"payload\":Days[2]},\n {\"payload\":Days[3]},\n {\"payload\":Days[4]},\n {\"payload\":Days[5]}];","outputs":6,"noerr":0,"initialize":"","finalize":"","x":300,"y":760,"wires":[["3424b9b6.4f6846","7fc1db7a.abe934"],["3424b9b6.4f6846","b698e7fb.44a8c8"],["3424b9b6.4f6846","266071df.4bf33e"],["3424b9b6.4f6846","9b00d33.87f6b3"],["3424b9b6.4f6846","f6c951b2.3bac1"],["3424b9b6.4f6846","bf292080.e0dde"]]},{"id":"f6f0d626.ef0168","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":660,"wires":[]},{"id":"3424b9b6.4f6846","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":960,"wires":[]},{"id":"7fc1db7a.abe934","type":"ui_text","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","order":3,"width":"6","height":"2","name":"","label":"","format":"{{msg.payload}}","layout":"row-left","x":510,"y":720,"wires":[]},{"id":"b698e7fb.44a8c8","type":"ui_text","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","order":5,"width":"6","height":"2","name":"","label":"","format":"{{msg.payload}}","layout":"row-left","x":510,"y":760,"wires":[]},{"id":"266071df.4bf33e","type":"ui_text","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","order":7,"width":"6","height":"2","name":"","label":"","format":"{{msg.payload}}","layout":"row-left","x":510,"y":800,"wires":[]},{"id":"9b00d33.87f6b3","type":"ui_text","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","order":9,"width":"6","height":"2","name":"","label":"","format":"{{msg.payload}}","layout":"row-left","x":510,"y":840,"wires":[]},{"id":"f6c951b2.3bac1","type":"ui_text","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","order":11,"width":"6","height":"2","name":"","label":"","format":"{{msg.payload}}","layout":"row-left","x":510,"y":880,"wires":[]},{"id":"bf292080.e0dde","type":"ui_text","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","order":13,"width":"6","height":"2","name":"","label":"","format":"{{msg.payload}}","layout":"row-left","x":510,"y":920,"wires":[]},{"id":"a3c9ad3e.d8773","type":"ui_template","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","name":"Weather Icon Image1","order":2,"width":"2","height":"2","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,"templateScope":"local","x":1020,"y":720,"wires":[[]]},{"id":"9d911f7b.6e92c","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"console":"false","complete":"payload","x":990,"y":960,"wires":[]},{"id":"676d6cb3.041684","type":"function","z":"2bdd775d.9b8cb8","name":"Weather Icon","func":"// TWC forecast API suggests a Icon code to display with the narrative\n// Map the icon codes to Weather Lite icons. See\n// https://github.com/Paul-Reed/weather-icons-lite\nvar IconMapping=[ \"wi-darksky-tornado\", \"wi-hurricane\",\n\"wi-hurricane\",\"wi-owm-11d\",\"wi-owm-11d\",\n\"wi-wu-rain\",\"wi-wu-sleet\",\"wi-wu-sleet\",\"wi-wu-sleet\",\n\"wi-wu-rain\",\"wi-wu-chancesleet\",\"wi-wu-rain\",\"wi-wu-rain\",\n\"wi-wu-flurries\",\"wi-wu-flurries\",\"wi-wu-snow\",\"wi-wu-snow\",\n\"wi-wu-sleet\",\"wi-wu-sleet\",\"wi-sandstorm\",\"wi-wu-hazy\",\n\"wi-wu-hazy\",\"wi-wu-hazy\",\"wi-darksky-wind\",\"wi-darksky-wind\",\n\"wi-wu-sleet\",\"wi-wu-cloudy\",\"wi-wu-mostlycloudy\",\n\"wi-wu-mostlycloudy\",\"wi-wu-partlycloudy\",\"wi-wu-partlycloudy\",\n\"wi-wu-clear\",\"wi-wu-sunny\",\"wi-owm-02d\",\"wi-owm-02d\",\"wi-wu-rain\",\n\"wi-wu-sunny\",\"wi-darksky-thunderstorm\",\"wi-darksky-thunderstorm\",\"wi-wu-chancerain\",\n\"wi-owm-10d\",\"wi-wu-flurries\",\"wi-wu-snow\",\"wi-wu-snow\",\"wi-na\",\n\"wi-wu-chancerain\",\"wi-wu-snow\",\"wi-wu-tstorms\"];\n\n\nvar Icon=[];\nfor(i = 0; i<=msg.payload.daypart[0].iconCode.length; i+=2){\n if( msg.payload.daypart[0].iconCode[i] !== null) {\n Icon.push(IconMapping[msg.payload.daypart[0].iconCode[i]]);\n } else {\n // Evening half day? - use the alternate icon\n Icon.push(IconMapping[msg.payload.daypart[0].iconCode[i+1]]);\n }\n}\n\n//node.send({\"payload\":Icon})\nreturn [{\"payload\":Icon[0]},\n {\"payload\":Icon[1]},\n {\"payload\":Icon[2]},\n {\"payload\":Icon[3]},\n {\"payload\":Icon[4]},\n {\"payload\":Icon[5]}];\n\n","outputs":6,"noerr":0,"initialize":"","finalize":"","x":750,"y":760,"wires":[["9d911f7b.6e92c","a3c9ad3e.d8773"],["9d911f7b.6e92c","b6da1898.955248"],["9d911f7b.6e92c","50bbff02.c90bb"],["9d911f7b.6e92c","6b49711a.e681d"],["9d911f7b.6e92c","90b8c557.03f488"],["9d911f7b.6e92c","e3bf4630.b95ff8"]]},{"id":"b6da1898.955248","type":"ui_template","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","name":"Weather Icon Image2","order":4,"width":"2","height":"2","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,"templateScope":"local","x":1020,"y":760,"wires":[[]]},{"id":"50bbff02.c90bb","type":"ui_template","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","name":"Weather Icon Image3","order":6,"width":"2","height":"2","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,"templateScope":"local","x":1020,"y":800,"wires":[[]]},{"id":"6b49711a.e681d","type":"ui_template","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","name":"Weather Icon Image4","order":8,"width":"2","height":"2","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,"templateScope":"local","x":1020,"y":840,"wires":[[]]},{"id":"90b8c557.03f488","type":"ui_template","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","name":"Weather Icon Image5","order":10,"width":"2","height":"2","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,"templateScope":"local","x":1020,"y":880,"wires":[[]]},{"id":"e3bf4630.b95ff8","type":"ui_template","z":"2bdd775d.9b8cb8","group":"1bba4345.fa4d15","name":"Weather Icon Image6","order":12,"width":"2","height":"2","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":1020,"y":920,"wires":[[]]},{"id":"5f18bc58.def444","type":"pws-7day-hourly","z":"2bdd775d.9b8cb8","name":"","stationid":"IOSCHE1","units":"m","apikey":"ba693fed.4c01f8","x":430,"y":400,"wires":[["e1f2d161.f5c29","5a59e080.e6225"]]},{"id":"6b5171b0.82599","type":"change","z":"2bdd775d.9b8cb8","name":"Set twcparams","rules":[{"t":"set","p":"twcparams","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"twcparams.StationID","pt":"msg","to":"StationID","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":360,"wires":[["5f18bc58.def444"]]},{"id":"4118ba23.e1e234","type":"pws-observations","z":"2bdd775d.9b8cb8","name":"","stationid":"IOSCHE1","units":"m","apikey":"ba693fed.4c01f8","x":450,"y":120,"wires":[["8a74e813.b77cc8","8db68e90.e9147","fec0eea.eb7211","a13631a4.67eb9","bec5e8b1.234e18"]]},{"id":"86fc3eea.7823f","type":"ui_gauge","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":4,"width":6,"height":3,"gtype":"gage","title":"Temperatur","label":"°C","format":"{{value}}","min":"-35","max":"40","colors":["#001eb3","#35ed5a","#ca3838"],"seg1":"-5","seg2":"25","x":1070,"y":20,"wires":[]},{"id":"fec0eea.eb7211","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":430,"y":40,"wires":[]},{"id":"8a74e813.b77cc8","type":"change","z":"2bdd775d.9b8cb8","name":"Temperatur","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.observations[0].metric.temp","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":60,"wires":[["86fc3eea.7823f","1c8320ac.ff1faf"]]},{"id":"8db68e90.e9147","type":"change","z":"2bdd775d.9b8cb8","name":"Niederschlag","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.observations[0].metric.precipTotal","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":100,"wires":[["1563cf4e.fa8d21","9aa55f59.1da7c"]]},{"id":"1563cf4e.fa8d21","type":"debug","z":"2bdd775d.9b8cb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1250,"y":100,"wires":[]},{"id":"9aa55f59.1da7c","type":"ui_gauge","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":6,"width":6,"height":3,"gtype":"wave","title":"Regen","label":"mm","format":"{{value}}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1050,"y":100,"wires":[]},{"id":"a13631a4.67eb9","type":"change","z":"2bdd775d.9b8cb8","name":"Wind","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.observations[0].metric.windSpeed","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":180,"wires":[["97baf1d5.7e78c","ef93ee2c.cd614"]]},{"id":"ef93ee2c.cd614","type":"ui_gauge","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":8,"width":6,"height":3,"gtype":"compass","title":"Wind ","label":"km/h","format":"{{value}}","min":0,"max":"35","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1050,"y":180,"wires":[]},{"id":"92ad2057.1631f","type":"ui_button","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":3,"width":2,"height":1,"passthru":false,"label":"Wetter","tooltip":"","color":"","bgcolor":"","icon":"wi-wu-cloudy","payload":"","payloadType":"str","topic":"","topicType":"str","x":35,"y":80,"wires":[["4118ba23.e1e234"]],"l":false},{"id":"97baf1d5.7e78c","type":"ui_chart","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":9,"width":0,"height":0,"label":"Wind km/h","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"warte auf Daten","dot":true,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":1070,"y":220,"wires":[[]]},{"id":"a809ce7c.8ec05","type":"trigger","z":"2bdd775d.9b8cb8","name":"","op1":"","op2":"0","op1type":"date","op2type":"str","duration":"-1","extend":false,"overrideDelay":false,"units":"min","reset":"0","bytopic":"all","topic":"topic","outputs":1,"x":230,"y":160,"wires":[["4118ba23.e1e234"]]},{"id":"4ff21b4f.de6b74","type":"ui_slider","z":"2bdd775d.9b8cb8","name":"","label":"Auto","tooltip":"","group":"62acffe6.21fe7","order":1,"width":3,"height":1,"passthru":true,"outs":"end","topic":"topic","topicType":"msg","min":0,"max":"1","step":1,"x":70,"y":120,"wires":[["a809ce7c.8ec05"]]},{"id":"519cc84e.b15c68","type":"ui_chart","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":7,"width":0,"height":0,"label":"Regen mm/h","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"warte auf Daten","dot":true,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":1070,"y":140,"wires":[[]]},{"id":"bec5e8b1.234e18","type":"change","z":"2bdd775d.9b8cb8","name":"Niederschlag","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.observations[0].metric.precipRate","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":140,"wires":[["519cc84e.b15c68"]]},{"id":"1c8320ac.ff1faf","type":"ui_chart","z":"2bdd775d.9b8cb8","name":"","group":"62acffe6.21fe7","order":5,"width":0,"height":0,"label":"Temperaturverlauf","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"warte auf Daten","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":1090,"y":60,"wires":[[]]},{"id":"ba693fed.4c01f8","type":"pwsapikey","name":"IOSCHE1"},{"id":"1bba4345.fa4d15","type":"ui_group","name":"Forecast","tab":"a105e68a.f1f57","order":3,"disp":true,"width":"8","collapse":false},{"id":"a91cd93c.4ca95","type":"ui_group","name":"PWS Queries","tab":"a105e68a.f1f57","order":1,"disp":true,"width":"6","collapse":false},{"id":"ada0ce32.b103c","type":"ui_group","name":"PWS Results","tab":"a105e68a.f1f57","order":2,"disp":true,"width":"12","collapse":false},{"id":"62acffe6.21fe7","type":"ui_group","name":"W1","tab":"81002e94.47829","order":1,"disp":false,"width":"6","collapse":false},{"id":"a105e68a.f1f57","type":"ui_tab","name":"PWS Example","icon":"wi-wu-partlycloudy","order":8,"disabled":false,"hidden":true},{"id":"81002e94.47829","type":"ui_tab","name":"Wetter","icon":"wi-wu-clear","order":2,"disabled":false,"hidden":false}]

johnwalicki commented 2 years ago

Hi @daniceguy1612 - I have deployed your example flow and will watch it over the next several hours / days.

johnwalicki commented 2 years ago

@daniceguy1612 The flow has been running fine for 3 days.

daniceguy1612 commented 2 years ago

Have you activated the Automatic Data reciving every Minute ? There is a Slider for it. The Error occours only when i collect the Data.

johnwalicki commented 2 years ago

Yes, it's querying data every minute.

daniceguy1612 commented 2 years ago

Can i do Something Else to find the Error? Activate deeper logging or Something?

johnwalicki commented 2 years ago

Enable console logging. In your ~/.node-red directory, edit your settings.js file. Change the logging > console > level to trace

    logging: {
        console: {
            // Level of logging to be recorded. Options are:
            // trace - record very detailed logging + debug + info + warn + error + fatal errors
            level: "trace"
        }
daniceguy1612 commented 2 years ago

Hope you can find out something.

Mai 06 13:16:38 DietPi node-red[15645]: 6 May 13:16:38 - [red] Uncaught Exception: Mai 06 13:16:38 DietPi node-red[15645]: 6 May 13:16:38 - TypeError: Cannot read properties of undefined (reading 'data') Mai 06 13:16:38 DietPi node-red[15645]: at /mnt/dietpi_userdata/node-red/node_modules/node-red-contrib-twc-weather/pws-current.js:79:40 Mai 06 13:16:38 DietPi node-red[15645]: at runMicrotasks () Mai 06 13:16:38 DietPi node-red[15645]: at processTicksAndRejections (node:internal/process/task_queues:96:5) Mai 06 13:16:42 DietPi systemd[1]: node-red.service: Main process exited, code=exited, status=1/FAILURE Mai 06 13:16:42 DietPi systemd[1]: node-red.service: Failed with result 'exit-code'. Mai 06 13:16:42 DietPi systemd[1]: node-red.service: Consumed 33min 55.796s CPU time.

johnwalicki commented 2 years ago

This trace provides some clues. I will investigate. I'm traveling this week so will be slow to test.

johnwalicki commented 2 years ago

Ok - I see. Line 79 is already inside the error handler.

https://github.com/johnwalicki/node-red-contrib-twc-weather/blob/96907585e792d5f99f14a5ffaa1f7cb5fc75c30e/pws-current.js#L78-L83

The node-red-contrib-twc-weather nodes use the axios http library to call the TWC apis. If there is an error, error handler tries to console.log the error. However, if the json object error.response.data doesn't exist, the error you are experiencing would occur.

What the error handler should do is implement the full error handling recommended here: https://axios-http.com/docs/handling_errors

Its a trivial to add additional error handling (but in nine difference sections of code) That will prevent Node-RED from crashing. The TWC API call failed for some other reason.

Will work on this tomorrow.

johnwalicki commented 2 years ago

Fixed in node-red-contrib-twc-weather@0.6.0 release

npm install node-red-contrib-twc-weather@0.6.0
johnwalicki commented 2 years ago

@daniceguy1612 - When you have time, please upgrade / install v0.6.0. It includes additional axios error handling. Node-RED should not crash. There will be error details in the console log. Then we can figure out why your TWC api calls are intermittently failing.

daniceguy1612 commented 2 years ago

Thank you very much! I ve updated and we will see :) Can i donate for your work?

johnwalicki commented 2 years ago

I'll keep this issue open until you report back. I'm a weather nerd - enjoy. Buy me a Heineken next time I'm near Leiden.