Merge pull request #7 from OpenSprinkler/feature/add-openweather-map-support

Add OpenWeatherMap and set it as the default when no key is provided
This commit is contained in:
Samer Albahra
2018-05-24 09:46:25 -05:00
committed by GitHub
5 changed files with 54 additions and 336 deletions

View File

@@ -10,6 +10,5 @@ before_script:
- grunt - grunt
after_script: after_script:
- istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec - istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec
- cat coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js
notifications: notifications:
on_failure: change on_failure: change

View File

@@ -1,5 +1,5 @@
<img align="left" height="150" src="http://albahra.com/opensprinkler/icon-new.png"><h3>&nbsp;OpenSprinkler Weather Service [![GitHub version](https://badge.fury.io/gh/OpenSprinkler%2FOpenSprinkler-Weather.svg)](http://badge.fury.io/gh/OpenSprinkler%2FOpenSprinkler-Weather)</h3> <img align="left" height="150" src="http://albahra.com/opensprinkler/icon-new.png"><h3>&nbsp;OpenSprinkler Weather Service [![GitHub version](https://badge.fury.io/gh/OpenSprinkler%2FOpenSprinkler-Weather.svg)](http://badge.fury.io/gh/OpenSprinkler%2FOpenSprinkler-Weather)</h3>
&nbsp;[![Build Status](https://api.travis-ci.org/OpenSprinkler/OpenSprinkler-Weather.svg?branch=master)](https://travis-ci.org/) [![codecov.io](http://codecov.io/github/OpenSprinkler/OpenSprinkler-Weather/coverage.svg?branch=master)](http://codecov.io/github/OpenSprinkler/OpenSprinkler-Weather?branch=master) [![devDependency Status](https://david-dm.org/OpenSprinkler/OpenSprinkler-Weather/status.svg)](https://david-dm.org/OpenSprinkler/OpenSprinkler-Weather#info=dependencies) &nbsp;[![Build Status](https://api.travis-ci.org/OpenSprinkler/OpenSprinkler-Weather.svg?branch=master)](https://travis-ci.org/) [![devDependency Status](https://david-dm.org/OpenSprinkler/OpenSprinkler-Weather/status.svg)](https://david-dm.org/OpenSprinkler/OpenSprinkler-Weather#info=dependencies)
&nbsp;[Official Site][official] | [Support][help] | [Changelog][changelog] &nbsp;[Official Site][official] | [Support][help] | [Changelog][changelog]
<br> <br>
This script is used by OpenSprinkler Unified Firmware to update the water level of the device. It also provides timezone information based on user location along with other local information (sunrise, sunset, daylights saving time, etc). This script is used by OpenSprinkler Unified Firmware to update the water level of the device. It also provides timezone information based on user location along with other local information (sunrise, sunset, daylights saving time, etc).

308
package-lock.json generated
View File

@@ -100,40 +100,12 @@
"resolved": "https://registry.npmjs.org/array-source/-/array-source-0.0.4.tgz", "resolved": "https://registry.npmjs.org/array-source/-/array-source-0.0.4.tgz",
"integrity": "sha512-frNdc+zBn80vipY+GdcJkLEbMWj3xmzArYApmUGxoiV8uAu/ygcs9icPdsGdA26h0MkHUMW6EN2piIvVx+M5Mw==" "integrity": "sha512-frNdc+zBn80vipY+GdcJkLEbMWj3xmzArYApmUGxoiV8uAu/ygcs9icPdsGdA26h0MkHUMW6EN2piIvVx+M5Mw=="
}, },
"asn1": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz",
"integrity": "sha1-VZvhg3bQik7E2+gId9J4GGObLfc=",
"dev": true,
"optional": true
},
"assert-plus": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz",
"integrity": "sha1-7nQAlBMALYTOxyGcasgRgS5yMWA=",
"dev": true,
"optional": true
},
"assertion-error": { "assertion-error": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.1.tgz", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.1.tgz",
"integrity": "sha1-NaruwzCX8R9COZ7K3zP6zNJ/XEw=", "integrity": "sha1-NaruwzCX8R9COZ7K3zP6zNJ/XEw=",
"dev": true "dev": true
}, },
"async": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz",
"integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=",
"dev": true,
"optional": true
},
"aws-sign2": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz",
"integrity": "sha1-xXED96F/wDfwLXwuZLYC6iI/fWM=",
"dev": true,
"optional": true
},
"aws4": { "aws4": {
"version": "1.7.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz",
@@ -155,15 +127,6 @@
"tweetnacl": "^0.14.3" "tweetnacl": "^0.14.3"
} }
}, },
"bl": {
"version": "0.9.5",
"resolved": "https://registry.npmjs.org/bl/-/bl-0.9.5.tgz",
"integrity": "sha1-wGt5evCF6gC8Unr8jvzxHeIjIFQ=",
"dev": true,
"requires": {
"readable-stream": "~1.0.26"
}
},
"bluebird": { "bluebird": {
"version": "3.5.0", "version": "3.5.0",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz",
@@ -193,15 +156,6 @@
} }
} }
}, },
"boom": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/boom/-/boom-0.4.2.tgz",
"integrity": "sha1-emNune1O/O+xnO9JR6PGffrukRs=",
"dev": true,
"requires": {
"hoek": "0.9.x"
}
},
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@@ -256,12 +210,6 @@
"map-obj": "^1.0.0" "map-obj": "^1.0.0"
} }
}, },
"caseless": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.6.0.tgz",
"integrity": "sha1-gWfBq4OX+1u5X5bSjlqBxQ8kesQ=",
"dev": true
},
"center-align": { "center-align": {
"version": "0.1.3", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz",
@@ -349,16 +297,6 @@
} }
} }
}, },
"codecov.io": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/codecov.io/-/codecov.io-0.1.6.tgz",
"integrity": "sha1-Wd/QLaH/McL7K5Uq2K0W/TeBtyg=",
"dev": true,
"requires": {
"request": "2.42.0",
"urlgrey": "0.4.0"
}
},
"coffeescript": { "coffeescript": {
"version": "1.10.0", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-1.10.0.tgz", "resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-1.10.0.tgz",
@@ -369,16 +307,6 @@
"resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz",
"integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=" "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM="
}, },
"combined-stream": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz",
"integrity": "sha1-ATfmV7qlp1QcV6w3rF/AfXO03B8=",
"dev": true,
"optional": true,
"requires": {
"delayed-stream": "0.0.5"
}
},
"commander": { "commander": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz",
@@ -476,23 +404,6 @@
"moment-timezone": "^0.5.x" "moment-timezone": "^0.5.x"
} }
}, },
"cryptiles": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-0.2.2.tgz",
"integrity": "sha1-7ZH/HxetE9N0gohZT4pIoNJvMlw=",
"dev": true,
"optional": true,
"requires": {
"boom": "0.4.x"
}
},
"ctype": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz",
"integrity": "sha1-gsGMJGH3QRTvFsE1IkrQuRRMoS8=",
"dev": true,
"optional": true
},
"currently-unhandled": { "currently-unhandled": {
"version": "0.4.1", "version": "0.4.1",
"resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz",
@@ -563,31 +474,12 @@
} }
} }
}, },
"deep-equal": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.1.2.tgz",
"integrity": "sha1-skbCuApXCkfBG+HZvRBw7IeLh84=",
"dev": true
},
"deep-is": { "deep-is": {
"version": "0.1.3", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
"integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
"dev": true "dev": true
}, },
"defined": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/defined/-/defined-0.0.0.tgz",
"integrity": "sha1-817qfXBekzuvE7LwOz+D2SFAOz4=",
"dev": true
},
"delayed-stream": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz",
"integrity": "sha1-1LH0OpPoKW3+AmlPRoC8N6MTxz8=",
"dev": true,
"optional": true
},
"depd": { "depd": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
@@ -658,12 +550,6 @@
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-2.0.0.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-2.0.0.tgz",
"integrity": "sha1-vXWcNXqqcDZeAclrewvsCKbg2Uk=" "integrity": "sha1-vXWcNXqqcDZeAclrewvsCKbg2Uk="
}, },
"duplexer": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
"integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=",
"dev": true
},
"ecc-jsbn": { "ecc-jsbn": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
@@ -879,24 +765,6 @@
} }
} }
}, },
"forever-agent": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz",
"integrity": "sha1-bQ4JxJIflKJ/Y9O0nF/v8epMUTA=",
"dev": true
},
"form-data": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-0.1.4.tgz",
"integrity": "sha1-kavXiKupcCsaq/qLwBAxoqyeOxI=",
"dev": true,
"optional": true,
"requires": {
"async": "~0.9.0",
"combined-stream": "~0.0.4",
"mime": "~1.2.11"
}
},
"forwarded": { "forwarded": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
@@ -1174,19 +1042,6 @@
"integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=",
"dev": true "dev": true
}, },
"hawk": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/hawk/-/hawk-1.1.1.tgz",
"integrity": "sha1-h81JH5tG5OKurKM1QWdmiF0tHtk=",
"dev": true,
"optional": true,
"requires": {
"boom": "0.4.x",
"cryptiles": "0.2.x",
"hoek": "0.9.x",
"sntp": "0.2.x"
}
},
"he": { "he": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
@@ -1426,12 +1281,6 @@
} }
} }
}, },
"hoek": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz",
"integrity": "sha1-PTIkYrrfB3Fup+uFuviAec3c5QU=",
"dev": true
},
"hooker": { "hooker": {
"version": "0.2.3", "version": "0.2.3",
"resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz",
@@ -1492,18 +1341,6 @@
} }
} }
}, },
"http-signature": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-0.10.1.tgz",
"integrity": "sha1-T72sEyVZqoMjEh5UB3nAoBKyfmY=",
"dev": true,
"optional": true,
"requires": {
"asn1": "0.1.11",
"assert-plus": "^0.1.5",
"ctype": "0.5.3"
}
},
"iconv-lite": { "iconv-lite": {
"version": "0.4.19", "version": "0.4.19",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
@@ -1731,12 +1568,6 @@
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
"dev": true "dev": true
}, },
"jsonify": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
"dev": true
},
"jsonpointer": { "jsonpointer": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz",
@@ -1868,24 +1699,11 @@
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
}, },
"mime": {
"version": "1.2.11",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz",
"integrity": "sha1-WCA+7Ybjpe8XrtK32evUfwpg3RA=",
"dev": true,
"optional": true
},
"mime-db": { "mime-db": {
"version": "1.33.0", "version": "1.33.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
"integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ=="
}, },
"mime-types": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-1.0.2.tgz",
"integrity": "sha1-mVrhOSq4r/y/yyZB3QVOlDwNXc4=",
"dev": true
},
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
@@ -2230,13 +2048,6 @@
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
}, },
"oauth-sign": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.4.0.tgz",
"integrity": "sha1-8ilW8x6nFRqCHl8vsywRPK2Ln2k=",
"dev": true,
"optional": true
},
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@@ -2416,12 +2227,6 @@
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
"dev": true "dev": true
}, },
"qs": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-1.2.2.tgz",
"integrity": "sha1-GbV/8k3CqZzh+L32r82ln472H4g=",
"dev": true
},
"range-parser": { "range-parser": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
@@ -2485,18 +2290,6 @@
"read-pkg": "^1.0.0" "read-pkg": "^1.0.0"
} }
}, },
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"redent": { "redent": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz",
@@ -2525,29 +2318,6 @@
"is-finite": "^1.0.0" "is-finite": "^1.0.0"
} }
}, },
"request": {
"version": "2.42.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.42.0.tgz",
"integrity": "sha1-VyvQFIk4VkBArHqxSLlkI6BjMEo=",
"dev": true,
"requires": {
"aws-sign2": "~0.5.0",
"bl": "~0.9.0",
"caseless": "~0.6.0",
"forever-agent": "~0.5.0",
"form-data": "~0.1.0",
"hawk": "1.1.1",
"http-signature": "~0.10.0",
"json-stringify-safe": "~5.0.0",
"mime-types": "~1.0.1",
"node-uuid": "~1.4.0",
"oauth-sign": "~0.4.0",
"qs": "~1.2.0",
"stringstream": "~0.0.4",
"tough-cookie": ">=0.12.0",
"tunnel-agent": "~0.4.0"
}
},
"require_optional": { "require_optional": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
@@ -2575,15 +2345,6 @@
"protocol-buffers-schema": "^2.0.2" "protocol-buffers-schema": "^2.0.2"
} }
}, },
"resumer": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz",
"integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=",
"dev": true,
"requires": {
"through": "~2.3.4"
}
},
"right-align": { "right-align": {
"version": "0.1.3", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
@@ -2691,16 +2452,6 @@
"resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
"integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
}, },
"sntp": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/sntp/-/sntp-0.2.4.tgz",
"integrity": "sha1-+4hfGLDzqtGJ+CSGJTa87ux1CQA=",
"dev": true,
"optional": true,
"requires": {
"hoek": "0.9.x"
}
},
"source-map": { "source-map": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz",
@@ -2739,15 +2490,6 @@
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz",
"integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==" "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA=="
}, },
"split": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/split/-/split-0.2.10.tgz",
"integrity": "sha1-Zwl8YB1pfOE2j0GPBs0gHPBSGlc=",
"dev": true,
"requires": {
"through": "2"
}
},
"sprintf-js": { "sprintf-js": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
@@ -2788,15 +2530,6 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
"integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
}, },
"stream-combiner": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz",
"integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=",
"dev": true,
"requires": {
"duplexer": "~0.1.1"
}
},
"stream-source": { "stream-source": {
"version": "0.3.5", "version": "0.3.5",
"resolved": "https://registry.npmjs.org/stream-source/-/stream-source-0.3.5.tgz", "resolved": "https://registry.npmjs.org/stream-source/-/stream-source-0.3.5.tgz",
@@ -2811,7 +2544,8 @@
"stringstream": { "stringstream": {
"version": "0.0.6", "version": "0.0.6",
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz",
"integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==" "integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==",
"dev": true
}, },
"strip-ansi": { "strip-ansi": {
"version": "3.0.1", "version": "3.0.1",
@@ -2853,45 +2587,16 @@
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
}, },
"tape": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/tape/-/tape-2.3.0.tgz",
"integrity": "sha1-Df7scJIn+8yRcKvn8EaWKycUMds=",
"dev": true,
"requires": {
"deep-equal": "~0.1.0",
"defined": "~0.0.0",
"inherits": "~2.0.1",
"jsonify": "~0.0.0",
"resumer": "~0.0.0",
"split": "~0.2.10",
"stream-combiner": "~0.0.2",
"through": "~2.3.4"
}
},
"text-encoding": { "text-encoding": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.1.tgz", "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.1.tgz",
"integrity": "sha1-TeETDmHVDdhnBAQoqhVlbv3cscg=" "integrity": "sha1-TeETDmHVDdhnBAQoqhVlbv3cscg="
}, },
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
"dev": true
},
"timed-cache": { "timed-cache": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/timed-cache/-/timed-cache-1.1.0.tgz", "resolved": "https://registry.npmjs.org/timed-cache/-/timed-cache-1.1.0.tgz",
"integrity": "sha1-HxQlzCbPrAApTecDEY4vCMBIBeI=" "integrity": "sha1-HxQlzCbPrAApTecDEY4vCMBIBeI="
}, },
"tough-cookie": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.2.tgz",
"integrity": "sha1-yDoYMPTl7wuT7yo0iOck+N4Basc=",
"dev": true,
"optional": true
},
"trim-newlines": { "trim-newlines": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz",
@@ -2987,15 +2692,6 @@
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
}, },
"urlgrey": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/urlgrey/-/urlgrey-0.4.0.tgz",
"integrity": "sha1-8GU1cED7NcOzEdTl3DZITZbb6gY=",
"dev": true,
"requires": {
"tape": "2.3.0"
}
},
"util-deprecate": { "util-deprecate": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",

View File

@@ -19,7 +19,6 @@
}, },
"devDependencies": { "devDependencies": {
"chai": "^3.0.0", "chai": "^3.0.0",
"codecov.io": "^0.1.5",
"grunt-contrib-jshint": "^1.1.0", "grunt-contrib-jshint": "^1.1.0",
"hippie": "^0.5.1", "hippie": "^0.5.1",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",

View File

@@ -29,7 +29,7 @@ function resolveCoordinates( location, callback ) {
data = JSON.parse( data ); data = JSON.parse( data );
// Check if the data is valid // Check if the data is valid
if ( typeof data.RESULTS === "object" && data.RESULTS.length ) { if ( typeof data.RESULTS === "object" && data.RESULTS.length && data.RESULTS[ 0 ].tz !== "MISSING" ) {
// If it is, reply with an array containing the GPS coordinates // If it is, reply with an array containing the GPS coordinates
callback( [ data.RESULTS[ 0 ].lat, data.RESULTS[ 0 ].lon ], moment().tz( data.RESULTS[ 0 ].tz ).utcOffset() ); callback( [ data.RESULTS[ 0 ].lat, data.RESULTS[ 0 ].lon ], moment().tz( data.RESULTS[ 0 ].tz ).utcOffset() );
@@ -95,8 +95,8 @@ function getWeatherUndergroundData( location, weatherUndergroundKey, callback )
// Otherwise indicate the request failed // Otherwise indicate the request failed
callback( false ); callback( false );
return;
} }
} ); } );
} }
@@ -137,7 +137,6 @@ function getWxWeatherData( location, callback ) {
} ); } );
updateCache( location, weather ); updateCache( location, weather );
} ); } );
} ); } );
} }
@@ -154,7 +153,6 @@ function getWeatherData( location, callback ) {
// Perform the HTTP request to retrieve the weather data // Perform the HTTP request to retrieve the weather data
httpRequest( url, function( data ) { httpRequest( url, function( data ) {
try { try {
data = JSON.parse( data ); data = JSON.parse( data );
@@ -186,8 +184,8 @@ function getWeatherData( location, callback ) {
// Otherwise indicate the request failed // Otherwise indicate the request failed
callback( false ); callback( false );
return;
} }
} ); } );
} }
@@ -218,6 +216,45 @@ function getYesterdayWeatherData( location, callback ) {
} ); } );
} }
// Retrieve weather data from Open Weather Map
function getOWMWeatherData( location, callback ) {
// Generate URL using OpenWeatherMap in Imperial units
var OWM_API_KEY = process.env.OWM_API_KEY,
forecastUrl = "http://api.openweathermap.org/data/2.5/forecast?appid=" + OWM_API_KEY + "&units=imperial&lat=" + location[ 0 ] + "&lon=" + location[ 1 ];
getTimeData( location, function( weather ) {
// Perform the HTTP request to retrieve the weather data
httpRequest( forecastUrl, function( data ) {
try {
data = JSON.parse( data );
} catch ( err ) {
// Otherwise indicate the request failed
callback( weather );
return;
}
weather.temp = parseInt( data.list[ 0 ].main.temp );
weather.humidity = parseInt( data.list[ 0 ].main.humidity );
weather.wind = parseInt( data.list[ 0 ].wind.speed );
weather.precip = data.list[ 0 ].rain ? parseFloat( data.list[ 0 ].rain[ "3h" ] || 0 ) : 0;
location = location.join( "," );
getCache( {
key: "yesterdayHumidity",
location: location,
weather: weather,
callback: callback
} );
updateCache( location, weather );
} );
} );
}
// Calculate timezone and sun rise/set information // Calculate timezone and sun rise/set information
function getTimeData( location, callback ) { function getTimeData( location, callback ) {
var timezone = moment().tz( geoTZ( location[ 0 ], location[ 1 ] ) ).utcOffset(); var timezone = moment().tz( geoTZ( location[ 0 ], location[ 1 ] ) ).utcOffset();
@@ -393,7 +430,12 @@ exports.getWeather = function( req, res ) {
// and also calculate if a restriction is met to prevent watering. // and also calculate if a restriction is met to prevent watering.
finishRequest = function( weather ) { finishRequest = function( weather ) {
if ( !weather ) { if ( !weather ) {
res.send( "Error: No weather data found." ); if ( typeof location[ 0 ] === "number" && typeof location[ 1 ] === "number" ) {
getTimeData( location, finishRequest );
} else {
res.send( "Error: No weather data found." );
}
return; return;
} }
@@ -486,9 +528,8 @@ exports.getWeather = function( req, res ) {
location = [ parseFloat( location[ 0 ] ), parseFloat( location[ 1 ] ) ]; location = [ parseFloat( location[ 0 ] ), parseFloat( location[ 1 ] ) ];
// Continue with the weather request // Continue with the weather request
getTimeData( location, finishRequest ); getOWMWeatherData( location, finishRequest );
} else {
} else {
// Attempt to resolve provided location to GPS coordinates when it does not match // Attempt to resolve provided location to GPS coordinates when it does not match
// a GPS coordinate or Weather Underground location using Weather Underground autocomplete // a GPS coordinate or Weather Underground location using Weather Underground autocomplete
@@ -499,24 +540,7 @@ exports.getWeather = function( req, res ) {
} }
location = result; location = result;
getWeatherData( location, function( weather ) { getOWMWeatherData( location, finishRequest );
if ( !weather ) {
var tzOffset = getTimezone( timezone, "minutes" ),
// Calculate sunrise and sunset since Weather Underground does not provide it
sunData = SunCalc.getTimes( new Date(), location[ 0 ], location[ 1 ] );
sunData.sunrise.setUTCMinutes( sunData.sunrise.getUTCMinutes() + tzOffset );
sunData.sunset.setUTCMinutes( sunData.sunset.getUTCMinutes() + tzOffset );
weather = {
timezone: timezone,
sunrise: ( sunData.sunrise.getUTCHours() * 60 + sunData.sunrise.getUTCMinutes() ),
sunset: ( sunData.sunset.getUTCHours() * 60 + sunData.sunset.getUTCMinutes() )
};
}
finishRequest( weather );
} );
} ); } );
} }
}; };