├── PWS-Examples.png ├── PWS-Dashboard.png ├── PWS-Dashboard-flow.png ├── wunderground-mydevices.png ├── icons └── wi-wu-partlycloudy.png ├── SECURITY.md ├── .github └── workflows │ └── npm-publish.yml ├── package.json ├── CHANGELOG.md ├── twc-health.js ├── pws-forecast.js ├── twc-core.js ├── twc-nowcast.html ├── pws-current.js ├── twc-nowcast.js ├── pws-historical.html ├── pws-forecast.html ├── README.md ├── pws-current.html ├── twc-health.html ├── pws-historical.js ├── twc-core.html ├── npm-shrinkwrap.json ├── pws-recent.html ├── pws-recent.js ├── LICENSE └── examples ├── PWS-Examples.json └── PWS-Dashboard.json /PWS-Examples.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/node-red-contrib-twc-weather/main/PWS-Examples.png -------------------------------------------------------------------------------- /PWS-Dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/node-red-contrib-twc-weather/main/PWS-Dashboard.png -------------------------------------------------------------------------------- /PWS-Dashboard-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/node-red-contrib-twc-weather/main/PWS-Dashboard-flow.png -------------------------------------------------------------------------------- /wunderground-mydevices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/node-red-contrib-twc-weather/main/wunderground-mydevices.png -------------------------------------------------------------------------------- /icons/wi-wu-partlycloudy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/node-red-contrib-twc-weather/main/icons/wi-wu-partlycloudy.png -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please report any potential security issues to `johnwalicki@gmail.com`. This will notify the core project team who will respond accordingly. 6 | 7 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: actions/setup-node@v3 16 | with: 17 | node-version: 16 18 | - run: npm ci 19 | - run: npm test 20 | 21 | publish-npm: 22 | needs: build 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v3 26 | - uses: actions/setup-node@v3 27 | with: 28 | node-version: 16 29 | registry-url: https://registry.npmjs.org/ 30 | - run: npm ci 31 | - run: npm publish 32 | env: 33 | NODE_AUTH_TOKEN: ${{secrets.npm_token}} 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-red-contrib-twc-weather", 3 | "version": "0.7.0", 4 | "description": "Node-RED nodes for The Weather Company and Weather Underground Data APIs", 5 | "main": "pws-current.js", 6 | "scripts": { 7 | "test": "echo \"no test required\" && exit 0" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/johnwalicki/node-red-contrib-twc-weather.git" 12 | }, 13 | "keywords": [ 14 | "node-red", 15 | "weather", 16 | "twc", 17 | "pws", 18 | "forecast", 19 | "weatherunderground" 20 | ], 21 | "author": "John Walicki ", 22 | "license": "Apache-2.0", 23 | "bugs": { 24 | "url": "https://github.com/johnwalicki/node-red-contrib-twc-weather/issues" 25 | }, 26 | "homepage": "https://github.com/johnwalicki/node-red-contrib-twc-weather#readme", 27 | "node-red": { 28 | "version": ">=2.0.0", 29 | "nodes": { 30 | "pws-observations": "pws-current.js", 31 | "pws-historical": "pws-historical.js", 32 | "pws-forecast": "pws-forecast.js", 33 | "pws-recent": "pws-recent.js", 34 | "twc-health": "twc-health.js", 35 | "twc-core": "twc-core.js", 36 | "twc-nowcast": "twc-nowcast.js" 37 | } 38 | }, 39 | "engines": { 40 | "node": ">=12.0.0" 41 | }, 42 | "dependencies": { 43 | "axios": ">=0.27.2" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | #### Change Log for node-red-contrib-twc-weather 2 | 3 | - v0.7.0 4 | - numericPrecision option added to pws-historical and pws-recent nodes 5 | - v0.6.1 6 | - Improve Scorecard results 7 | - Declare minimum version of node.js and Node-RED 8 | - v0.6.0 9 | - Add additional axios error handling ([#6](https://github.com/johnwalicki/node-red-contrib-twc-weather/issues/6)) 10 | - Bump axios version 11 | - v0.5.2 12 | - Set up a npm publish pipeline 13 | - Add a SECURITY.md as suggested by OpenSSF Best Practices checklist 14 | - Add npm-shrinkwrap.json for pipeline 15 | - v0.5.0 16 | - numericPrecision option added to pws-current observations node (jimison) 17 | - Bump axios version 18 | - v0.4.1 19 | - Bump axios version (CVE-2020-28168) 20 | - v0.4.0 21 | - Refactor nodes to use axios for network requests 22 | - twcparams bug fix in pws historical node 23 | - Add TWC 6 Hour Nowcast API from the TWC Enhanced Forecast package 24 | - Nowcast Example flow 25 | - v0.3.1 26 | - fix StationID bug in 7 Day recent history nodes 27 | - Better Weather Dashboard example 28 | - v0.3.0 29 | - msg.twcparams input override values for all query parameters for the PWS/TWC nodes 30 | - Return msg.twcparams object with the query params so that they can be used downstream in the flow for possible display on a dashboard. 31 | - PWS / TWC documentation enhancements 32 | - Add TWC Daily Forecast node - (3, 5, 7, 10, 15 Day) from the TWC Core Weather Data Package 33 | - v0.2.0 34 | - Add Cognitive Health Forecast APIs from Lifestyle Indices Weather Data Package 35 | - v0.1.0 36 | - Initial release - Personal Weather Station wunderground APIs 37 | -------------------------------------------------------------------------------- /twc-health.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | function weatherTWCHealthForecastNode( n ) { 3 | RED.nodes.createNode(this,n ); 4 | var node = this; 5 | var name = n.name; 6 | var locationtype = n.locationtype; 7 | var location= n.location; 8 | var lang = n.lang; 9 | var conditiontype = n.conditiontype; 10 | var range = n.range; 11 | var pwsConfigNode; 12 | var apiKey; 13 | const axios = require('axios'); 14 | 15 | // Retrieve the config node 16 | pwsConfigNode = RED.nodes.getNode(n.apikey); 17 | apiKey = pwsConfigNode.credentials.apikey; 18 | 19 | if (!lang) { 20 | lang = 'en-US'; 21 | } 22 | 23 | node.on('input', function (msg) { 24 | msg.twcparams = msg.twcparams || {}; 25 | 26 | if( typeof msg.twcparams.range == 'undefined' ) { 27 | msg.twcparams.range = range; 28 | } 29 | 30 | if( typeof msg.twcparams.conditiontype == 'undefined' ) { 31 | msg.twcparams.conditiontype = conditiontype; 32 | } 33 | 34 | if( typeof msg.twcparams.lang == 'undefined' ) { 35 | msg.twcparams.lang = lang; 36 | } 37 | 38 | if( typeof msg.twcparams.location == 'undefined' ) { 39 | msg.twcparams.location = location; 40 | } 41 | 42 | if( typeof msg.twcparams.locationtype == 'undefined' ) { 43 | msg.twcparams.locationtype = locationtype; 44 | } 45 | 46 | (async () => { 47 | try { 48 | const response = await axios.get('https://api.weather.com/v3/wx/forecast/daily/'+msg.twcparams.range+'/cognitiveHealth?'+ msg.twcparams.locationtype + '='+ msg.twcparams.location +'&conditionType='+msg.twcparams.conditiontype+'&format=json&language='+msg.twcparams.lang+'&apiKey='+apiKey); 49 | //console.log(response.data) 50 | msg.payload = response.data; 51 | node.send(msg); 52 | } catch (error) { 53 | //console.log(error.response.data); 54 | //console.log(error.response.status); 55 | if (error.response) { 56 | // The request was made and the server responded with a status code 57 | // that falls out of the range of 2xx 58 | console.log(error.response.data); 59 | console.log(error.response.status); 60 | console.log(error.response.headers); 61 | node.warn(error.response.data); 62 | } else if (error.request) { 63 | // The request was made but no response was received 64 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of 65 | // http.ClientRequest in node.js 66 | console.log(error.request); 67 | } else { 68 | // Something happened in setting up the request that triggered an Error 69 | console.log('Error', error.message); 70 | } 71 | console.log(error.config); 72 | console.log(error.toJSON()); 73 | node.send(msg); 74 | } 75 | })(); 76 | }); 77 | } 78 | RED.nodes.registerType("twc-health-forecast",weatherTWCHealthForecastNode); 79 | } 80 | -------------------------------------------------------------------------------- /pws-forecast.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | function weatherPWS5DayForecastNode( n ) { 3 | RED.nodes.createNode(this,n ); 4 | var node = this; 5 | var units = n.units; 6 | var name = n.name; 7 | var locationtype = n.locationtype; 8 | var location= n.location; 9 | var lang = n.lang; 10 | var pwsConfigNode; 11 | var apiKey; 12 | const axios = require('axios'); 13 | 14 | // Retrieve the config node 15 | pwsConfigNode = RED.nodes.getNode(n.apikey); 16 | apiKey = pwsConfigNode.credentials.apikey; 17 | 18 | if (!units) { 19 | units = 'm'; 20 | } 21 | if (!lang) { 22 | lang = 'en-US'; 23 | } 24 | 25 | node.on('input', function (msg) { 26 | 27 | msg.twcparams = msg.twcparams || {}; 28 | 29 | if( typeof msg.twcparams.units == 'undefined' ) { 30 | msg.twcparams.units = units; // take the default or the node setting 31 | } else if( "emhEMH".indexOf(msg.twcparams.units) >= 0 ) { 32 | // passed in param is valid, override default or node setting 33 | msg.twcparams.units = msg.twcparams.units.toLowerCase(); 34 | } else { 35 | msg.twcparams.units = units; // take the default or the node setting 36 | } 37 | 38 | if( typeof msg.twcparams.lang == 'undefined' ) { 39 | msg.twcparams.lang = lang; 40 | } 41 | 42 | if( typeof msg.twcparams.location == 'undefined' ) { 43 | msg.twcparams.location = location; 44 | } 45 | 46 | if( typeof msg.twcparams.locationtype == 'undefined' ) { 47 | msg.twcparams.locationtype = locationtype; 48 | } 49 | 50 | (async () => { 51 | try { 52 | const response = await axios.get('https://api.weather.com/v3/wx/forecast/daily/5day?'+ msg.twcparams.locationtype + '='+ msg.twcparams.location +'&format=json&language='+msg.twcparams.lang+'&units='+msg.twcparams.units+'&apiKey='+apiKey); 53 | //console.log(response.data) 54 | msg.payload = response.data; 55 | node.send(msg); 56 | } catch (error) { 57 | //console.log(error.response.data); 58 | //console.log(error.response.status); 59 | if (error.response) { 60 | // The request was made and the server responded with a status code 61 | // that falls out of the range of 2xx 62 | console.log(error.response.data); 63 | console.log(error.response.status); 64 | console.log(error.response.headers); 65 | node.warn(error.response.data); 66 | } else if (error.request) { 67 | // The request was made but no response was received 68 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of 69 | // http.ClientRequest in node.js 70 | console.log(error.request); 71 | } else { 72 | // Something happened in setting up the request that triggered an Error 73 | console.log('Error', error.message); 74 | } 75 | console.log(error.config); 76 | console.log(error.toJSON()); 77 | node.send(msg); 78 | } 79 | })(); 80 | }); 81 | } 82 | RED.nodes.registerType("pws-forecast",weatherPWS5DayForecastNode); 83 | } 84 | -------------------------------------------------------------------------------- /twc-core.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | function weatherTWCDailyForecastNode( n ) { 3 | RED.nodes.createNode(this,n ); 4 | var node = this; 5 | var units = n.units; 6 | var name = n.name; 7 | var locationtype = n.locationtype; 8 | var location= n.location; 9 | var lang = n.lang; 10 | var range = n.range; 11 | var pwsConfigNode; 12 | var apiKey; 13 | const axios = require('axios'); 14 | 15 | // Retrieve the config node 16 | pwsConfigNode = RED.nodes.getNode(n.apikey); 17 | apiKey = pwsConfigNode.credentials.apikey; 18 | 19 | if (!units) { 20 | units = 'm'; 21 | } 22 | if (!lang) { 23 | lang = 'en-US'; 24 | } 25 | if (!range) { 26 | range = '5day'; 27 | } 28 | 29 | node.on('input', function (msg) { 30 | msg.twcparams = msg.twcparams || {}; 31 | 32 | if( typeof msg.twcparams.units == 'undefined' ) { 33 | msg.twcparams.units = units; // take the default or the node setting 34 | } else if( "emhEMH".indexOf(msg.twcparams.units) >= 0 ) { 35 | // passed in param is valid, override default or node setting 36 | msg.twcparams.units = msg.twcparams.units.toLowerCase(); 37 | } else { 38 | msg.twcparams.units = units; // take the default or the node setting 39 | } 40 | 41 | if( typeof msg.twcparams.lang == 'undefined' ) { 42 | msg.twcparams.lang = lang; 43 | } 44 | 45 | if( typeof msg.twcparams.range == 'undefined' ) { 46 | msg.twcparams.range = range; 47 | } 48 | 49 | if( typeof msg.twcparams.location == 'undefined' ) { 50 | msg.twcparams.location = location; 51 | } 52 | 53 | if( typeof msg.twcparams.locationtype == 'undefined' ) { 54 | msg.twcparams.locationtype = locationtype; 55 | } 56 | 57 | (async () => { 58 | try { 59 | const response = await axios.get('https://api.weather.com/v3/wx/forecast/daily/'+msg.twcparams.range+'?'+ msg.twcparams.locationtype + '='+ msg.twcparams.location +'&format=json&language='+msg.twcparams.lang+'&units='+msg.twcparams.units+'&apiKey='+apiKey); 60 | //console.log(response.data) 61 | msg.payload = response.data; 62 | node.send(msg); 63 | } catch (error) { 64 | //console.log(error.response.data); 65 | //console.log(error.response.status); 66 | if (error.response) { 67 | // The request was made and the server responded with a status code 68 | // that falls out of the range of 2xx 69 | console.log(error.response.data); 70 | console.log(error.response.status); 71 | console.log(error.response.headers); 72 | node.warn(error.response.data); 73 | } else if (error.request) { 74 | // The request was made but no response was received 75 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of 76 | // http.ClientRequest in node.js 77 | console.log(error.request); 78 | } else { 79 | // Something happened in setting up the request that triggered an Error 80 | console.log('Error', error.message); 81 | } 82 | console.log(error.config); 83 | console.log(error.toJSON()); 84 | node.send(msg); 85 | } 86 | })(); 87 | }); 88 | } 89 | RED.nodes.registerType("twc-daily-forecast",weatherTWCDailyForecastNode); 90 | } 91 | -------------------------------------------------------------------------------- /twc-nowcast.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 56 | 57 | 85 | -------------------------------------------------------------------------------- /pws-current.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | function weatherPWSapikeyNode(n) { 3 | RED.nodes.createNode(this,n); 4 | var node = this; 5 | //node.apikey = n.apikey; 6 | } 7 | RED.nodes.registerType("pwsapikey", weatherPWSapikeyNode, { 8 | credentials: { 9 | apikey: {type: "password"} 10 | } 11 | }); 12 | 13 | function weatherPWSCurrentObsNode( n ) { 14 | RED.nodes.createNode(this,n ); 15 | var node = this; 16 | var StationId = n.stationid; 17 | var units = n.units; 18 | var precision = n.precision; 19 | var name = n.name; 20 | var pwsConfigNode; 21 | var apiKey; 22 | const axios = require('axios'); 23 | 24 | // Retrieve the config node 25 | pwsConfigNode = RED.nodes.getNode(n.apikey); 26 | apiKey = pwsConfigNode.credentials.apikey; 27 | 28 | if (!units) { 29 | units = 'm'; 30 | } 31 | if (!precision) { 32 | precision = 'i'; 33 | } 34 | 35 | node.on('input', function (msg) { 36 | msg.twcparams = msg.twcparams || {}; 37 | 38 | if( typeof msg.twcparams.units == 'undefined' ) { 39 | msg.twcparams.units = units; // take the default or the node setting 40 | } else if( "emhEMH".indexOf(msg.twcparams.units) >= 0 ) { 41 | // passed in param is valid, override default or node setting 42 | msg.twcparams.units = msg.twcparams.units.toLowerCase(); 43 | } else { 44 | msg.twcparams.units = units; // take the default or the node setting 45 | } 46 | 47 | if( typeof msg.twcparams.precision == 'undefined' ) { 48 | msg.twcparams.precision = precision; 49 | } else if( "idID".indexOf(msg.twcparams.precision) >= 0 ) { 50 | // passed in param is valid, override default or node setting 51 | msg.twcparams.precision = msg.twcparams.precision.toLowerCase(); 52 | } else { 53 | msg.twcparams.precision = precision; 54 | } 55 | 56 | if ( msg.twcparams.precision == 'd') { 57 | var numericPrecision = '&numericPrecision=decimal'; 58 | } else { 59 | var numericPrecision = ''; 60 | } 61 | 62 | var curStationId = StationId; 63 | if( typeof msg.twcparams.StationID != 'undefined' ) { 64 | curStationId = msg.twcparams.StationID.toUpperCase(); 65 | } 66 | if( !curStationId ) { 67 | // No StationID is set. Abort with error 68 | msg.payload = "Error: No StationID provided."; 69 | node.send(msg); 70 | } else { 71 | msg.twcparams.StationID = curStationId; 72 | (async () => { 73 | try { 74 | const response = await axios.get('https://api.weather.com/v2/pws/observations/current?stationId=' + curStationId +'&format=json&units='+msg.twcparams.units+'&apiKey='+apiKey+numericPrecision); 75 | //console.log(response.data) 76 | msg.payload = response.data; 77 | node.send(msg); 78 | } catch (error) { 79 | //console.log(error.response.data); 80 | //console.log(error.response.status); 81 | if (error.response) { 82 | // The request was made and the server responded with a status code 83 | // that falls out of the range of 2xx 84 | console.log(error.response.data); 85 | console.log(error.response.status); 86 | console.log(error.response.headers); 87 | node.warn(error.response.data); 88 | } else if (error.request) { 89 | // The request was made but no response was received 90 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of 91 | // http.ClientRequest in node.js 92 | console.log(error.request); 93 | } else { 94 | // Something happened in setting up the request that triggered an Error 95 | console.log('Error', error.message); 96 | } 97 | console.log(error.config); 98 | console.log(error.toJSON()); 99 | node.send(msg); 100 | } 101 | })(); 102 | } 103 | }); 104 | } 105 | RED.nodes.registerType("pws-observations",weatherPWSCurrentObsNode); 106 | } 107 | -------------------------------------------------------------------------------- /twc-nowcast.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | function weather6HrNowCastNode( n ) { 3 | RED.nodes.createNode(this,n ); 4 | var node = this; 5 | var units = n.units; 6 | var name = n.name; 7 | var locationtype = n.locationtype; 8 | var location= n.location; 9 | var lang = n.lang; 10 | var pwsConfigNode; 11 | var apiKey; 12 | const axios = require('axios'); 13 | 14 | // Retrieve the config node 15 | pwsConfigNode = RED.nodes.getNode(n.apikey); 16 | apiKey = pwsConfigNode.credentials.apikey; 17 | 18 | if (!units) { 19 | units = 'm'; 20 | } 21 | if (!lang) { 22 | lang = 'en-US'; 23 | } 24 | 25 | node.on('input', function (msg) { 26 | 27 | msg.twcparams = msg.twcparams || {}; 28 | 29 | if( typeof msg.twcparams.units == 'undefined' ) { 30 | msg.twcparams.units = units; // take the default or the node setting 31 | } else if( "emhEMH".indexOf(msg.twcparams.units) >= 0 ) { 32 | // passed in param is valid, override default or node setting 33 | msg.twcparams.units = msg.twcparams.units.toLowerCase(); 34 | } else { 35 | msg.twcparams.units = units; // take the default or the node setting 36 | } 37 | 38 | if( typeof msg.twcparams.lang == 'undefined' ) { 39 | msg.twcparams.lang = lang; 40 | } 41 | 42 | if( typeof msg.twcparams.location == 'undefined' ) { 43 | msg.twcparams.location = location; 44 | } 45 | 46 | if( typeof msg.twcparams.locationtype == 'undefined' ) { 47 | msg.twcparams.locationtype = locationtype; 48 | } 49 | 50 | var TWCendpoint ; 51 | if( msg.twcparams.locationtype == 'geocode' ) { 52 | const latlong = msg.twcparams.location.split(',') 53 | var latitude = parseFloat(latlong[0]); 54 | var longitude = parseFloat(latlong[1]); 55 | if( isNaN(latitude) || isNaN(longitude) ) { 56 | node.warn("Not a valid geocode"); 57 | return; 58 | } 59 | TWCendpoint = 'https://api.weather.com/v1/geocode/'+latitude+'/'+longitude+'/forecast/nowcast.json?language='+msg.twcparams.lang+'&units='+msg.twcparams.units+'&apiKey='+apiKey 60 | } else if( msg.twcparams.locationtype == 'postalKey' ) { 61 | // The Postal Code has a TWC proprietary location type (4) with the following format: 62 | // location/:: 63 | const postal = msg.twcparams.location.split(':') 64 | if( typeof postal[1] == 'undefined' ) { 65 | node.warn("Missing Country. Not a valid postalKey"); 66 | return; 67 | } 68 | TWCendpoint = 'https://api.weather.com/v1/location/'+postal[0]+':4:'+postal[1]+'/forecast/nowcast.json?language='+msg.twcparams.lang+'&units='+msg.twcparams.units+'&apiKey='+apiKey 69 | } 70 | 71 | (async () => { 72 | try { 73 | const response = await axios.get( TWCendpoint ); 74 | //console.log(response.data) 75 | msg.payload = response.data; 76 | node.send(msg); 77 | } catch (error) { 78 | //console.log(error.response.data); 79 | //console.log(error.response.status); 80 | if (error.response) { 81 | // The request was made and the server responded with a status code 82 | // that falls out of the range of 2xx 83 | console.log(error.response.data); 84 | console.log(error.response.status); 85 | console.log(error.response.headers); 86 | node.warn(error.response.data); 87 | } else if (error.request) { 88 | // The request was made but no response was received 89 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of 90 | // http.ClientRequest in node.js 91 | console.log(error.request); 92 | } else { 93 | // Something happened in setting up the request that triggered an Error 94 | console.log('Error', error.message); 95 | } 96 | console.log(error.config); 97 | console.log(error.toJSON()); 98 | node.send(msg); 99 | } 100 | })(); 101 | }); 102 | } 103 | RED.nodes.registerType("twc-nowcast",weather6HrNowCastNode); 104 | } 105 | -------------------------------------------------------------------------------- /pws-historical.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 65 | 66 | 93 | -------------------------------------------------------------------------------- /pws-forecast.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | 59 | 60 | 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # node-red-contrib-twc-weather 2 | 3 | Node-RED nodes for The Weather Company and Weather Underground Personal Weather Station APIs 4 | 5 | These nodes replace the depreciated **node-red-node-weather-underground** with new TWC apis for querying [wunderground.com](https://wunderground.com) Personal Weather Station (PWS) data. 6 | 7 | The set of nodes in this package implement the [APIs for Personal Weather Station Contributors](https://docs.google.com/document/d/1eKCnKXI9xnoMGRRzOL1xPCBihNV2rOet08qpE_gArAY). 8 | 9 | The Weather Company provides [TWC Weather Data Packages](https://www.ibm.com/products/weather-company-data-packages) that are available for purchase. Node-RED nodes in this package implement select API services. 10 | 11 | If you are building [Call for Code Global Challenge](https://developer.ibm.com/callforcode) solutions that fight [climate change](https://developer.ibm.com/callforcode/get-started/climate-change/), you can register and receive a time-limited free trial [TWC API key](https://developer.ibm.com/callforcode/tools/weather/) to assist in your projects. This TWC API key can be used for many of the Node-RED nodes in this node-red-contrib-twc-weather package. 12 | 13 | ## Install 14 | 15 | Either use the Editor - Menu - Manage Palette - Install option, or run the following command in your Node-RED user directory (typically `~/.node-red`). 16 | 17 | ```bash 18 | npm install node-red-contrib-twc-weather 19 | ``` 20 | 21 | ## Usage 22 | 23 | Register your Personal Weather Station at [wunderground](https://www.wunderground.com/member/devices) and copy your PWS Station ID and API Key into these Node-RED nodes. 24 | 25 | ![wunderground mydevices](wunderground-mydevices.png) 26 | 27 | ## node-red-contrib-twc-weather Nodes 28 | 29 | This Node-RED package creates six PWS nodes in your Node-RED palette. 30 | 31 | - **pws observations** - Personal Weather Station (PWS) Current Conditions returns the current conditions observations. 32 | - **pws historical** - Personal Weather Station (PWS) Historical Data returns the historical PWS data for a single date ( hourly data, summary data for the entire day, or all records ) 33 | - **pws forecast** - The Daily Forecast API is sourced from the The Weather Company Forecast system. This TWC API returns the 5 Day Daily weather forecast. 34 | - **pws 7 day summary** - Personal Weather Station (PWS) Daily Summary Historical Observations returns the 7 day summary of daily observations. 35 | - **pws 7 day hourly** - Personal Weather Stations (PWS) Hourly Historical Observations returns the hourly records for each days observations report. 36 | - **pws 1 day all** - Personal Weather Station (PWS) Rapid Historical Observations returns all of the observations records for a specific date. 37 | 38 | This Node-RED package creates TWC nodes in your Node-RED palette. 39 | 40 | - **TWC Daily Forecast** - (3, 5, 7, 10, 15 Day) Daily Forecast API from the TWC Core Weather Data Package. 41 | - **TWC Health Forecast** - The Cognitive Health Forecast API provides forecast data for the risk of allergy, migraine, cold and flu, or pain for a given location and for a period of one to 15 days in advance. 42 | - **TWC Nowcast** - The short range Nowcast Forecast API provides a text summary of the weather forecast for the next 6 hour period for today. 43 | 44 | Review the [CHANGELOG](https://github.com/johnwalicki/node-red-contrib-twc-weather/blob/master/CHANGELOG.md) for enhancement history. 45 | 46 | ## Examples 47 | 48 | Two examples are provided in the [examples](https://github.com/johnwalicki/node-red-contrib-twc-weather/tree/master/examples) folder. 49 | 50 | - Exercise each of the Node-RED PWS APIs by importing this [PWS-Examples.json flow](https://github.com/johnwalicki/node-red-contrib-twc-weather/blob/master/examples/PWS-Examples.json) 51 | 52 | ![PWS Examples](PWS-Examples.png) 53 | 54 | - Here is an example Weather Node-RED Dashboard that displays Personal Weather Station current and historical data on a map, in a table, a gauge and on a chart. The PWS API key includes access to the TWC 5 Day Forecast, which is displayed with [weather-lite icons](https://github.com/Paul-Reed/weather-icons-lite). This flow requires node-red-dashboard, node-red-node-ui-table and node-red-contrib-web-worldmap. Import this [PWS-Dashboard.json flow](https://github.com/johnwalicki/node-red-contrib-twc-weather/blob/master/examples/PWS-Dashboard.json) 55 | 56 | ![PWS Dashboard](PWS-Dashboard.png) 57 | 58 | ## Contributing and Developer information 59 | 60 | For reporting bugs, security issues, requesting features, and discussing changes, developers should use GitHub issues. Give me [feedback](https://github.com/johnwalicki/node-red-contrib-twc-weather/issues) if you have suggestions on how to improve these nodes. 61 | 62 | The Node-RED community welcomes your involvement and contributions to this project. Pull requests are welcome. 63 | 64 | #### Author 65 | 66 | - [John Walicki](https://github.com/johnwalicki/) 67 | 68 | ___ 69 | 70 | ## License 71 | 72 | This npm package is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the [Developer Certificate of Origin, Version 1.1 (DCO)](https://developercertificate.org/) and the [Apache Software License, Version 2](http://www.apache.org/licenses/LICENSE-2.0.txt). 73 | 74 | [Apache Software License (ASL) FAQ](http://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN) 75 | -------------------------------------------------------------------------------- /pws-current.html: -------------------------------------------------------------------------------- 1 | 15 | 16 | 34 | 41 | 42 | 61 | 62 | 63 | 92 | 93 | 119 | -------------------------------------------------------------------------------- /twc-health.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 72 | 73 | 108 | -------------------------------------------------------------------------------- /pws-historical.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | function weatherPWSHistoricalDataNode( n ) { 3 | RED.nodes.createNode(this,n ); 4 | var node = this; 5 | var StationId = n.stationid; 6 | var units = n.units; 7 | var precision = n.precision; 8 | var name = n.name; 9 | var range = n.range; 10 | var date = n.date; 11 | var pwsConfigNode; 12 | var apiKey; 13 | const axios = require('axios'); 14 | 15 | // Retrieve the config node 16 | pwsConfigNode = RED.nodes.getNode(n.apikey); 17 | apiKey = pwsConfigNode.credentials.apikey; 18 | 19 | if (!units) { 20 | units = 'm'; 21 | } 22 | if (!precision) { 23 | precision = 'i'; 24 | } 25 | 26 | function datevalidation( v ) { 27 | var datestr =""+v // cast from number to string 28 | if (!/^\d{8}/.test(datestr)) { return false; } 29 | var year = datestr.substring(0,4); 30 | var month = datestr.substring(4,6); 31 | var day = datestr.substring(6,8); 32 | // Date.parse will return NaN if this isn't a valid date 33 | var time = Date.parse(year+"-"+month+"-"+day); 34 | return !isNaN(time); 35 | } 36 | 37 | function dateparser( msg ) { 38 | // Date validation and reformatting 39 | var teststr; 40 | if( typeof msg.twcparams.date !== 'undefined' ) { 41 | // The pws date to query was passed in as a msg key value pair 42 | // override any value specified in the edit panel 43 | var time = new Date(msg.twcparams.date); 44 | if( !isNaN(time) ) { 45 | // msg.date contains a timestamp 46 | // Grab the date 2020-01-01 from the ISO format 47 | teststr = time.toISOString().substr(0,10); 48 | } else { 49 | // cast from number to string in case it was a number 50 | teststr = ""+msg.twcparams.date; 51 | } 52 | } else { 53 | // Use the date provided in the edit panel 54 | teststr = date ; 55 | } 56 | var datestr; 57 | // reformat 2020-01-01 or 2020/01/01 to 20200101 required yyyymmdd format 58 | datestr = teststr.replace( /(\d{4})[\-/](\d{1,2})[\-/](\d{1,2})/, '$1$2$3' ); 59 | 60 | if( !datestr || !datevalidation(datestr) ) { 61 | msg.payload = "Error: No or incorrect date format provided. yyyymmdd required."; 62 | node.send(msg); 63 | return null; 64 | } 65 | return datestr; 66 | } 67 | 68 | node.on('input', function (msg) { 69 | msg.twcparams = msg.twcparams || {}; 70 | var datestr = dateparser( msg ); 71 | if( !datestr ) { 72 | return; 73 | } 74 | msg.twcparams.date = datestr ; 75 | 76 | if( typeof msg.twcparams.range == 'undefined' ) { 77 | msg.twcparams.range = range; 78 | } 79 | 80 | if( typeof msg.twcparams.units == 'undefined' ) { 81 | msg.twcparams.units = units; // take the default or the node setting 82 | } else if( "emhEMH".indexOf(msg.twcparams.units) >= 0 ) { 83 | // passed in param is valid, override default or node setting 84 | msg.twcparams.units = msg.twcparams.units.toLowerCase(); 85 | } else { 86 | msg.twcparams.units = units; // take the default or the node setting 87 | } 88 | 89 | if( typeof msg.twcparams.precision == 'undefined' ) { 90 | msg.twcparams.precision = precision; 91 | } else if( "idID".indexOf(msg.twcparams.precision) >= 0 ) { 92 | // passed in param is valid, override default or node setting 93 | msg.twcparams.precision = msg.twcparams.precision.toLowerCase(); 94 | } else { 95 | msg.twcparams.precision = precision; 96 | } 97 | 98 | if ( msg.twcparams.precision == 'd') { 99 | var numericPrecision = '&numericPrecision=decimal'; 100 | } else { 101 | var numericPrecision = ''; 102 | } 103 | 104 | var curStationId = StationId; 105 | if( typeof msg.twcparams.StationID != 'undefined' ) { 106 | curStationId = msg.twcparams.StationID.toUpperCase(); 107 | } 108 | if( !curStationId ) { 109 | // No StationID is set. Abort with error 110 | msg.payload = "Error: No StationID provided."; 111 | node.send(msg); 112 | } else { 113 | msg.twcparams.StationID = curStationId; 114 | (async () => { 115 | try { 116 | const response = await axios.get('https://api.weather.com/v2/pws/history/'+ msg.twcparams.range + '?stationId='+ curStationId +'&format=json&date='+datestr+'&units='+msg.twcparams.units+'&apiKey='+apiKey+numericPrecision); 117 | //console.log(response.data) 118 | msg.payload = response.data; 119 | node.send(msg); 120 | } catch (error) { 121 | //console.log(error.response.data); 122 | //console.log(error.response.status); 123 | if (error.response) { 124 | // The request was made and the server responded with a status code 125 | // that falls out of the range of 2xx 126 | console.log(error.response.data); 127 | console.log(error.response.status); 128 | console.log(error.response.headers); 129 | node.warn(error.response.data); 130 | } else if (error.request) { 131 | // The request was made but no response was received 132 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of 133 | // http.ClientRequest in node.js 134 | console.log(error.request); 135 | } else { 136 | // Something happened in setting up the request that triggered an Error 137 | console.log('Error', error.message); 138 | } 139 | console.log(error.config); 140 | console.log(error.toJSON()); 141 | node.send(msg); 142 | } 143 | })(); 144 | } 145 | }); 146 | } 147 | RED.nodes.registerType("pws-historical",weatherPWSHistoricalDataNode); 148 | } 149 | -------------------------------------------------------------------------------- /twc-core.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 70 | 71 | 107 | -------------------------------------------------------------------------------- /npm-shrinkwrap.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-red-contrib-twc-weather", 3 | "version": "0.6.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "node-red-contrib-twc-weather", 9 | "version": "0.6.0", 10 | "license": "Apache-2.0", 11 | "dependencies": { 12 | "axios": ">=0.27.2" 13 | } 14 | }, 15 | "node_modules/asynckit": { 16 | "version": "0.4.0", 17 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 18 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" 19 | }, 20 | "node_modules/axios": { 21 | "version": "0.27.2", 22 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", 23 | "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", 24 | "dependencies": { 25 | "follow-redirects": "^1.14.9", 26 | "form-data": "^4.0.0" 27 | } 28 | }, 29 | "node_modules/combined-stream": { 30 | "version": "1.0.8", 31 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 32 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 33 | "dependencies": { 34 | "delayed-stream": "~1.0.0" 35 | }, 36 | "engines": { 37 | "node": ">= 0.8" 38 | } 39 | }, 40 | "node_modules/delayed-stream": { 41 | "version": "1.0.0", 42 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 43 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", 44 | "engines": { 45 | "node": ">=0.4.0" 46 | } 47 | }, 48 | "node_modules/follow-redirects": { 49 | "version": "1.14.9", 50 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", 51 | "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", 52 | "funding": [ 53 | { 54 | "type": "individual", 55 | "url": "https://github.com/sponsors/RubenVerborgh" 56 | } 57 | ], 58 | "engines": { 59 | "node": ">=4.0" 60 | }, 61 | "peerDependenciesMeta": { 62 | "debug": { 63 | "optional": true 64 | } 65 | } 66 | }, 67 | "node_modules/form-data": { 68 | "version": "4.0.0", 69 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 70 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 71 | "dependencies": { 72 | "asynckit": "^0.4.0", 73 | "combined-stream": "^1.0.8", 74 | "mime-types": "^2.1.12" 75 | }, 76 | "engines": { 77 | "node": ">= 6" 78 | } 79 | }, 80 | "node_modules/mime-db": { 81 | "version": "1.52.0", 82 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 83 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", 84 | "engines": { 85 | "node": ">= 0.6" 86 | } 87 | }, 88 | "node_modules/mime-types": { 89 | "version": "2.1.35", 90 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 91 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 92 | "dependencies": { 93 | "mime-db": "1.52.0" 94 | }, 95 | "engines": { 96 | "node": ">= 0.6" 97 | } 98 | } 99 | }, 100 | "dependencies": { 101 | "asynckit": { 102 | "version": "0.4.0", 103 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 104 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" 105 | }, 106 | "axios": { 107 | "version": "0.27.2", 108 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", 109 | "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", 110 | "requires": { 111 | "follow-redirects": "^1.14.9", 112 | "form-data": "^4.0.0" 113 | } 114 | }, 115 | "combined-stream": { 116 | "version": "1.0.8", 117 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 118 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 119 | "requires": { 120 | "delayed-stream": "~1.0.0" 121 | } 122 | }, 123 | "delayed-stream": { 124 | "version": "1.0.0", 125 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 126 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 127 | }, 128 | "follow-redirects": { 129 | "version": "1.14.9", 130 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", 131 | "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==" 132 | }, 133 | "form-data": { 134 | "version": "4.0.0", 135 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 136 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 137 | "requires": { 138 | "asynckit": "^0.4.0", 139 | "combined-stream": "^1.0.8", 140 | "mime-types": "^2.1.12" 141 | } 142 | }, 143 | "mime-db": { 144 | "version": "1.52.0", 145 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 146 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" 147 | }, 148 | "mime-types": { 149 | "version": "2.1.35", 150 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 151 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 152 | "requires": { 153 | "mime-db": "1.52.0" 154 | } 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /pws-recent.html: -------------------------------------------------------------------------------- 1 | 20 | 21 | 22 | 51 | 52 | 75 | 76 | //// PWS 7 Day Hourly 77 | 96 | 97 | 98 | 127 | 128 | 151 | 152 | //// PWS 1 Day Rapid 153 | 172 | 173 | 174 | 203 | 204 | 227 | -------------------------------------------------------------------------------- /pws-recent.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | function weatherPWS7DaySummaryNode( n ) { 3 | RED.nodes.createNode(this,n ); 4 | var node = this; 5 | var StationId = n.stationid; 6 | var units = n.units; 7 | var precision = n.precision; 8 | var name = n.name; 9 | var pwsConfigNode; 10 | var apiKey; 11 | const axios = require('axios'); 12 | 13 | // Retrieve the config node 14 | pwsConfigNode = RED.nodes.getNode(n.apikey); 15 | apiKey = pwsConfigNode.credentials.apikey; 16 | 17 | if (!units) { 18 | units = 'm'; 19 | } 20 | if (!precision) { 21 | precision = 'i'; 22 | } 23 | 24 | node.on('input', function (msg) { 25 | msg.twcparams = msg.twcparams || {}; 26 | 27 | if( typeof msg.twcparams.units == 'undefined' ) { 28 | msg.twcparams.units = units; // take the default or the node setting 29 | } else if( "emhEMH".indexOf(msg.twcparams.units) >= 0 ) { 30 | // passed in param is valid, override default or node setting 31 | msg.twcparams.units = msg.twcparams.units.toLowerCase(); 32 | } else { 33 | msg.twcparams.units = units; // take the default or the node setting 34 | } 35 | 36 | if( typeof msg.twcparams.precision == 'undefined' ) { 37 | msg.twcparams.precision = precision; 38 | } else if( "idID".indexOf(msg.twcparams.precision) >= 0 ) { 39 | // passed in param is valid, override default or node setting 40 | msg.twcparams.precision = msg.twcparams.precision.toLowerCase(); 41 | } else { 42 | msg.twcparams.precision = precision; 43 | } 44 | 45 | if ( msg.twcparams.precision == 'd') { 46 | var numericPrecision = '&numericPrecision=decimal'; 47 | } else { 48 | var numericPrecision = ''; 49 | } 50 | 51 | var curStationId = StationId; 52 | if( typeof msg.twcparams.StationID != 'undefined' ) { 53 | curStationId = msg.twcparams.StationID.toUpperCase(); 54 | } 55 | if( !curStationId ) { 56 | // No StationID is set. Abort with error 57 | msg.payload = "Error: No StationID provided."; 58 | node.send(msg); 59 | } else { 60 | msg.twcparams.StationID = curStationId; 61 | 62 | (async () => { 63 | try { 64 | const response = await axios.get('https://api.weather.com/v2/pws/dailysummary/7day?stationId=' + msg.twcparams.StationID +'&format=json&units='+msg.twcparams.units+'&apiKey='+apiKey+numericPrecision); 65 | //console.log(response.data) 66 | msg.payload = response.data; 67 | node.send(msg); 68 | } catch (error) { 69 | //console.log(error.response.data); 70 | //console.log(error.response.status); 71 | if (error.response) { 72 | // The request was made and the server responded with a status code 73 | // that falls out of the range of 2xx 74 | console.log(error.response.data); 75 | console.log(error.response.status); 76 | console.log(error.response.headers); 77 | node.warn(error.response.data); 78 | } else if (error.request) { 79 | // The request was made but no response was received 80 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of 81 | // http.ClientRequest in node.js 82 | console.log(error.request); 83 | } else { 84 | // Something happened in setting up the request that triggered an Error 85 | console.log('Error', error.message); 86 | } 87 | console.log(error.config); 88 | console.log(error.toJSON()); 89 | node.send(msg); 90 | } 91 | })(); 92 | } 93 | }); 94 | } 95 | RED.nodes.registerType("pws-7day-summary",weatherPWS7DaySummaryNode); 96 | 97 | /// 98 | function weatherPWS7DayHourlyNode( n ) { 99 | RED.nodes.createNode(this,n ); 100 | var node = this; 101 | var StationId = n.stationid; 102 | var units = n.units; 103 | var precision = n.precision; 104 | var name = n.name; 105 | var pwsConfigNode; 106 | var apiKey; 107 | const axios = require('axios'); 108 | 109 | // Retrieve the config node 110 | pwsConfigNode = RED.nodes.getNode(n.apikey); 111 | apiKey = pwsConfigNode.credentials.apikey; 112 | 113 | if (!units) { 114 | units = 'm'; 115 | } 116 | if (!precision) { 117 | precision = 'i'; 118 | } 119 | 120 | node.on('input', function (msg) { 121 | msg.twcparams = msg.twcparams || {}; 122 | 123 | if( typeof msg.twcparams.units == 'undefined' ) { 124 | msg.twcparams.units = units; // take the default or the node setting 125 | } else if( "emhEMH".indexOf(msg.twcparams.units) >= 0 ) { 126 | // passed in param is valid, override default or node setting 127 | msg.twcparams.units = msg.twcparams.units.toLowerCase(); 128 | } else { 129 | msg.twcparams.units = units; // take the default or the node setting 130 | } 131 | 132 | if( typeof msg.twcparams.precision == 'undefined' ) { 133 | msg.twcparams.precision = precision; 134 | } else if( "idID".indexOf(msg.twcparams.precision) >= 0 ) { 135 | // passed in param is valid, override default or node setting 136 | msg.twcparams.precision = msg.twcparams.precision.toLowerCase(); 137 | } else { 138 | msg.twcparams.precision = precision; 139 | } 140 | 141 | if ( msg.twcparams.precision == 'd') { 142 | var numericPrecision = '&numericPrecision=decimal'; 143 | } else { 144 | var numericPrecision = ''; 145 | } 146 | 147 | var curStationId = StationId; 148 | if( typeof msg.twcparams.StationID != 'undefined' ) { 149 | curStationId = msg.twcparams.StationID.toUpperCase(); 150 | } 151 | if( !curStationId ) { 152 | // No StationID is set. Abort with error 153 | msg.payload = "Error: No StationID provided."; 154 | node.send(msg); 155 | } else { 156 | msg.twcparams.StationID = curStationId; 157 | 158 | (async () => { 159 | try { 160 | const response = await axios.get('https://api.weather.com/v2/pws/observations/hourly/7day?stationId=' + msg.twcparams.StationID +'&format=json&units='+msg.twcparams.units+'&apiKey='+apiKey+numericPrecision); 161 | //console.log(response.data) 162 | msg.payload = response.data; 163 | node.send(msg); 164 | } catch (error) { 165 | //console.log(error.response.data); 166 | //console.log(error.response.status); 167 | if (error.response) { 168 | // The request was made and the server responded with a status code 169 | // that falls out of the range of 2xx 170 | console.log(error.response.data); 171 | console.log(error.response.status); 172 | console.log(error.response.headers); 173 | node.warn(error.response.data); 174 | } else if (error.request) { 175 | // The request was made but no response was received 176 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of 177 | // http.ClientRequest in node.js 178 | console.log(error.request); 179 | } else { 180 | // Something happened in setting up the request that triggered an Error 181 | console.log('Error', error.message); 182 | } 183 | console.log(error.config); 184 | console.log(error.toJSON()); 185 | node.send(msg); 186 | } 187 | })(); 188 | 189 | } 190 | }); 191 | } 192 | RED.nodes.registerType("pws-7day-hourly",weatherPWS7DayHourlyNode); 193 | 194 | /// 195 | function weatherPWS1DayRapidNode( n ) { 196 | RED.nodes.createNode(this,n ); 197 | var node = this; 198 | var StationId = n.stationid; 199 | var units = n.units; 200 | var precision = n.precision; 201 | var name = n.name; 202 | var pwsConfigNode; 203 | var apiKey; 204 | const axios = require('axios'); 205 | 206 | // Retrieve the config node 207 | pwsConfigNode = RED.nodes.getNode(n.apikey); 208 | apiKey = pwsConfigNode.credentials.apikey; 209 | 210 | if (!units) { 211 | units = 'm'; 212 | } 213 | if (!precision) { 214 | precision = 'i'; 215 | } 216 | 217 | node.on('input', function (msg) { 218 | msg.twcparams = msg.twcparams || {}; 219 | 220 | if( typeof msg.twcparams.units == 'undefined' ) { 221 | msg.twcparams.units = units; // take the default or the node setting 222 | } else if( "emhEMH".indexOf(msg.twcparams.units) >= 0 ) { 223 | // passed in param is valid, override default or node setting 224 | msg.twcparams.units = msg.twcparams.units.toLowerCase(); 225 | } else { 226 | msg.twcparams.units = units; // take the default or the node setting 227 | } 228 | 229 | if( typeof msg.twcparams.precision == 'undefined' ) { 230 | msg.twcparams.precision = precision; 231 | } else if( "idID".indexOf(msg.twcparams.precision) >= 0 ) { 232 | // passed in param is valid, override default or node setting 233 | msg.twcparams.precision = msg.twcparams.precision.toLowerCase(); 234 | } else { 235 | msg.twcparams.precision = precision; 236 | } 237 | 238 | if ( msg.twcparams.precision == 'd') { 239 | var numericPrecision = '&numericPrecision=decimal'; 240 | } else { 241 | var numericPrecision = ''; 242 | } 243 | 244 | var curStationId = StationId; 245 | if( typeof msg.twcparams.StationID != 'undefined' ) { 246 | curStationId = msg.twcparams.StationID.toUpperCase(); 247 | } 248 | if( !curStationId ) { 249 | // No StationID is set. Abort with error 250 | msg.payload = "Error: No StationID provided."; 251 | node.send(msg); 252 | } else { 253 | msg.twcparams.StationID = curStationId; 254 | 255 | (async () => { 256 | try { 257 | const response = await axios.get('https://api.weather.com/v2/pws/observations/all/1day?stationId=' + msg.twcparams.StationID +'&format=json&units='+msg.twcparams.units+'&apiKey='+apiKey+numericPrecision); 258 | //console.log(response.data) 259 | msg.payload = response.data; 260 | node.send(msg); 261 | } catch (error) { 262 | //console.log(error.response.data); 263 | //console.log(error.response.status); 264 | if (error.response) { 265 | // The request was made and the server responded with a status code 266 | // that falls out of the range of 2xx 267 | console.log(error.response.data); 268 | console.log(error.response.status); 269 | console.log(error.response.headers); 270 | node.warn(error.response.data); 271 | } else if (error.request) { 272 | // The request was made but no response was received 273 | // `error.request` is an instance of XMLHttpRequest in the browser and an instance of 274 | // http.ClientRequest in node.js 275 | console.log(error.request); 276 | } else { 277 | // Something happened in setting up the request that triggered an Error 278 | console.log('Error', error.message); 279 | } 280 | console.log(error.config); 281 | console.log(error.toJSON()); 282 | node.send(msg); 283 | } 284 | })(); 285 | } 286 | }); 287 | } 288 | RED.nodes.registerType("pws-1day-all",weatherPWS1DayRapidNode); 289 | } 290 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /examples/PWS-Examples.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "60afae7.f61045", 4 | "type": "tab", 5 | "label": "PWS Examples", 6 | "disabled": false, 7 | "info": "" 8 | }, 9 | { 10 | "id": "73501d9c.791594", 11 | "type": "inject", 12 | "z": "60afae7.f61045", 13 | "name": "Current PWS Observations", 14 | "topic": "", 15 | "payload": "true", 16 | "payloadType": "bool", 17 | "repeat": "", 18 | "crontab": "", 19 | "once": false, 20 | "onceDelay": 0.1, 21 | "x": 150, 22 | "y": 100, 23 | "wires": [ 24 | [ 25 | "33cd7447.122c6c" 26 | ] 27 | ] 28 | }, 29 | { 30 | "id": "937fc0b7.497", 31 | "type": "debug", 32 | "z": "60afae7.f61045", 33 | "name": "", 34 | "active": true, 35 | "tosidebar": true, 36 | "console": false, 37 | "tostatus": false, 38 | "complete": "payload", 39 | "targetType": "msg", 40 | "x": 810, 41 | "y": 100, 42 | "wires": [] 43 | }, 44 | { 45 | "id": "33cd7447.122c6c", 46 | "type": "pws-observations", 47 | "z": "60afae7.f61045", 48 | "name": "", 49 | "stationid": "KNJRIDGE9", 50 | "units": "m", 51 | "apikey": "", 52 | "x": 570, 53 | "y": 100, 54 | "wires": [ 55 | [ 56 | "937fc0b7.497" 57 | ] 58 | ] 59 | }, 60 | { 61 | "id": "af1d2f1a.8f7e4", 62 | "type": "pws-observations", 63 | "z": "60afae7.f61045", 64 | "name": "", 65 | "stationid": "KNJRIDGE9", 66 | "units": "m", 67 | "apikey": "", 68 | "x": 570, 69 | "y": 140, 70 | "wires": [ 71 | [ 72 | "599c27a0.c3109" 73 | ] 74 | ] 75 | }, 76 | { 77 | "id": "599c27a0.c3109", 78 | "type": "debug", 79 | "z": "60afae7.f61045", 80 | "name": "", 81 | "active": true, 82 | "tosidebar": true, 83 | "console": false, 84 | "tostatus": false, 85 | "complete": "true", 86 | "targetType": "full", 87 | "x": 790, 88 | "y": 140, 89 | "wires": [] 90 | }, 91 | { 92 | "id": "f1e7b71e.c678c8", 93 | "type": "pws-historical", 94 | "z": "60afae7.f61045", 95 | "name": "", 96 | "stationid": "KNJRIDGE9", 97 | "units": "e", 98 | "date": "", 99 | "range": "daily", 100 | "apikey": "", 101 | "x": 560, 102 | "y": 360, 103 | "wires": [ 104 | [ 105 | "516905b9.895464" 106 | ] 107 | ] 108 | }, 109 | { 110 | "id": "908313b6.1abcb", 111 | "type": "inject", 112 | "z": "60afae7.f61045", 113 | "name": "PWS Historical Averages by Date", 114 | "topic": "", 115 | "payload": "", 116 | "payloadType": "date", 117 | "repeat": "", 118 | "crontab": "", 119 | "once": false, 120 | "onceDelay": 0.1, 121 | "x": 250, 122 | "y": 360, 123 | "wires": [ 124 | [ 125 | "f1e7b71e.c678c8" 126 | ] 127 | ] 128 | }, 129 | { 130 | "id": "516905b9.895464", 131 | "type": "debug", 132 | "z": "60afae7.f61045", 133 | "name": "", 134 | "active": true, 135 | "tosidebar": true, 136 | "console": false, 137 | "tostatus": false, 138 | "complete": "true", 139 | "targetType": "full", 140 | "x": 790, 141 | "y": 360, 142 | "wires": [] 143 | }, 144 | { 145 | "id": "69912477.b08cd4", 146 | "type": "pws-historical", 147 | "z": "60afae7.f61045", 148 | "name": "", 149 | "stationid": "KNJRIDGE9", 150 | "units": "e", 151 | "date": "20191101", 152 | "range": "hourly", 153 | "apikey": "", 154 | "x": 560, 155 | "y": 400, 156 | "wires": [ 157 | [ 158 | "e6fb3331.8ff6a" 159 | ] 160 | ] 161 | }, 162 | { 163 | "id": "98cba034.a050b8", 164 | "type": "inject", 165 | "z": "60afae7.f61045", 166 | "name": "PWS Historical Hourly Averages by Date", 167 | "topic": "", 168 | "payload": "", 169 | "payloadType": "date", 170 | "repeat": "", 171 | "crontab": "", 172 | "once": false, 173 | "onceDelay": 0.1, 174 | "x": 220, 175 | "y": 400, 176 | "wires": [ 177 | [ 178 | "69912477.b08cd4" 179 | ] 180 | ] 181 | }, 182 | { 183 | "id": "e6fb3331.8ff6a", 184 | "type": "debug", 185 | "z": "60afae7.f61045", 186 | "name": "", 187 | "active": true, 188 | "tosidebar": true, 189 | "console": false, 190 | "tostatus": false, 191 | "complete": "false", 192 | "x": 810, 193 | "y": 400, 194 | "wires": [] 195 | }, 196 | { 197 | "id": "296bfa4e.dddfce", 198 | "type": "pws-historical", 199 | "z": "60afae7.f61045", 200 | "name": "", 201 | "stationid": "KNJRIDGE9", 202 | "units": "e", 203 | "date": "20191101", 204 | "range": "all", 205 | "apikey": "", 206 | "x": 560, 207 | "y": 440, 208 | "wires": [ 209 | [ 210 | "76e67514.bc11a4" 211 | ] 212 | ] 213 | }, 214 | { 215 | "id": "1c3c7b47.f47535", 216 | "type": "inject", 217 | "z": "60afae7.f61045", 218 | "name": "PWS Historical All Data by Date", 219 | "topic": "", 220 | "payload": "", 221 | "payloadType": "date", 222 | "repeat": "", 223 | "crontab": "", 224 | "once": false, 225 | "onceDelay": 0.1, 226 | "x": 250, 227 | "y": 440, 228 | "wires": [ 229 | [ 230 | "296bfa4e.dddfce" 231 | ] 232 | ] 233 | }, 234 | { 235 | "id": "76e67514.bc11a4", 236 | "type": "debug", 237 | "z": "60afae7.f61045", 238 | "name": "", 239 | "active": true, 240 | "tosidebar": true, 241 | "console": false, 242 | "tostatus": false, 243 | "complete": "false", 244 | "x": 810, 245 | "y": 440, 246 | "wires": [] 247 | }, 248 | { 249 | "id": "848d9977.07ee58", 250 | "type": "comment", 251 | "z": "60afae7.f61045", 252 | "name": "Query PWS Current Conditions / Observations for any Personal Weather Station", 253 | "info": "", 254 | "x": 320, 255 | "y": 60, 256 | "wires": [] 257 | }, 258 | { 259 | "id": "1797132e.1ef7ed", 260 | "type": "comment", 261 | "z": "60afae7.f61045", 262 | "name": "Query Historical Data from any Personal Weather Station", 263 | "info": "", 264 | "x": 250, 265 | "y": 280, 266 | "wires": [] 267 | }, 268 | { 269 | "id": "8a2848a7.6ae26", 270 | "type": "inject", 271 | "z": "60afae7.f61045", 272 | "name": "Current PWS Observations elsewhere", 273 | "topic": "", 274 | "payload": "true", 275 | "payloadType": "bool", 276 | "repeat": "", 277 | "crontab": "", 278 | "once": false, 279 | "onceDelay": 0.1, 280 | "x": 190, 281 | "y": 140, 282 | "wires": [ 283 | [ 284 | "af1d2f1a.8f7e4" 285 | ] 286 | ] 287 | }, 288 | { 289 | "id": "c7827503.8fb508", 290 | "type": "pws-forecast", 291 | "z": "60afae7.f61045", 292 | "name": "", 293 | "units": "e", 294 | "locationtype": "postalKey", 295 | "location": "07450:US", 296 | "lang": "en-US", 297 | "apikey": "", 298 | "x": 560, 299 | "y": 560, 300 | "wires": [ 301 | [ 302 | "6d89de08.f0c248" 303 | ] 304 | ] 305 | }, 306 | { 307 | "id": "49e3776.bdaa108", 308 | "type": "inject", 309 | "z": "60afae7.f61045", 310 | "name": "5 Day Forecast by Postal Code", 311 | "topic": "", 312 | "payload": "", 313 | "payloadType": "date", 314 | "repeat": "", 315 | "crontab": "", 316 | "once": false, 317 | "onceDelay": 0.1, 318 | "x": 250, 319 | "y": 560, 320 | "wires": [ 321 | [ 322 | "c7827503.8fb508" 323 | ] 324 | ] 325 | }, 326 | { 327 | "id": "6d89de08.f0c248", 328 | "type": "debug", 329 | "z": "60afae7.f61045", 330 | "name": "", 331 | "active": true, 332 | "tosidebar": true, 333 | "console": false, 334 | "tostatus": false, 335 | "complete": "payload", 336 | "targetType": "msg", 337 | "x": 810, 338 | "y": 560, 339 | "wires": [] 340 | }, 341 | { 342 | "id": "17903445.5b7ab4", 343 | "type": "comment", 344 | "z": "60afae7.f61045", 345 | "name": "5 Day Forecast", 346 | "info": "", 347 | "x": 120, 348 | "y": 520, 349 | "wires": [] 350 | }, 351 | { 352 | "id": "392330de.7153c", 353 | "type": "pws-forecast", 354 | "z": "60afae7.f61045", 355 | "name": "", 356 | "units": "e", 357 | "locationtype": "geocode", 358 | "location": "40.98,-74.1", 359 | "lang": "en-US", 360 | "apikey": "", 361 | "x": 560, 362 | "y": 600, 363 | "wires": [ 364 | [ 365 | "7b81d355.a0b26c" 366 | ] 367 | ] 368 | }, 369 | { 370 | "id": "432be774.12d0b", 371 | "type": "inject", 372 | "z": "60afae7.f61045", 373 | "name": "5 Day Forecast by GeoCode", 374 | "topic": "", 375 | "payload": "", 376 | "payloadType": "date", 377 | "repeat": "", 378 | "crontab": "", 379 | "once": false, 380 | "onceDelay": 0.1, 381 | "x": 260, 382 | "y": 600, 383 | "wires": [ 384 | [ 385 | "392330de.7153c" 386 | ] 387 | ] 388 | }, 389 | { 390 | "id": "7b81d355.a0b26c", 391 | "type": "debug", 392 | "z": "60afae7.f61045", 393 | "name": "", 394 | "active": true, 395 | "tosidebar": true, 396 | "console": false, 397 | "tostatus": false, 398 | "complete": "false", 399 | "x": 810, 400 | "y": 600, 401 | "wires": [] 402 | }, 403 | { 404 | "id": "75d8cd72.a54024", 405 | "type": "pws-forecast", 406 | "z": "60afae7.f61045", 407 | "name": "", 408 | "units": "e", 409 | "locationtype": "iataCode", 410 | "location": "EWR", 411 | "lang": "en-US", 412 | "apikey": "", 413 | "x": 560, 414 | "y": 640, 415 | "wires": [ 416 | [ 417 | "87899939.c0e55" 418 | ] 419 | ] 420 | }, 421 | { 422 | "id": "62b30898.0cfef", 423 | "type": "inject", 424 | "z": "60afae7.f61045", 425 | "name": "5 Day Forecast by IATA Airport Code", 426 | "topic": "", 427 | "payload": "", 428 | "payloadType": "date", 429 | "repeat": "", 430 | "crontab": "", 431 | "once": false, 432 | "onceDelay": 0.1, 433 | "x": 240, 434 | "y": 640, 435 | "wires": [ 436 | [ 437 | "75d8cd72.a54024" 438 | ] 439 | ] 440 | }, 441 | { 442 | "id": "87899939.c0e55", 443 | "type": "debug", 444 | "z": "60afae7.f61045", 445 | "name": "", 446 | "active": true, 447 | "tosidebar": true, 448 | "console": false, 449 | "tostatus": false, 450 | "complete": "false", 451 | "x": 810, 452 | "y": 640, 453 | "wires": [] 454 | }, 455 | { 456 | "id": "e82cab41.432088", 457 | "type": "pws-forecast", 458 | "z": "60afae7.f61045", 459 | "name": "", 460 | "units": "e", 461 | "locationtype": "icaoCode", 462 | "location": "KEWR", 463 | "lang": "en-US", 464 | "apikey": "", 465 | "x": 560, 466 | "y": 680, 467 | "wires": [ 468 | [ 469 | "8cba0c9a.e01db8" 470 | ] 471 | ] 472 | }, 473 | { 474 | "id": "12816772.4e1731", 475 | "type": "inject", 476 | "z": "60afae7.f61045", 477 | "name": "5 Day Forecast by ICAO Airport Code", 478 | "topic": "", 479 | "payload": "", 480 | "payloadType": "date", 481 | "repeat": "", 482 | "crontab": "", 483 | "once": false, 484 | "onceDelay": 0.1, 485 | "x": 230, 486 | "y": 680, 487 | "wires": [ 488 | [ 489 | "e82cab41.432088" 490 | ] 491 | ] 492 | }, 493 | { 494 | "id": "8cba0c9a.e01db8", 495 | "type": "debug", 496 | "z": "60afae7.f61045", 497 | "name": "", 498 | "active": true, 499 | "tosidebar": true, 500 | "console": false, 501 | "tostatus": false, 502 | "complete": "false", 503 | "x": 810, 504 | "y": 680, 505 | "wires": [] 506 | }, 507 | { 508 | "id": "bf93dbe9.883de", 509 | "type": "pws-forecast", 510 | "z": "60afae7.f61045", 511 | "name": "", 512 | "units": "e", 513 | "locationtype": "placeid", 514 | "location": "327145917e06d09373dd2760425a88622a62d248fd97550eb4883737d8d1173b", 515 | "lang": "en-US", 516 | "apikey": "", 517 | "x": 560, 518 | "y": 720, 519 | "wires": [ 520 | [ 521 | "b444366a.92aad8" 522 | ] 523 | ] 524 | }, 525 | { 526 | "id": "66c30b69.feddb4", 527 | "type": "inject", 528 | "z": "60afae7.f61045", 529 | "name": "5 Day Forecast by Postal Code", 530 | "topic": "", 531 | "payload": "", 532 | "payloadType": "date", 533 | "repeat": "", 534 | "crontab": "", 535 | "once": false, 536 | "onceDelay": 0.1, 537 | "x": 250, 538 | "y": 720, 539 | "wires": [ 540 | [ 541 | "bf93dbe9.883de" 542 | ] 543 | ] 544 | }, 545 | { 546 | "id": "b444366a.92aad8", 547 | "type": "debug", 548 | "z": "60afae7.f61045", 549 | "name": "", 550 | "active": true, 551 | "tosidebar": true, 552 | "console": false, 553 | "tostatus": false, 554 | "complete": "true", 555 | "targetType": "full", 556 | "x": 790, 557 | "y": 720, 558 | "wires": [] 559 | }, 560 | { 561 | "id": "cc26f90.d84b688", 562 | "type": "comment", 563 | "z": "60afae7.f61045", 564 | "name": "Recent PWS Observations", 565 | "info": "", 566 | "x": 170, 567 | "y": 840, 568 | "wires": [] 569 | }, 570 | { 571 | "id": "3f281a15.40c126", 572 | "type": "inject", 573 | "z": "60afae7.f61045", 574 | "name": "7 Day PWS Daily Summary", 575 | "topic": "", 576 | "payload": "", 577 | "payloadType": "date", 578 | "repeat": "", 579 | "crontab": "", 580 | "once": false, 581 | "onceDelay": 0.1, 582 | "x": 260, 583 | "y": 880, 584 | "wires": [ 585 | [ 586 | "6b62255f.7dd2ac" 587 | ] 588 | ] 589 | }, 590 | { 591 | "id": "6b62255f.7dd2ac", 592 | "type": "pws-7day-summary", 593 | "z": "60afae7.f61045", 594 | "name": "", 595 | "stationid": "KNJRIDGE9", 596 | "units": "e", 597 | "apikey": "", 598 | "x": 580, 599 | "y": 880, 600 | "wires": [ 601 | [ 602 | "44b51394.d3d324" 603 | ] 604 | ] 605 | }, 606 | { 607 | "id": "44b51394.d3d324", 608 | "type": "debug", 609 | "z": "60afae7.f61045", 610 | "name": "", 611 | "active": true, 612 | "tosidebar": true, 613 | "console": false, 614 | "tostatus": false, 615 | "complete": "false", 616 | "x": 810, 617 | "y": 880, 618 | "wires": [] 619 | }, 620 | { 621 | "id": "293a0680.115bea", 622 | "type": "pws-7day-hourly", 623 | "z": "60afae7.f61045", 624 | "name": "", 625 | "stationid": "KNJRIDGE9", 626 | "units": "e", 627 | "apikey": "", 628 | "x": 570, 629 | "y": 920, 630 | "wires": [ 631 | [ 632 | "6fec8552.3eda0c" 633 | ] 634 | ] 635 | }, 636 | { 637 | "id": "d979058f.d75fd8", 638 | "type": "inject", 639 | "z": "60afae7.f61045", 640 | "name": "7 Day PWS Hourly Summary", 641 | "topic": "", 642 | "payload": "", 643 | "payloadType": "date", 644 | "repeat": "", 645 | "crontab": "", 646 | "once": false, 647 | "onceDelay": 0.1, 648 | "x": 260, 649 | "y": 920, 650 | "wires": [ 651 | [ 652 | "293a0680.115bea" 653 | ] 654 | ] 655 | }, 656 | { 657 | "id": "6fec8552.3eda0c", 658 | "type": "debug", 659 | "z": "60afae7.f61045", 660 | "name": "", 661 | "active": true, 662 | "tosidebar": true, 663 | "console": false, 664 | "tostatus": false, 665 | "complete": "false", 666 | "x": 810, 667 | "y": 920, 668 | "wires": [] 669 | }, 670 | { 671 | "id": "f45a1e7d.a0286", 672 | "type": "pws-1day-all", 673 | "z": "60afae7.f61045", 674 | "name": "", 675 | "stationid": "KNJRIDGE9", 676 | "units": "e", 677 | "apikey": "", 678 | "x": 560, 679 | "y": 960, 680 | "wires": [ 681 | [ 682 | "1df48582.6949f2" 683 | ] 684 | ] 685 | }, 686 | { 687 | "id": "1df48582.6949f2", 688 | "type": "debug", 689 | "z": "60afae7.f61045", 690 | "name": "", 691 | "active": true, 692 | "tosidebar": true, 693 | "console": false, 694 | "tostatus": false, 695 | "complete": "false", 696 | "x": 810, 697 | "y": 960, 698 | "wires": [] 699 | }, 700 | { 701 | "id": "cc71523b.ebb288", 702 | "type": "inject", 703 | "z": "60afae7.f61045", 704 | "name": "1 Day All PWS Records", 705 | "topic": "", 706 | "payload": "", 707 | "payloadType": "date", 708 | "repeat": "", 709 | "crontab": "", 710 | "once": false, 711 | "onceDelay": 0.1, 712 | "x": 280, 713 | "y": 960, 714 | "wires": [ 715 | [ 716 | "f45a1e7d.a0286" 717 | ] 718 | ] 719 | }, 720 | { 721 | "id": "5875d07f.015118", 722 | "type": "change", 723 | "z": "60afae7.f61045", 724 | "name": "Inject / test params", 725 | "rules": [ 726 | { 727 | "t": "set", 728 | "p": "twcparams", 729 | "pt": "msg", 730 | "to": "{}", 731 | "tot": "json" 732 | }, 733 | { 734 | "t": "set", 735 | "p": "twcparams.StationID", 736 | "pt": "msg", 737 | "to": "KNJRIDGE9", 738 | "tot": "str" 739 | }, 740 | { 741 | "t": "set", 742 | "p": "date", 743 | "pt": "msg", 744 | "to": "futz", 745 | "tot": "str" 746 | }, 747 | { 748 | "t": "set", 749 | "p": "twcparams", 750 | "pt": "msg", 751 | "to": "{}", 752 | "tot": "json" 753 | }, 754 | { 755 | "t": "set", 756 | "p": "twcparams.date", 757 | "pt": "msg", 758 | "to": "1579560576859", 759 | "tot": "num" 760 | }, 761 | { 762 | "t": "set", 763 | "p": "twcparams.date", 764 | "pt": "msg", 765 | "to": "payload", 766 | "tot": "msg" 767 | }, 768 | { 769 | "t": "set", 770 | "p": "twcparams.date", 771 | "pt": "msg", 772 | "to": "2020/01/20", 773 | "tot": "str" 774 | }, 775 | { 776 | "t": "set", 777 | "p": "twcparams.date", 778 | "pt": "msg", 779 | "to": "2020-01-19", 780 | "tot": "str" 781 | }, 782 | { 783 | "t": "set", 784 | "p": "twcparams.payload", 785 | "pt": "msg", 786 | "to": "20200118", 787 | "tot": "str" 788 | } 789 | ], 790 | "action": "", 791 | "property": "", 792 | "from": "", 793 | "to": "", 794 | "reg": false, 795 | "x": 290, 796 | "y": 320, 797 | "wires": [ 798 | [ 799 | "f1e7b71e.c678c8" 800 | ] 801 | ] 802 | }, 803 | { 804 | "id": "870c30f7.a5d8f8", 805 | "type": "inject", 806 | "z": "60afae7.f61045", 807 | "name": "", 808 | "topic": "", 809 | "payload": "", 810 | "payloadType": "date", 811 | "repeat": "", 812 | "crontab": "", 813 | "once": false, 814 | "onceDelay": 0.1, 815 | "x": 120, 816 | "y": 320, 817 | "wires": [ 818 | [ 819 | "5875d07f.015118" 820 | ] 821 | ] 822 | }, 823 | { 824 | "id": "afd14094.616318", 825 | "type": "inject", 826 | "z": "60afae7.f61045", 827 | "name": "Test", 828 | "topic": "", 829 | "payload": "true", 830 | "payloadType": "bool", 831 | "repeat": "", 832 | "crontab": "", 833 | "once": false, 834 | "onceDelay": 0.1, 835 | "x": 90, 836 | "y": 180, 837 | "wires": [ 838 | [ 839 | "a0f90d1c.bd05" 840 | ] 841 | ] 842 | }, 843 | { 844 | "id": "a0f90d1c.bd05", 845 | "type": "change", 846 | "z": "60afae7.f61045", 847 | "name": "set msg.twcparams input vars", 848 | "rules": [ 849 | { 850 | "t": "set", 851 | "p": "twcparams", 852 | "pt": "msg", 853 | "to": "{\"StationID\":\"KNJRIDGE9\",\"units\":\"E\"}", 854 | "tot": "json" 855 | }, 856 | { 857 | "t": "set", 858 | "p": "twcparams.units", 859 | "pt": "msg", 860 | "to": "e", 861 | "tot": "str" 862 | }, 863 | { 864 | "t": "set", 865 | "p": "twcparams.StationID", 866 | "pt": "msg", 867 | "to": "KNJRIDGE9", 868 | "tot": "str" 869 | }, 870 | { 871 | "t": "set", 872 | "p": "twcparams.location", 873 | "pt": "msg", 874 | "to": "EWR", 875 | "tot": "str" 876 | }, 877 | { 878 | "t": "set", 879 | "p": "twcparams.locationtype", 880 | "pt": "msg", 881 | "to": "iataCode", 882 | "tot": "str" 883 | } 884 | ], 885 | "action": "", 886 | "property": "", 887 | "from": "", 888 | "to": "", 889 | "reg": false, 890 | "x": 310, 891 | "y": 180, 892 | "wires": [ 893 | [ 894 | "af1d2f1a.8f7e4", 895 | "9e126936.ee05" 896 | ] 897 | ] 898 | }, 899 | { 900 | "id": "9e126936.ee05", 901 | "type": "debug", 902 | "z": "60afae7.f61045", 903 | "name": "", 904 | "active": true, 905 | "tosidebar": true, 906 | "console": false, 907 | "tostatus": false, 908 | "complete": "twcparams", 909 | "targetType": "msg", 910 | "x": 820, 911 | "y": 180, 912 | "wires": [] 913 | }, 914 | { 915 | "id": "19b4b5.0071034c", 916 | "type": "change", 917 | "z": "60afae7.f61045", 918 | "name": "set msg.twcparams input vars", 919 | "rules": [ 920 | { 921 | "t": "set", 922 | "p": "twcparams", 923 | "pt": "msg", 924 | "to": "{\"StationID\":\"KNJRIDGE9\",\"units\":\"E\"}", 925 | "tot": "json" 926 | }, 927 | { 928 | "t": "set", 929 | "p": "twcparams.units", 930 | "pt": "msg", 931 | "to": "e", 932 | "tot": "str" 933 | }, 934 | { 935 | "t": "set", 936 | "p": "twcparams.StationID", 937 | "pt": "msg", 938 | "to": "KNJRIDGE9", 939 | "tot": "str" 940 | }, 941 | { 942 | "t": "set", 943 | "p": "twcparams.location", 944 | "pt": "msg", 945 | "to": "EWR", 946 | "tot": "str" 947 | }, 948 | { 949 | "t": "set", 950 | "p": "twcparams.locationtype", 951 | "pt": "msg", 952 | "to": "iataCode", 953 | "tot": "str" 954 | } 955 | ], 956 | "action": "", 957 | "property": "", 958 | "from": "", 959 | "to": "", 960 | "reg": false, 961 | "x": 310, 962 | "y": 760, 963 | "wires": [ 964 | [ 965 | "bf93dbe9.883de" 966 | ] 967 | ] 968 | }, 969 | { 970 | "id": "b9f838d0.e2d158", 971 | "type": "inject", 972 | "z": "60afae7.f61045", 973 | "name": "Test", 974 | "topic": "", 975 | "payload": "true", 976 | "payloadType": "bool", 977 | "repeat": "", 978 | "crontab": "", 979 | "once": false, 980 | "onceDelay": 0.1, 981 | "x": 90, 982 | "y": 760, 983 | "wires": [ 984 | [ 985 | "19b4b5.0071034c" 986 | ] 987 | ] 988 | }, 989 | { 990 | "id": "fbc7d77a.a48c08", 991 | "type": "comment", 992 | "z": "60afae7.f61045", 993 | "name": "TWC NowCast", 994 | "info": "", 995 | "x": 140, 996 | "y": 1020, 997 | "wires": [] 998 | }, 999 | { 1000 | "id": "c3ffdbe8.30d178", 1001 | "type": "twc-nowcast", 1002 | "z": "60afae7.f61045", 1003 | "name": "", 1004 | "units": "e", 1005 | "locationtype": "geocode", 1006 | "location": "40.98,-74.1", 1007 | "lang": "en-US", 1008 | "apikey": "", 1009 | "x": 560, 1010 | "y": 1060, 1011 | "wires": [ 1012 | [ 1013 | "1aa3f73b.6758f9" 1014 | ] 1015 | ] 1016 | }, 1017 | { 1018 | "id": "26b6548d.4f6d14", 1019 | "type": "twc-nowcast", 1020 | "z": "60afae7.f61045", 1021 | "name": "", 1022 | "units": "e", 1023 | "locationtype": "geocode", 1024 | "location": "1", 1025 | "lang": "en-US", 1026 | "apikey": "", 1027 | "x": 560, 1028 | "y": 1100, 1029 | "wires": [ 1030 | [ 1031 | "5be0ee64.95622" 1032 | ] 1033 | ] 1034 | }, 1035 | { 1036 | "id": "5eb4505a.0a19e", 1037 | "type": "change", 1038 | "z": "60afae7.f61045", 1039 | "name": "set msg.twcparams input vars", 1040 | "rules": [ 1041 | { 1042 | "t": "set", 1043 | "p": "twcparams.units", 1044 | "pt": "msg", 1045 | "to": "e", 1046 | "tot": "str" 1047 | }, 1048 | { 1049 | "t": "set", 1050 | "p": "twcparams.location", 1051 | "pt": "msg", 1052 | "to": "40.98,-74.1", 1053 | "tot": "str" 1054 | }, 1055 | { 1056 | "t": "set", 1057 | "p": "twcparams.locationtype", 1058 | "pt": "msg", 1059 | "to": "geocode", 1060 | "tot": "str" 1061 | } 1062 | ], 1063 | "action": "", 1064 | "property": "", 1065 | "from": "", 1066 | "to": "", 1067 | "reg": false, 1068 | "x": 310, 1069 | "y": 1100, 1070 | "wires": [ 1071 | [ 1072 | "26b6548d.4f6d14" 1073 | ] 1074 | ] 1075 | }, 1076 | { 1077 | "id": "f4b9b75a.3dc67", 1078 | "type": "inject", 1079 | "z": "60afae7.f61045", 1080 | "name": "Test", 1081 | "topic": "", 1082 | "payload": "true", 1083 | "payloadType": "bool", 1084 | "repeat": "", 1085 | "crontab": "", 1086 | "once": false, 1087 | "onceDelay": 0.1, 1088 | "x": 90, 1089 | "y": 1100, 1090 | "wires": [ 1091 | [ 1092 | "5eb4505a.0a19e" 1093 | ] 1094 | ] 1095 | }, 1096 | { 1097 | "id": "80bbfc91.cee928", 1098 | "type": "twc-nowcast", 1099 | "z": "60afae7.f61045", 1100 | "name": "", 1101 | "units": "m", 1102 | "locationtype": "postalKey", 1103 | "location": "07450:US", 1104 | "lang": "en-US", 1105 | "apikey": "", 1106 | "x": 560, 1107 | "y": 1140, 1108 | "wires": [ 1109 | [ 1110 | "1fa6af15.e23cd9" 1111 | ] 1112 | ] 1113 | }, 1114 | { 1115 | "id": "df751055.93314", 1116 | "type": "twc-nowcast", 1117 | "z": "60afae7.f61045", 1118 | "name": "", 1119 | "units": "e", 1120 | "locationtype": "postalKey", 1121 | "location": "0", 1122 | "lang": "en-US", 1123 | "apikey": "", 1124 | "x": 560, 1125 | "y": 1180, 1126 | "wires": [ 1127 | [ 1128 | "9310c61d.1946b8" 1129 | ] 1130 | ] 1131 | }, 1132 | { 1133 | "id": "192a73d3.39059c", 1134 | "type": "inject", 1135 | "z": "60afae7.f61045", 1136 | "name": "6 Hour Nowcast by GeoCode", 1137 | "topic": "", 1138 | "payload": "true", 1139 | "payloadType": "bool", 1140 | "repeat": "", 1141 | "crontab": "", 1142 | "once": false, 1143 | "onceDelay": 0.1, 1144 | "x": 260, 1145 | "y": 1060, 1146 | "wires": [ 1147 | [ 1148 | "c3ffdbe8.30d178" 1149 | ] 1150 | ] 1151 | }, 1152 | { 1153 | "id": "994c4860.ad4b18", 1154 | "type": "inject", 1155 | "z": "60afae7.f61045", 1156 | "name": "6 Hour Nowcast by Postal Code", 1157 | "topic": "", 1158 | "payload": "true", 1159 | "payloadType": "bool", 1160 | "repeat": "", 1161 | "crontab": "", 1162 | "once": false, 1163 | "onceDelay": 0.1, 1164 | "x": 250, 1165 | "y": 1140, 1166 | "wires": [ 1167 | [ 1168 | "80bbfc91.cee928" 1169 | ] 1170 | ] 1171 | }, 1172 | { 1173 | "id": "5ffb2617.162658", 1174 | "type": "change", 1175 | "z": "60afae7.f61045", 1176 | "name": "set msg.twcparams input vars", 1177 | "rules": [ 1178 | { 1179 | "t": "set", 1180 | "p": "twcparams.units", 1181 | "pt": "msg", 1182 | "to": "e", 1183 | "tot": "str" 1184 | }, 1185 | { 1186 | "t": "set", 1187 | "p": "twcparams.location", 1188 | "pt": "msg", 1189 | "to": "07450:US", 1190 | "tot": "str" 1191 | }, 1192 | { 1193 | "t": "set", 1194 | "p": "twcparams.locationtype", 1195 | "pt": "msg", 1196 | "to": "postalKey", 1197 | "tot": "str" 1198 | } 1199 | ], 1200 | "action": "", 1201 | "property": "", 1202 | "from": "", 1203 | "to": "", 1204 | "reg": false, 1205 | "x": 310, 1206 | "y": 1180, 1207 | "wires": [ 1208 | [ 1209 | "df751055.93314" 1210 | ] 1211 | ] 1212 | }, 1213 | { 1214 | "id": "236c9d05.c5aa22", 1215 | "type": "inject", 1216 | "z": "60afae7.f61045", 1217 | "name": "Test", 1218 | "topic": "", 1219 | "payload": "true", 1220 | "payloadType": "bool", 1221 | "repeat": "", 1222 | "crontab": "", 1223 | "once": false, 1224 | "onceDelay": 0.1, 1225 | "x": 90, 1226 | "y": 1180, 1227 | "wires": [ 1228 | [ 1229 | "5ffb2617.162658" 1230 | ] 1231 | ] 1232 | }, 1233 | { 1234 | "id": "1aa3f73b.6758f9", 1235 | "type": "debug", 1236 | "z": "60afae7.f61045", 1237 | "name": "", 1238 | "active": true, 1239 | "tosidebar": true, 1240 | "console": false, 1241 | "tostatus": false, 1242 | "complete": "false", 1243 | "x": 810, 1244 | "y": 1060, 1245 | "wires": [] 1246 | }, 1247 | { 1248 | "id": "5be0ee64.95622", 1249 | "type": "debug", 1250 | "z": "60afae7.f61045", 1251 | "name": "", 1252 | "active": true, 1253 | "tosidebar": true, 1254 | "console": false, 1255 | "tostatus": false, 1256 | "complete": "false", 1257 | "x": 810, 1258 | "y": 1100, 1259 | "wires": [] 1260 | }, 1261 | { 1262 | "id": "1fa6af15.e23cd9", 1263 | "type": "debug", 1264 | "z": "60afae7.f61045", 1265 | "name": "", 1266 | "active": true, 1267 | "tosidebar": true, 1268 | "console": false, 1269 | "tostatus": false, 1270 | "complete": "false", 1271 | "x": 810, 1272 | "y": 1140, 1273 | "wires": [] 1274 | }, 1275 | { 1276 | "id": "9310c61d.1946b8", 1277 | "type": "debug", 1278 | "z": "60afae7.f61045", 1279 | "name": "", 1280 | "active": true, 1281 | "tosidebar": true, 1282 | "console": false, 1283 | "tostatus": false, 1284 | "complete": "false", 1285 | "x": 810, 1286 | "y": 1180, 1287 | "wires": [] 1288 | } 1289 | ] 1290 | -------------------------------------------------------------------------------- /examples/PWS-Dashboard.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "282fafd4.df968", 4 | "type": "tab", 5 | "label": "PWS Dashboard", 6 | "disabled": false, 7 | "info": "" 8 | }, 9 | { 10 | "id": "d2d665ce.c48898", 11 | "type": "debug", 12 | "z": "282fafd4.df968", 13 | "name": "", 14 | "active": true, 15 | "tosidebar": true, 16 | "console": false, 17 | "tostatus": false, 18 | "complete": "payload", 19 | "targetType": "msg", 20 | "x": 810, 21 | "y": 100, 22 | "wires": [] 23 | }, 24 | { 25 | "id": "36df2040.dab0e8", 26 | "type": "pws-observations", 27 | "z": "282fafd4.df968", 28 | "name": "", 29 | "stationid": "", 30 | "units": "e", 31 | "apikey": "ba693fed.4c01f8", 32 | "x": 590, 33 | "y": 140, 34 | "wires": [ 35 | [ 36 | "d2d665ce.c48898", 37 | "b7babaaf.bb0448", 38 | "b3dc9bd1.1c29f" 39 | ] 40 | ] 41 | }, 42 | { 43 | "id": "384cef20.42b128", 44 | "type": "pws-historical", 45 | "z": "282fafd4.df968", 46 | "name": "", 47 | "stationid": "", 48 | "units": "e", 49 | "date": "", 50 | "range": "daily", 51 | "apikey": "ba693fed.4c01f8", 52 | "x": 520, 53 | "y": 540, 54 | "wires": [ 55 | [ 56 | "599bbba7.ab986c" 57 | ] 58 | ] 59 | }, 60 | { 61 | "id": "887582a4.04a18", 62 | "type": "debug", 63 | "z": "282fafd4.df968", 64 | "name": "", 65 | "active": true, 66 | "tosidebar": true, 67 | "console": false, 68 | "tostatus": false, 69 | "complete": "false", 70 | "x": 970, 71 | "y": 500, 72 | "wires": [] 73 | }, 74 | { 75 | "id": "36bc66ae.8b41fa", 76 | "type": "comment", 77 | "z": "282fafd4.df968", 78 | "name": "Query PWS Current Conditions / Observations for any Personal Weather Station", 79 | "info": "", 80 | "x": 320, 81 | "y": 60, 82 | "wires": [] 83 | }, 84 | { 85 | "id": "7c258cf.19a1ef4", 86 | "type": "comment", 87 | "z": "282fafd4.df968", 88 | "name": "Query Historical Data from PWS", 89 | "info": "", 90 | "x": 170, 91 | "y": 500, 92 | "wires": [] 93 | }, 94 | { 95 | "id": "27c10673.26a442", 96 | "type": "pws-forecast", 97 | "z": "282fafd4.df968", 98 | "name": "", 99 | "units": "e", 100 | "locationtype": "postalKey", 101 | "location": "07450:US", 102 | "lang": "en-US", 103 | "apikey": "ba693fed.4c01f8", 104 | "x": 400, 105 | "y": 660, 106 | "wires": [ 107 | [ 108 | "5c5bc36.005563c", 109 | "fec4e447.6fa4d8", 110 | "77f061a6.a3dd7" 111 | ] 112 | ] 113 | }, 114 | { 115 | "id": "b7b794a8.d80fb8", 116 | "type": "comment", 117 | "z": "282fafd4.df968", 118 | "name": "5 Day Forecast", 119 | "info": "", 120 | "x": 120, 121 | "y": 620, 122 | "wires": [] 123 | }, 124 | { 125 | "id": "1a5eba9a.169b45", 126 | "type": "comment", 127 | "z": "282fafd4.df968", 128 | "name": "Recent PWS Observations", 129 | "info": "", 130 | "x": 150, 131 | "y": 320, 132 | "wires": [] 133 | }, 134 | { 135 | "id": "95f6a021.aa9ba8", 136 | "type": "debug", 137 | "z": "282fafd4.df968", 138 | "name": "", 139 | "active": true, 140 | "tosidebar": true, 141 | "console": false, 142 | "tostatus": false, 143 | "complete": "false", 144 | "x": 870, 145 | "y": 360, 146 | "wires": [] 147 | }, 148 | { 149 | "id": "cf262cff.8843e", 150 | "type": "debug", 151 | "z": "282fafd4.df968", 152 | "name": "", 153 | "active": true, 154 | "tosidebar": true, 155 | "console": false, 156 | "tostatus": false, 157 | "complete": "true", 158 | "targetType": "full", 159 | "x": 610, 160 | "y": 360, 161 | "wires": [] 162 | }, 163 | { 164 | "id": "4adddd56.4d9fc4", 165 | "type": "ui_text_input", 166 | "z": "282fafd4.df968", 167 | "name": "", 168 | "label": "Enter StationID", 169 | "tooltip": "", 170 | "group": "a91cd93c.4ca95", 171 | "order": 1, 172 | "width": 0, 173 | "height": 0, 174 | "passthru": true, 175 | "mode": "text", 176 | "delay": 300, 177 | "topic": "", 178 | "x": 120, 179 | "y": 100, 180 | "wires": [ 181 | [ 182 | "a41d8185.128c7" 183 | ] 184 | ] 185 | }, 186 | { 187 | "id": "a41d8185.128c7", 188 | "type": "change", 189 | "z": "282fafd4.df968", 190 | "name": "", 191 | "rules": [ 192 | { 193 | "t": "set", 194 | "p": "StationID", 195 | "pt": "flow", 196 | "to": "payload", 197 | "tot": "msg" 198 | } 199 | ], 200 | "action": "", 201 | "property": "", 202 | "from": "", 203 | "to": "", 204 | "reg": false, 205 | "x": 390, 206 | "y": 100, 207 | "wires": [ 208 | [ 209 | "1d33165b.0656ea" 210 | ] 211 | ] 212 | }, 213 | { 214 | "id": "8fd9fd9d.76cff", 215 | "type": "ui_button", 216 | "z": "282fafd4.df968", 217 | "name": "", 218 | "group": "a91cd93c.4ca95", 219 | "order": 2, 220 | "width": "6", 221 | "height": "1", 222 | "passthru": false, 223 | "label": "Current PWS Observations", 224 | "tooltip": "", 225 | "color": "", 226 | "bgcolor": "", 227 | "icon": "", 228 | "payload": "", 229 | "payloadType": "str", 230 | "topic": "", 231 | "x": 160, 232 | "y": 140, 233 | "wires": [ 234 | [ 235 | "6e439dd2.a9fbc4" 236 | ] 237 | ] 238 | }, 239 | { 240 | "id": "6e439dd2.a9fbc4", 241 | "type": "change", 242 | "z": "282fafd4.df968", 243 | "name": "Set twcparams", 244 | "rules": [ 245 | { 246 | "t": "set", 247 | "p": "twcparams", 248 | "pt": "msg", 249 | "to": "{}", 250 | "tot": "json" 251 | }, 252 | { 253 | "t": "set", 254 | "p": "twcparams.StationID", 255 | "pt": "msg", 256 | "to": "StationID", 257 | "tot": "flow" 258 | } 259 | ], 260 | "action": "", 261 | "property": "", 262 | "from": "", 263 | "to": "", 264 | "reg": false, 265 | "x": 380, 266 | "y": 140, 267 | "wires": [ 268 | [ 269 | "36df2040.dab0e8" 270 | ] 271 | ] 272 | }, 273 | { 274 | "id": "1d33165b.0656ea", 275 | "type": "debug", 276 | "z": "282fafd4.df968", 277 | "name": "", 278 | "active": true, 279 | "tosidebar": true, 280 | "console": false, 281 | "tostatus": false, 282 | "complete": "false", 283 | "x": 570, 284 | "y": 100, 285 | "wires": [] 286 | }, 287 | { 288 | "id": "7f93eff4.ad8d48", 289 | "type": "ui_button", 290 | "z": "282fafd4.df968", 291 | "name": "", 292 | "group": "1bba4345.fa4d15", 293 | "order": 1, 294 | "width": 0, 295 | "height": 0, 296 | "passthru": false, 297 | "label": "Today Forecast", 298 | "tooltip": "", 299 | "color": "", 300 | "bgcolor": "", 301 | "icon": "", 302 | "payload": "", 303 | "payloadType": "str", 304 | "topic": "", 305 | "x": 120, 306 | "y": 660, 307 | "wires": [ 308 | [ 309 | "27c10673.26a442" 310 | ] 311 | ] 312 | }, 313 | { 314 | "id": "7af5ad2e.7e20ec", 315 | "type": "ui_button", 316 | "z": "282fafd4.df968", 317 | "name": "", 318 | "group": "a91cd93c.4ca95", 319 | "order": 7, 320 | "width": 0, 321 | "height": 0, 322 | "passthru": false, 323 | "label": "7 Day PWS Hourly Summary", 324 | "tooltip": "", 325 | "color": "", 326 | "bgcolor": "", 327 | "icon": "", 328 | "payload": "", 329 | "payloadType": "str", 330 | "topic": "", 331 | "x": 160, 332 | "y": 360, 333 | "wires": [ 334 | [ 335 | "3cc00f08.79528" 336 | ] 337 | ] 338 | }, 339 | { 340 | "id": "9f3b16b0.6f231", 341 | "type": "function", 342 | "z": "282fafd4.df968", 343 | "name": "Get HourlyAvgTemp", 344 | "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;", 345 | "outputs": 1, 346 | "noerr": 0, 347 | "x": 660, 348 | "y": 400, 349 | "wires": [ 350 | [ 351 | "95f6a021.aa9ba8", 352 | "785597bb.acbdf8" 353 | ] 354 | ] 355 | }, 356 | { 357 | "id": "785597bb.acbdf8", 358 | "type": "ui_chart", 359 | "z": "282fafd4.df968", 360 | "name": "", 361 | "group": "ada0ce32.b103c", 362 | "order": 2, 363 | "width": "12", 364 | "height": "4", 365 | "label": "7 Day PWS Hourly Avg Temp", 366 | "chartType": "line", 367 | "legend": "false", 368 | "xformat": "HH:mm:ss", 369 | "interpolate": "linear", 370 | "nodata": "", 371 | "dot": false, 372 | "ymin": "0", 373 | "ymax": "100", 374 | "removeOlder": 1, 375 | "removeOlderPoints": "", 376 | "removeOlderUnit": "3600", 377 | "cutout": 0, 378 | "useOneColor": false, 379 | "colors": [ 380 | "#1f77b4", 381 | "#aec7e8", 382 | "#ff7f0e", 383 | "#2ca02c", 384 | "#98df8a", 385 | "#d62728", 386 | "#ff9896", 387 | "#9467bd", 388 | "#c5b0d5" 389 | ], 390 | "useOldStyle": false, 391 | "outputs": 1, 392 | "x": 920, 393 | "y": 400, 394 | "wires": [ 395 | [] 396 | ] 397 | }, 398 | { 399 | "id": "89db0f5c.801e58", 400 | "type": "ui_date_picker", 401 | "z": "282fafd4.df968", 402 | "name": "", 403 | "label": "Historical Date", 404 | "group": "a91cd93c.4ca95", 405 | "order": 4, 406 | "width": 0, 407 | "height": 0, 408 | "passthru": true, 409 | "topic": "", 410 | "x": 120, 411 | "y": 540, 412 | "wires": [ 413 | [ 414 | "7890ac05.5252bc" 415 | ] 416 | ] 417 | }, 418 | { 419 | "id": "7890ac05.5252bc", 420 | "type": "change", 421 | "z": "282fafd4.df968", 422 | "name": "Set twcparams", 423 | "rules": [ 424 | { 425 | "t": "set", 426 | "p": "twcparams", 427 | "pt": "msg", 428 | "to": "{}", 429 | "tot": "json" 430 | }, 431 | { 432 | "t": "set", 433 | "p": "twcparams.date", 434 | "pt": "msg", 435 | "to": "payload", 436 | "tot": "msg" 437 | }, 438 | { 439 | "t": "set", 440 | "p": "twcparams.StationID", 441 | "pt": "msg", 442 | "to": "StationID", 443 | "tot": "flow" 444 | } 445 | ], 446 | "action": "", 447 | "property": "", 448 | "from": "", 449 | "to": "", 450 | "reg": false, 451 | "x": 320, 452 | "y": 540, 453 | "wires": [ 454 | [ 455 | "384cef20.42b128", 456 | "9825a586.39c16" 457 | ] 458 | ] 459 | }, 460 | { 461 | "id": "9825a586.39c16", 462 | "type": "debug", 463 | "z": "282fafd4.df968", 464 | "name": "", 465 | "active": true, 466 | "tosidebar": true, 467 | "console": false, 468 | "tostatus": false, 469 | "complete": "true", 470 | "targetType": "full", 471 | "x": 490, 472 | "y": 500, 473 | "wires": [] 474 | }, 475 | { 476 | "id": "599bbba7.ab986c", 477 | "type": "change", 478 | "z": "282fafd4.df968", 479 | "name": "Historical Date AvgTemp ", 480 | "rules": [ 481 | { 482 | "t": "set", 483 | "p": "payload", 484 | "pt": "msg", 485 | "to": "payload.observations[0].imperial.tempAvg", 486 | "tot": "msg" 487 | } 488 | ], 489 | "action": "", 490 | "property": "", 491 | "from": "", 492 | "to": "", 493 | "reg": false, 494 | "x": 750, 495 | "y": 540, 496 | "wires": [ 497 | [ 498 | "216575bf.741902", 499 | "887582a4.04a18" 500 | ] 501 | ] 502 | }, 503 | { 504 | "id": "216575bf.741902", 505 | "type": "ui_gauge", 506 | "z": "282fafd4.df968", 507 | "name": "", 508 | "group": "a91cd93c.4ca95", 509 | "order": 5, 510 | "width": 0, 511 | "height": 0, 512 | "gtype": "gage", 513 | "title": "Historical Date AvgTemp", 514 | "label": "F", 515 | "format": "{{value}}", 516 | "min": 0, 517 | "max": "100", 518 | "colors": [ 519 | "#0054ff", 520 | "#e6e600", 521 | "#ca3838" 522 | ], 523 | "seg1": "", 524 | "seg2": "", 525 | "x": 1010, 526 | "y": 540, 527 | "wires": [] 528 | }, 529 | { 530 | "id": "e5d07e30.329da", 531 | "type": "inject", 532 | "z": "282fafd4.df968", 533 | "name": "Hourly refresh", 534 | "topic": "", 535 | "payload": "", 536 | "payloadType": "date", 537 | "repeat": "3600", 538 | "crontab": "", 539 | "once": false, 540 | "onceDelay": 0.1, 541 | "x": 120, 542 | "y": 700, 543 | "wires": [ 544 | [ 545 | "27c10673.26a442" 546 | ] 547 | ] 548 | }, 549 | { 550 | "id": "5c5bc36.005563c", 551 | "type": "function", 552 | "z": "282fafd4.df968", 553 | "name": "Narrative", 554 | "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]}];", 555 | "outputs": 6, 556 | "noerr": 0, 557 | "x": 300, 558 | "y": 760, 559 | "wires": [ 560 | [ 561 | "d2b0178b.fa37e8", 562 | "c6f84647.c727" 563 | ], 564 | [ 565 | "d2b0178b.fa37e8", 566 | "38c5e3a2.2f759c" 567 | ], 568 | [ 569 | "d2b0178b.fa37e8", 570 | "e6eeebc9.faf3d" 571 | ], 572 | [ 573 | "d2b0178b.fa37e8", 574 | "6061525a.e3fe14" 575 | ], 576 | [ 577 | "d2b0178b.fa37e8", 578 | "54c87a53.d9ec64" 579 | ], 580 | [ 581 | "d2b0178b.fa37e8", 582 | "2035f1f6.a56dbe" 583 | ] 584 | ] 585 | }, 586 | { 587 | "id": "fec4e447.6fa4d8", 588 | "type": "debug", 589 | "z": "282fafd4.df968", 590 | "name": "", 591 | "active": true, 592 | "tosidebar": true, 593 | "console": false, 594 | "tostatus": false, 595 | "complete": "false", 596 | "x": 690, 597 | "y": 660, 598 | "wires": [] 599 | }, 600 | { 601 | "id": "d2b0178b.fa37e8", 602 | "type": "debug", 603 | "z": "282fafd4.df968", 604 | "name": "", 605 | "active": true, 606 | "tosidebar": true, 607 | "console": false, 608 | "tostatus": false, 609 | "complete": "false", 610 | "x": 530, 611 | "y": 960, 612 | "wires": [] 613 | }, 614 | { 615 | "id": "c6f84647.c727", 616 | "type": "ui_text", 617 | "z": "282fafd4.df968", 618 | "group": "1bba4345.fa4d15", 619 | "order": 3, 620 | "width": "6", 621 | "height": "2", 622 | "name": "", 623 | "label": "", 624 | "format": "{{msg.payload}}", 625 | "layout": "row-left", 626 | "x": 510, 627 | "y": 720, 628 | "wires": [] 629 | }, 630 | { 631 | "id": "38c5e3a2.2f759c", 632 | "type": "ui_text", 633 | "z": "282fafd4.df968", 634 | "group": "1bba4345.fa4d15", 635 | "order": 5, 636 | "width": "6", 637 | "height": "2", 638 | "name": "", 639 | "label": "", 640 | "format": "{{msg.payload}}", 641 | "layout": "row-left", 642 | "x": 510, 643 | "y": 760, 644 | "wires": [] 645 | }, 646 | { 647 | "id": "e6eeebc9.faf3d", 648 | "type": "ui_text", 649 | "z": "282fafd4.df968", 650 | "group": "1bba4345.fa4d15", 651 | "order": 7, 652 | "width": "6", 653 | "height": "2", 654 | "name": "", 655 | "label": "", 656 | "format": "{{msg.payload}}", 657 | "layout": "row-left", 658 | "x": 510, 659 | "y": 800, 660 | "wires": [] 661 | }, 662 | { 663 | "id": "6061525a.e3fe14", 664 | "type": "ui_text", 665 | "z": "282fafd4.df968", 666 | "group": "1bba4345.fa4d15", 667 | "order": 9, 668 | "width": "6", 669 | "height": "2", 670 | "name": "", 671 | "label": "", 672 | "format": "{{msg.payload}}", 673 | "layout": "row-left", 674 | "x": 510, 675 | "y": 840, 676 | "wires": [] 677 | }, 678 | { 679 | "id": "54c87a53.d9ec64", 680 | "type": "ui_text", 681 | "z": "282fafd4.df968", 682 | "group": "1bba4345.fa4d15", 683 | "order": 11, 684 | "width": "6", 685 | "height": "2", 686 | "name": "", 687 | "label": "", 688 | "format": "{{msg.payload}}", 689 | "layout": "row-left", 690 | "x": 510, 691 | "y": 880, 692 | "wires": [] 693 | }, 694 | { 695 | "id": "2035f1f6.a56dbe", 696 | "type": "ui_text", 697 | "z": "282fafd4.df968", 698 | "group": "1bba4345.fa4d15", 699 | "order": 13, 700 | "width": "6", 701 | "height": "2", 702 | "name": "", 703 | "label": "", 704 | "format": "{{msg.payload}}", 705 | "layout": "row-left", 706 | "x": 510, 707 | "y": 920, 708 | "wires": [] 709 | }, 710 | { 711 | "id": "97fe9121.6dbc48", 712 | "type": "inject", 713 | "z": "282fafd4.df968", 714 | "name": "", 715 | "topic": "", 716 | "payload": "", 717 | "payloadType": "date", 718 | "repeat": "", 719 | "crontab": "", 720 | "once": false, 721 | "onceDelay": 0.1, 722 | "x": 200, 723 | "y": 400, 724 | "wires": [ 725 | [ 726 | "3cc00f08.79528" 727 | ] 728 | ] 729 | }, 730 | { 731 | "id": "eb564a5d.b01118", 732 | "type": "ui_template", 733 | "z": "282fafd4.df968", 734 | "group": "1bba4345.fa4d15", 735 | "name": "Weather Icon Image1", 736 | "order": 2, 737 | "width": "2", 738 | "height": "2", 739 | "format": "
\n\n
", 740 | "storeOutMessages": false, 741 | "fwdInMessages": true, 742 | "templateScope": "local", 743 | "x": 1020, 744 | "y": 720, 745 | "wires": [ 746 | [] 747 | ] 748 | }, 749 | { 750 | "id": "8d8a0f4c.d53668", 751 | "type": "debug", 752 | "z": "282fafd4.df968", 753 | "name": "", 754 | "active": true, 755 | "console": "false", 756 | "complete": "payload", 757 | "x": 990, 758 | "y": 960, 759 | "wires": [] 760 | }, 761 | { 762 | "id": "77f061a6.a3dd7", 763 | "type": "function", 764 | "z": "282fafd4.df968", 765 | "name": "Weather Icon", 766 | "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", 767 | "outputs": 6, 768 | "noerr": 0, 769 | "x": 750, 770 | "y": 760, 771 | "wires": [ 772 | [ 773 | "8d8a0f4c.d53668", 774 | "eb564a5d.b01118" 775 | ], 776 | [ 777 | "8d8a0f4c.d53668", 778 | "71761249.14ae4c" 779 | ], 780 | [ 781 | "8d8a0f4c.d53668", 782 | "e9c1cf4f.1efb3" 783 | ], 784 | [ 785 | "8d8a0f4c.d53668", 786 | "95fe10b6.103008" 787 | ], 788 | [ 789 | "8d8a0f4c.d53668", 790 | "159f2e1d.f12802" 791 | ], 792 | [ 793 | "8d8a0f4c.d53668", 794 | "1c28ad07.583053" 795 | ] 796 | ] 797 | }, 798 | { 799 | "id": "71761249.14ae4c", 800 | "type": "ui_template", 801 | "z": "282fafd4.df968", 802 | "group": "1bba4345.fa4d15", 803 | "name": "Weather Icon Image2", 804 | "order": 4, 805 | "width": "2", 806 | "height": "2", 807 | "format": "
\n\n
", 808 | "storeOutMessages": false, 809 | "fwdInMessages": true, 810 | "templateScope": "local", 811 | "x": 1020, 812 | "y": 760, 813 | "wires": [ 814 | [] 815 | ] 816 | }, 817 | { 818 | "id": "e9c1cf4f.1efb3", 819 | "type": "ui_template", 820 | "z": "282fafd4.df968", 821 | "group": "1bba4345.fa4d15", 822 | "name": "Weather Icon Image3", 823 | "order": 6, 824 | "width": "2", 825 | "height": "2", 826 | "format": "
\n\n
", 827 | "storeOutMessages": false, 828 | "fwdInMessages": true, 829 | "templateScope": "local", 830 | "x": 1020, 831 | "y": 800, 832 | "wires": [ 833 | [] 834 | ] 835 | }, 836 | { 837 | "id": "95fe10b6.103008", 838 | "type": "ui_template", 839 | "z": "282fafd4.df968", 840 | "group": "1bba4345.fa4d15", 841 | "name": "Weather Icon Image4", 842 | "order": 8, 843 | "width": "2", 844 | "height": "2", 845 | "format": "
\n\n
", 846 | "storeOutMessages": false, 847 | "fwdInMessages": true, 848 | "templateScope": "local", 849 | "x": 1020, 850 | "y": 840, 851 | "wires": [ 852 | [] 853 | ] 854 | }, 855 | { 856 | "id": "159f2e1d.f12802", 857 | "type": "ui_template", 858 | "z": "282fafd4.df968", 859 | "group": "1bba4345.fa4d15", 860 | "name": "Weather Icon Image5", 861 | "order": 10, 862 | "width": "2", 863 | "height": "2", 864 | "format": "
\n\n
", 865 | "storeOutMessages": false, 866 | "fwdInMessages": true, 867 | "templateScope": "local", 868 | "x": 1020, 869 | "y": 880, 870 | "wires": [ 871 | [] 872 | ] 873 | }, 874 | { 875 | "id": "1c28ad07.583053", 876 | "type": "ui_template", 877 | "z": "282fafd4.df968", 878 | "group": "1bba4345.fa4d15", 879 | "name": "Weather Icon Image6", 880 | "order": 12, 881 | "width": "2", 882 | "height": "2", 883 | "format": "
\n\n
", 884 | "storeOutMessages": false, 885 | "fwdInMessages": true, 886 | "templateScope": "local", 887 | "x": 1020, 888 | "y": 920, 889 | "wires": [ 890 | [] 891 | ] 892 | }, 893 | { 894 | "id": "e4380e97.48866", 895 | "type": "pws-7day-hourly", 896 | "z": "282fafd4.df968", 897 | "name": "", 898 | "stationid": "", 899 | "units": "e", 900 | "apikey": "ba693fed.4c01f8", 901 | "x": 430, 902 | "y": 400, 903 | "wires": [ 904 | [ 905 | "cf262cff.8843e", 906 | "9f3b16b0.6f231" 907 | ] 908 | ] 909 | }, 910 | { 911 | "id": "3cc00f08.79528", 912 | "type": "change", 913 | "z": "282fafd4.df968", 914 | "name": "Set twcparams", 915 | "rules": [ 916 | { 917 | "t": "set", 918 | "p": "twcparams", 919 | "pt": "msg", 920 | "to": "{}", 921 | "tot": "json" 922 | }, 923 | { 924 | "t": "set", 925 | "p": "twcparams.StationID", 926 | "pt": "msg", 927 | "to": "StationID", 928 | "tot": "flow" 929 | } 930 | ], 931 | "action": "", 932 | "property": "", 933 | "from": "", 934 | "to": "", 935 | "reg": false, 936 | "x": 400, 937 | "y": 360, 938 | "wires": [ 939 | [ 940 | "e4380e97.48866" 941 | ] 942 | ] 943 | }, 944 | { 945 | "id": "7bbfbf86.8f9658", 946 | "type": "comment", 947 | "z": "282fafd4.df968", 948 | "name": "One time - Add Map to Dashboard", 949 | "info": "", 950 | "x": 180, 951 | "y": 220, 952 | "wires": [] 953 | }, 954 | { 955 | "id": "79b761e2.440c78", 956 | "type": "inject", 957 | "z": "282fafd4.df968", 958 | "name": "Init WorldMap", 959 | "topic": "", 960 | "payload": "true", 961 | "payloadType": "bool", 962 | "repeat": "", 963 | "crontab": "", 964 | "once": true, 965 | "onceDelay": "1", 966 | "x": 230, 967 | "y": 260, 968 | "wires": [ 969 | [ 970 | "982eedd1.509c58", 971 | "8285c7b2.4d23b8" 972 | ] 973 | ] 974 | }, 975 | { 976 | "id": "d54f125f.e6a1a", 977 | "type": "ui_template", 978 | "z": "282fafd4.df968", 979 | "group": "ada0ce32.b103c", 980 | "name": "Embedded Map", 981 | "order": 1, 982 | "width": "12", 983 | "height": "8", 984 | "format": "
", 985 | "storeOutMessages": true, 986 | "fwdInMessages": true, 987 | "templateScope": "local", 988 | "x": 660, 989 | "y": 260, 990 | "wires": [ 991 | [] 992 | ] 993 | }, 994 | { 995 | "id": "b1cccbd5.a704d8", 996 | "type": "worldmap", 997 | "z": "282fafd4.df968", 998 | "name": "", 999 | "lat": "", 1000 | "lon": "", 1001 | "zoom": "", 1002 | "layer": "", 1003 | "cluster": "", 1004 | "maxage": "", 1005 | "usermenu": "show", 1006 | "layers": "show", 1007 | "panit": "false", 1008 | "panlock": "false", 1009 | "zoomlock": "false", 1010 | "hiderightclick": "false", 1011 | "coords": "none", 1012 | "path": "/weathermap", 1013 | "x": 990, 1014 | "y": 220, 1015 | "wires": [] 1016 | }, 1017 | { 1018 | "id": "c6e23e3.7c6be4", 1019 | "type": "change", 1020 | "z": "282fafd4.df968", 1021 | "name": "Default map", 1022 | "rules": [ 1023 | { 1024 | "t": "delete", 1025 | "p": "payload", 1026 | "pt": "msg" 1027 | }, 1028 | { 1029 | "t": "set", 1030 | "p": "payload", 1031 | "pt": "msg", 1032 | "to": "{\"command\":{\"layer\":\"OSM\",\"lat\":41.2417,\"lon\":-99.3829,\"zoom\":4,\"addtoheatmap\":true,\"autopan\":true,\"clear\":\"OSM\",\"map\":{\"name\":\"OSM\",\"url\":\"http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png\",\"opt\":{\"MaxZoom\":18,\"attribution\":\"© OpenStreetMap\"}}}}", 1033 | "tot": "json" 1034 | } 1035 | ], 1036 | "action": "", 1037 | "property": "", 1038 | "from": "", 1039 | "to": "", 1040 | "reg": false, 1041 | "x": 650, 1042 | "y": 220, 1043 | "wires": [ 1044 | [ 1045 | "b1cccbd5.a704d8" 1046 | ] 1047 | ] 1048 | }, 1049 | { 1050 | "id": "982eedd1.509c58", 1051 | "type": "delay", 1052 | "z": "282fafd4.df968", 1053 | "name": "", 1054 | "pauseType": "delay", 1055 | "timeout": "1", 1056 | "timeoutUnits": "seconds", 1057 | "rate": "1", 1058 | "nbRateUnits": "1", 1059 | "rateUnits": "second", 1060 | "randomFirst": "1", 1061 | "randomLast": "5", 1062 | "randomUnits": "seconds", 1063 | "drop": false, 1064 | "x": 420, 1065 | "y": 220, 1066 | "wires": [ 1067 | [ 1068 | "c6e23e3.7c6be4" 1069 | ] 1070 | ] 1071 | }, 1072 | { 1073 | "id": "b7babaaf.bb0448", 1074 | "type": "function", 1075 | "z": "282fafd4.df968", 1076 | "name": "Plot on Map", 1077 | "func": "if( typeof(msg.payload.observations) == 'undefined') {\n return null;\n}\n\nvar weather = {};\nif( typeof( msg.payload.observations[0].metric) != 'undefined') {\n weather = msg.payload.observations[0].metric;\n delete msg.payload.observations[0].metric\n} else if( typeof( msg.payload.observations[0].imperial) != 'undefined') {\n weather = msg.payload.observations[0].imperial;\n delete msg.payload.observations[0].imperial\n} else if( typeof( msg.payload.observations[0].uk_hybrid) != 'undefined') {\n weather = msg.payload.observations[0].uk_hybrid;\n delete msg.payload.observations[0].uk_hybrid\n}\nfor (const [key, value] of Object.entries(weather)) {\n // Move the key/value pairs up so they appear nicely in the marker popup\n msg.payload[key]=value;\n}\n\nfor (const [key, value] of Object.entries(msg.payload.observations[0])) {\n // Move the key/value pairs up so they appear nicely in the marker popup\n msg.payload[key]=value;\n}\ndelete msg.payload.observations;\n\n\nmsg.payload.name = msg.twcparams.StationID;\nmsg.payload.icon = \"globe\";\nif( msg.payload.temp > 60 ) {\n msg.payload.iconColor = \"red\";\n} else {\n msg.payload.iconColor = \"orange\";\n}\n\nmsg.payload.command = { zoom:6, \n \"lat\":msg.payload.lat,\n \"lon\":msg.payload.lon,\n autopan:true };\n\nreturn msg;", 1078 | "outputs": 1, 1079 | "noerr": 0, 1080 | "x": 810, 1081 | "y": 180, 1082 | "wires": [ 1083 | [ 1084 | "b1cccbd5.a704d8" 1085 | ] 1086 | ] 1087 | }, 1088 | { 1089 | "id": "8285c7b2.4d23b8", 1090 | "type": "change", 1091 | "z": "282fafd4.df968", 1092 | "name": "Inject /weathermap", 1093 | "rules": [ 1094 | { 1095 | "t": "set", 1096 | "p": "payload", 1097 | "pt": "msg", 1098 | "to": "", 1099 | "tot": "str" 1100 | } 1101 | ], 1102 | "action": "", 1103 | "property": "", 1104 | "from": "", 1105 | "to": "", 1106 | "reg": false, 1107 | "x": 450, 1108 | "y": 260, 1109 | "wires": [ 1110 | [ 1111 | "d54f125f.e6a1a" 1112 | ] 1113 | ] 1114 | }, 1115 | { 1116 | "id": "a74bb8bb.139fc8", 1117 | "type": "ui_table", 1118 | "z": "282fafd4.df968", 1119 | "group": "ada0ce32.b103c", 1120 | "name": "", 1121 | "order": 3, 1122 | "width": "12", 1123 | "height": "4", 1124 | "columns": [ 1125 | { 1126 | "field": "observations", 1127 | "title": "Observations", 1128 | "width": "50%", 1129 | "align": "left", 1130 | "formatter": "plaintext", 1131 | "formatterParams": { 1132 | "target": "_blank" 1133 | } 1134 | }, 1135 | { 1136 | "field": "results", 1137 | "title": "Results", 1138 | "width": "48%", 1139 | "align": "right", 1140 | "formatter": "plaintext", 1141 | "formatterParams": { 1142 | "target": "_blank" 1143 | } 1144 | } 1145 | ], 1146 | "outputs": 0, 1147 | "cts": false, 1148 | "x": 970, 1149 | "y": 140, 1150 | "wires": [] 1151 | }, 1152 | { 1153 | "id": "b3dc9bd1.1c29f", 1154 | "type": "function", 1155 | "z": "282fafd4.df968", 1156 | "name": "Build Table", 1157 | "func": "if( typeof(msg.payload.observations) == 'undefined') {\n return null;\n}\n\nvar TableArray = [];\nfor (const [key, value] of Object.entries(msg.payload.observations[0])) {\n var TableEntry = {};\n TableEntry.observations = key ;\n TableEntry.results = value ;\n TableArray.push( TableEntry );\n}\n\nvar weather = {};\nif( typeof( msg.payload.observations[0].metric) != 'undefined') {\n weather = msg.payload.observations[0].metric;\n} else if( typeof( msg.payload.observations[0].imperial) != 'undefined') {\n weather = msg.payload.observations[0].imperial;\n} else if( typeof( msg.payload.observations[0].uk_hybrid) != 'undefined') {\n weather = msg.payload.observations[0].uk_hybrid;\n} \n \nfor (const [key, value] of Object.entries(weather)) {\n var TableEntry = {};\n TableEntry.observations = key ;\n TableEntry.results = value ;\n TableArray.push( TableEntry );\n}\n\nmsg.payload = TableArray;\nreturn msg;", 1158 | "outputs": 1, 1159 | "noerr": 0, 1160 | "x": 810, 1161 | "y": 140, 1162 | "wires": [ 1163 | [ 1164 | "a74bb8bb.139fc8" 1165 | ] 1166 | ] 1167 | }, 1168 | { 1169 | "id": "ba693fed.4c01f8", 1170 | "type": "pwsapikey", 1171 | "z": "", 1172 | "name": "" 1173 | }, 1174 | { 1175 | "id": "a91cd93c.4ca95", 1176 | "type": "ui_group", 1177 | "z": "", 1178 | "name": "PWS Queries", 1179 | "tab": "a105e68a.f1f57", 1180 | "order": 1, 1181 | "disp": true, 1182 | "width": "6", 1183 | "collapse": false 1184 | }, 1185 | { 1186 | "id": "1bba4345.fa4d15", 1187 | "type": "ui_group", 1188 | "z": "", 1189 | "name": "Forecast", 1190 | "tab": "a105e68a.f1f57", 1191 | "order": 3, 1192 | "disp": true, 1193 | "width": "8", 1194 | "collapse": false 1195 | }, 1196 | { 1197 | "id": "ada0ce32.b103c", 1198 | "type": "ui_group", 1199 | "z": "", 1200 | "name": "PWS Results", 1201 | "tab": "a105e68a.f1f57", 1202 | "order": 2, 1203 | "disp": true, 1204 | "width": "12", 1205 | "collapse": false 1206 | }, 1207 | { 1208 | "id": "a105e68a.f1f57", 1209 | "type": "ui_tab", 1210 | "z": "", 1211 | "name": "PWS Example", 1212 | "icon": "wi-wu-partlycloudy", 1213 | "order": 1, 1214 | "disabled": false, 1215 | "hidden": false 1216 | } 1217 | ] 1218 | --------------------------------------------------------------------------------