From b937449ce268566855b6326070c80cadc653d11e Mon Sep 17 00:00:00 2001 From: Raimond Brookman Date: Sun, 4 Nov 2018 07:25:49 -0800 Subject: [PATCH] Add documentation and make long-lat configurable --- daylight-rgbw.html | 54 +++- daylight-rgbw.js | 7 +- package-lock.json | 237 ++++++++---------- package.json | 2 +- ...lor-temp_spec.js => daylight-rgbw_spec.js} | 0 5 files changed, 152 insertions(+), 148 deletions(-) rename test/{input-color-temp_spec.js => daylight-rgbw_spec.js} (100%) diff --git a/daylight-rgbw.html b/daylight-rgbw.html index f34356f..8e043b8 100644 --- a/daylight-rgbw.html +++ b/daylight-rgbw.html @@ -20,6 +20,14 @@ +
+ + +
+
+ + +
@@ -36,27 +44,28 @@ @@ -102,6 +138,8 @@

Details

defaults: { name: {value:""}, topic: {value:"daylight-rgbw", required:true}, + latitude: {required:true, validate:RED.validators.number() }, + longitude: {required:true, validate:RED.validators.number() }, minColorTemp: {value:1000, required:true, validate:RED.validators.number() }, maxColorTemp: {value:6000, required:true, validate:RED.validators.number()}, whiteLevel: {value:50, required:true, validate:RED.validators.number()} diff --git a/daylight-rgbw.js b/daylight-rgbw.js index 12954f6..05eb4aa 100644 --- a/daylight-rgbw.js +++ b/daylight-rgbw.js @@ -37,12 +37,12 @@ module.exports = function(RED) { this.minTemp = Number(n.minColorTemp); this.maxTemp = Number(n.maxColorTemp); this.whiteLevel = Number(n.whiteLevel); + this.latitude = Number(n.latitude)||0.0; + this.longitude = Number(n.longitude)||0.0; this.itemState = this.context().get("itemState") || "OFF"; this.colorTemp = this.minTemp; - this.log("Read config:" + n); - var node = this; var msg = {}; @@ -55,8 +55,9 @@ module.exports = function(RED) { { this.dateTime = msg.payload; this.log("Received dt:" + this.dateTime); + - var positionResult = SunCalc.getPosition(this.dateTime, 51.8926122, 5.8764425); + var positionResult = SunCalc.getPosition(this.dateTime, this.latitude, this.longitude); this.log("Sun position:" + positionResult.altitude); var fraction = positionResult.altitude * 2.0 / Math.PI; diff --git a/package-lock.json b/package-lock.json index c8574a1..ee6b0a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,9 +36,9 @@ } }, "ajv": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.3.tgz", - "integrity": "sha512-LqZ9wY+fx3UMiiPd741yB2pj3hhil+hQc8taf4o2QGRFpWgZ2V5C8HA165DY9sS3fJwsk7uT7ZlFEyC3Ig3lLg==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", + "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", @@ -48,9 +48,9 @@ } }, "append-field": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/append-field/-/append-field-0.1.0.tgz", - "integrity": "sha1-bdxY+gg8e8VF08WZWygwzCNm1Eo=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY=", "dev": true }, "argparse": { @@ -126,12 +126,20 @@ "dev": true }, "basic-auth": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", - "integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", "dev": true, "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "bcrypt": { @@ -997,9 +1005,9 @@ "dev": true }, "cron": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/cron/-/cron-1.4.1.tgz", - "integrity": "sha512-HlglwQUNh6bhgfoDR6aEzyHN2T4bc0XhxJxkNPp+Ry7lK7Noby94pHcngYf634+MtxplwZm8okFgNe+R9PGDjg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/cron/-/cron-1.5.0.tgz", + "integrity": "sha512-j7zMFLrcSta53xqOvETUt8ge+PM14GtF47gEGJJeVlM6qP24/eWHSgtiWiEiKBR2sHS8xZaBQZq4D7vFXg8dcQ==", "dev": true, "requires": { "moment-timezone": "^0.5.x" @@ -1018,9 +1026,9 @@ } }, "css-what": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.0.tgz", - "integrity": "sha1-lGfQMsOM+u+58teVASUwYvh/ob0=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.2.tgz", + "integrity": "sha512-wan8dMWQ0GUeF7DGEPVjhHemVW/vy6xUYmFzRY8RYqgA0JtXC9rJmbScBjqSu6dg9q0lwPQy6ZAmJVr3PPTvqQ==", "dev": true }, "d": { @@ -1135,9 +1143,9 @@ } }, "domelementtype": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", - "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.2.1.tgz", + "integrity": "sha512-SQVCLFS2E7G5CRCMdn6K9bIhRj1bS6QBWZfF0TUPh4V/BbqrQ619IdSS3/izn0FZ+9l+uODzaZjb08fjOfablA==", "dev": true }, "domhandler": { @@ -1212,9 +1220,9 @@ } }, "entities": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", - "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", "dev": true }, "error-ex": { @@ -1335,14 +1343,14 @@ } }, "express": { - "version": "4.16.3", - "resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz", - "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", + "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", "dev": true, "requires": { "accepts": "~1.3.5", "array-flatten": "1.1.1", - "body-parser": "1.18.2", + "body-parser": "1.18.3", "content-disposition": "0.5.2", "content-type": "~1.0.4", "cookie": "0.3.1", @@ -1359,10 +1367,10 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.2", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.3", - "qs": "6.5.1", + "proxy-addr": "~2.0.4", + "qs": "6.5.2", "range-parser": "~1.2.0", - "safe-buffer": "5.1.1", + "safe-buffer": "5.1.2", "send": "0.16.2", "serve-static": "1.13.2", "setprototypeof": "1.1.0", @@ -1372,74 +1380,12 @@ "vary": "~1.1.2" }, "dependencies": { - "body-parser": { - "version": "1.18.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", - "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", - "dev": true, - "requires": { - "bytes": "3.0.0", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "~1.1.1", - "http-errors": "~1.6.2", - "iconv-lite": "0.4.19", - "on-finished": "~2.3.0", - "qs": "6.5.1", - "raw-body": "2.3.2", - "type-is": "~1.6.15" - } - }, - "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", - "dev": true - }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, - "raw-body": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", - "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", - "dev": true, - "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.2", - "iconv-lite": "0.4.19", - "unpipe": "1.0.0" - }, - "dependencies": { - "depd": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", - "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=", - "dev": true - }, - "http-errors": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", - "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", - "dev": true, - "requires": { - "depd": "1.1.1", - "inherits": "2.0.3", - "setprototypeof": "1.0.3", - "statuses": ">= 1.3.1 < 2" - } - }, - "setprototypeof": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", - "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=", - "dev": true - } - } - }, "statuses": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", @@ -1762,9 +1708,9 @@ "dev": true }, "htmlparser2": { - "version": "3.9.2", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.9.2.tgz", - "integrity": "sha1-G9+HrMoPP55T+k/M6w9LTLsAszg=", + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.0.tgz", + "integrity": "sha512-J1nEUGv+MkXS0weHNWVKJJ+UrLfePxRWpN3C9bEi9fLxL2+ggW94DQvgYVXsaT30PGwYRIZKNZXuyMhp3Di4bQ==", "dev": true, "requires": { "domelementtype": "^1.3.0", @@ -1772,7 +1718,26 @@ "domutils": "^1.5.1", "entities": "^1.1.1", "inherits": "^2.0.1", - "readable-stream": "^2.0.2" + "readable-stream": "^3.0.6" + }, + "dependencies": { + "domelementtype": { + "version": "1.3.0", + "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", + "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", + "dev": true + }, + "readable-stream": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.0.6.tgz", + "integrity": "sha512-9E1oLoOWfhSXHGv6QlwXJim7uNzd9EVlWK+21tCU9Ju/kR0/p2AZYPz4qSchgO8PlLIH4FpZYfzwS+rEksZjIg==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } } }, "http-errors": { @@ -2418,9 +2383,9 @@ "dev": true }, "moment-timezone": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.21.tgz", - "integrity": "sha512-j96bAh4otsgj3lKydm3K7kdtA3iKf2m6MY2iSYCzCm5a1zmHo1g+aK3068dDEeocLZQIS9kU8bsdQHLqEvgW0A==", + "version": "0.5.23", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.23.tgz", + "integrity": "sha512-WHFH85DkCfiNMDX5D3X7hpNH3/PUhjTGcD0U1SgfBGZxJ3qUmJh5FdvaFjcClxOvB3rzdfj4oRffbI38jEnC1w==", "dev": true, "requires": { "moment": ">= 2.9.0" @@ -2473,27 +2438,19 @@ "dev": true }, "multer": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/multer/-/multer-1.3.1.tgz", - "integrity": "sha512-JHdEoxkA/5NgZRo91RNn4UT+HdcJV9XUo01DTkKC7vo1erNIngtuaw9Y0WI8RdTlyi+wMIbunflhghzVLuGJyw==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.1.tgz", + "integrity": "sha512-zzOLNRxzszwd+61JFuAo0fxdQfvku12aNJgnla0AQ+hHxFmfc/B7jBVuPr5Rmvu46Jze/iJrFpSOsD7afO8SDw==", "dev": true, "requires": { - "append-field": "^0.1.0", + "append-field": "^1.0.0", "busboy": "^0.2.11", "concat-stream": "^1.5.2", "mkdirp": "^0.5.1", - "object-assign": "^3.0.0", + "object-assign": "^4.1.1", "on-finished": "^2.3.0", "type-is": "^1.6.4", "xtend": "^4.0.0" - }, - "dependencies": { - "object-assign": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", - "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", - "dev": true - } } }, "mustache": { @@ -2532,13 +2489,13 @@ "dev": true }, "node-red": { - "version": "0.19.4", - "resolved": "https://registry.npmjs.org/node-red/-/node-red-0.19.4.tgz", - "integrity": "sha512-BcFaU1bCAl0fsu6t3sSPXXPuvUiIKcHj3jrpV3zvVols+dp0zgM9xPX9N8D7978h402H8h2A+0DDQA1vENQIEA==", + "version": "0.19.5", + "resolved": "https://registry.npmjs.org/node-red/-/node-red-0.19.5.tgz", + "integrity": "sha512-Bwt5RYc77MqQjw9tSGFQHgfn6/3PTy0f9v4I4Nw4waJutGdxuAhdQJuPy6ouJpFt6CRI1ChmfJvC2ZBUMnaUCQ==", "dev": true, "requires": { - "ajv": "6.5.3", - "basic-auth": "2.0.0", + "ajv": "6.5.4", + "basic-auth": "2.0.1", "bcrypt": "~2.0.0", "bcryptjs": "2.4.3", "body-parser": "1.18.3", @@ -2547,9 +2504,9 @@ "cookie": "0.3.1", "cookie-parser": "1.4.3", "cors": "2.8.4", - "cron": "1.4.1", + "cron": "1.5.0", "denque": "1.3.0", - "express": "4.16.3", + "express": "4.16.4", "express-session": "1.15.6", "fs-extra": "5.0.0", "fs.notify": "0.0.4", @@ -2563,7 +2520,7 @@ "media-typer": "0.3.0", "memorystore": "1.6.0", "mqtt": "2.18.8", - "multer": "1.3.1", + "multer": "1.4.1", "mustache": "2.3.2", "node-red-node-email": "0.1.*", "node-red-node-feedparser": "^0.1.12", @@ -2577,12 +2534,20 @@ "passport-oauth2-client-password": "0.1.2", "raw-body": "2.3.3", "request": "2.88.0", - "semver": "5.5.1", + "semver": "5.6.0", "sentiment": "2.1.0", "uglify-js": "3.4.9", "when": "3.7.8", "ws": "1.1.5", "xml2js": "0.4.19" + }, + "dependencies": { + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "dev": true + } } }, "node-red-node-email": { @@ -2608,9 +2573,9 @@ } }, "node-red-node-rbe": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/node-red-node-rbe/-/node-red-node-rbe-0.2.3.tgz", - "integrity": "sha512-5+MtH9t8tX6Aw6M+SeoyGR23XplNTOln3aTQ7El9tj/606bxea4GxYyvV4ymTmuoODz3GXQlLLQVdGkFLyIdDQ==", + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/node-red-node-rbe/-/node-red-node-rbe-0.2.4.tgz", + "integrity": "sha512-ft/8/dTRGzGQ9vCnAzuBxzR+aDv4Yun/vuSKi/eI5Qj2/ZBal28L9HpWziSTWlLrMhZns8CRz7s2p84P2ee/vA==", "dev": true }, "node-red-node-test-helper": { @@ -2826,9 +2791,9 @@ } }, "node-red-node-twitter": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/node-red-node-twitter/-/node-red-node-twitter-1.1.3.tgz", - "integrity": "sha512-H4q6wfIeDkDp7ykFh4nK7vrnJa9NI3FmC2rASabup/9LEJ5XD5KXH07eqo+B3Cf3jAzJDmL7RFEFucA8C1oqCw==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/node-red-node-twitter/-/node-red-node-twitter-1.1.4.tgz", + "integrity": "sha512-mkw8HOosXHMBRdyJkio77vPx4Ls5IY26P5ZyoMWmKMkimXKTnX00DdpmNlkW+dHwMDYq1H66WzFtQhNOdEAbgA==", "dev": true, "requires": { "request": "^2.88.0", @@ -2905,9 +2870,9 @@ } }, "nth-check": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.1.tgz", - "integrity": "sha1-mSms32KPwsQQmN6rgqxYDPFJquQ=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", + "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", "dev": true, "requires": { "boolbase": "~1.0.0" @@ -3551,9 +3516,9 @@ "dev": true }, "sshpk": { - "version": "1.15.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.1.tgz", - "integrity": "sha512-mSdgNUaidk+dRU5MhYtN9zebdzF2iG0cNPWy8HG+W8y+fT1JnSkh0fzzpjOa0L7P8i1Rscz38t0h4gPcKz43xA==", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz", + "integrity": "sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA==", "dev": true, "requires": { "asn1": "~0.2.3", diff --git a/package.json b/package.json index f387883..abfed10 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ }, "devDependencies": { "mocha": "^5.2.0", - "node-red": "^0.19.4", + "node-red": "^0.19.5", "node-red-node-test-helper": "^0.1.8", "should": "^13.2.3" }, diff --git a/test/input-color-temp_spec.js b/test/daylight-rgbw_spec.js similarity index 100% rename from test/input-color-temp_spec.js rename to test/daylight-rgbw_spec.js