Successfully added tsyringe to project
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Brandon Watson 2021-12-28 14:48:02 -05:00
parent 503b4c9d59
commit 1a51e4d8c5
6 changed files with 264 additions and 224 deletions

266
package-lock.json generated
View File

@ -866,20 +866,22 @@
} }
}, },
"@homebridge/ciao": { "@homebridge/ciao": {
"version": "1.1.0", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/@homebridge/ciao/-/ciao-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@homebridge/ciao/-/ciao-1.1.3.tgz",
"integrity": "sha512-fpFUy/1PQ5eMPiTdRewoA/gnFCLBkBlNsFJpHO8/Wk/p1fQM0YLMDdyvR956CF0QdArhz2SBB3VeGmgVkOrLFw==", "integrity": "sha512-p9WgcSYUj3rtC1g3ywJpKxvIZXPkkv88JxbuW6idMHrUOqDMJlWIsWF0yXynQf8Z28gA0j6AJN9EnAr+hg5gNA==",
"dev": true,
"requires": { "requires": {
"debug": "^4.3.1", "debug": "^4.3.2",
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.20",
"tslib": "^2.0.3" "tslib": "^2.3.1"
}, },
"dependencies": { "dependencies": {
"debug": { "debug": {
"version": "4.3.1", "version": "4.3.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==",
"dev": true,
"requires": { "requires": {
"ms": "2.1.2" "ms": "2.1.2"
} }
@ -887,12 +889,14 @@
"fast-deep-equal": { "fast-deep-equal": {
"version": "3.1.3", "version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true
}, },
"tslib": { "tslib": {
"version": "2.0.3", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==" "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
} }
} }
}, },
@ -995,20 +999,22 @@
} }
}, },
"browserslist": { "browserslist": {
"version": "4.12.0", "version": "4.19.1",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.12.0.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz",
"integrity": "sha512-UH2GkcEDSI0k/lRkuDSzFl9ZZ87skSy9w2XAn1MsZnL+4c4rqbBd3e82UWHbYDpztABrPBhZsTEeuxVfHppqDg==", "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==",
"requires": { "requires": {
"caniuse-lite": "^1.0.30001043", "caniuse-lite": "^1.0.30001286",
"electron-to-chromium": "^1.3.413", "electron-to-chromium": "^1.4.17",
"node-releases": "^1.1.53", "escalade": "^3.1.1",
"pkg-up": "^2.0.0" "node-releases": "^2.0.1",
"picocolors": "^1.0.0"
} }
}, },
"buffer-from": { "buffer-from": {
"version": "1.1.1", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"dev": true
}, },
"builtin-modules": { "builtin-modules": {
"version": "1.1.1", "version": "1.1.1",
@ -1017,9 +1023,9 @@
"dev": true "dev": true
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001048", "version": "1.0.30001294",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001048.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001294.tgz",
"integrity": "sha512-g1iSHKVxornw0K8LG9LLdf+Fxnv7T1Z+mMsf0/YYLclQX4Cd522Ap0Lrw6NFqHgezit78dtyWxzlV2Xfc7vgRg==" "integrity": "sha512-LiMlrs1nSKZ8qkNhpUf5KD0Al1KCBE3zaT7OLOwEkagXMEDij98SiOovn9wxVGQpklk9vVC/pUSqgYmkmKOS8g=="
}, },
"caseless": { "caseless": {
"version": "0.12.0", "version": "0.12.0",
@ -1065,7 +1071,8 @@
"commander": { "commander": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz",
"integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==" "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==",
"dev": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
@ -1128,9 +1135,10 @@
} }
}, },
"decimal.js": { "decimal.js": {
"version": "10.2.1", "version": "10.3.1",
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.1.tgz", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz",
"integrity": "sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw==" "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==",
"dev": true
}, },
"define-properties": { "define-properties": {
"version": "1.1.3", "version": "1.1.3",
@ -1161,9 +1169,9 @@
} }
}, },
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.3.427", "version": "1.4.29",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.427.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.29.tgz",
"integrity": "sha512-/rG5G7Opcw68/Yrb4qYkz07h3bESVRJjUl4X/FrKLXzoUJleKm6D7K7rTTz8V5LUWnd+BbTOyxJX2XprRqHD8A==" "integrity": "sha512-N2Jbwxo5Rum8G2YXeUxycs1sv4Qme/ry71HG73bv8BvZl+I/4JtRgK/En+ST/Wh/yF1fqvVCY4jZBgMxnhjtBA=="
}, },
"es-abstract": { "es-abstract": {
"version": "1.17.5", "version": "1.17.5",
@ -1222,6 +1230,11 @@
"ext": "^1.1.2" "ext": "^1.1.2"
} }
}, },
"escalade": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw=="
},
"escape-string-regexp": { "escape-string-regexp": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
@ -1282,15 +1295,8 @@
"fast-srp-hap": { "fast-srp-hap": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/fast-srp-hap/-/fast-srp-hap-2.0.2.tgz", "resolved": "https://registry.npmjs.org/fast-srp-hap/-/fast-srp-hap-2.0.2.tgz",
"integrity": "sha512-wABhZRrFhlovqJQ1HygOUB4R6WZW2hmlpvVYh2dVCy8BPLabDrB/Tu6XI3B4QfmhtHk8s1OeiFqJHY7FBsphug==" "integrity": "sha512-wABhZRrFhlovqJQ1HygOUB4R6WZW2hmlpvVYh2dVCy8BPLabDrB/Tu6XI3B4QfmhtHk8s1OeiFqJHY7FBsphug==",
}, "dev": true
"find-up": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
"integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
"requires": {
"locate-path": "^2.0.0"
}
}, },
"forever-agent": { "forever-agent": {
"version": "0.6.1", "version": "0.6.1",
@ -1319,9 +1325,10 @@
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
}, },
"futoin-hkdf": { "futoin-hkdf": {
"version": "1.3.2", "version": "1.3.3",
"resolved": "https://registry.npmjs.org/futoin-hkdf/-/futoin-hkdf-1.3.2.tgz", "resolved": "https://registry.npmjs.org/futoin-hkdf/-/futoin-hkdf-1.3.3.tgz",
"integrity": "sha512-3EVi3ETTyJg5PSXlxLCaUVVn0pSbDf62L3Gwxne7Uq+d8adOSNWQAad4gg7WToHkcgnCJb3Wlb1P8r4Evj4GPw==" "integrity": "sha512-oR75fYk3B3X9/B02Y6vusrBKucrpC6VjxhRL+C6B7FwUpuSRHbhBNG3AZbcE/xPyJmEQWsyqUFp3VeNNbA3S7A==",
"dev": true
}, },
"gensync": { "gensync": {
"version": "1.0.0-beta.1", "version": "1.0.0-beta.1",
@ -1356,11 +1363,12 @@
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA=="
}, },
"hap-nodejs": { "hap-nodejs": {
"version": "0.8.3", "version": "0.8.5",
"resolved": "https://registry.npmjs.org/hap-nodejs/-/hap-nodejs-0.8.3.tgz", "resolved": "https://registry.npmjs.org/hap-nodejs/-/hap-nodejs-0.8.5.tgz",
"integrity": "sha512-1bX0UPmIfthYgF43M0rhNsyLayPVXAPvqgwUBfTUNSw4XuesepfbZFnhT8eYZqqClQorKaZr6FeHWw785FQ1Tg==", "integrity": "sha512-4OnIc3oYXHSmafsuBuY1sBbQaMy8n2uRnEPS9ZnD032cOvaVz2IZA3/rE5LEHsxgDvo+oiLxcdqXz0ho38Odxw==",
"dev": true,
"requires": { "requires": {
"@homebridge/ciao": "~1.1.0", "@homebridge/ciao": "~1.1.2",
"debug": "^4.1.1", "debug": "^4.1.1",
"decimal.js": "^10.2.0", "decimal.js": "^10.2.0",
"fast-srp-hap": "2.0.2", "fast-srp-hap": "2.0.2",
@ -1373,7 +1381,8 @@
"tweetnacl": { "tweetnacl": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==",
"dev": true
} }
} }
}, },
@ -1421,13 +1430,14 @@
"integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==" "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg=="
}, },
"homebridge": { "homebridge": {
"version": "1.2.4", "version": "1.2.5",
"resolved": "https://registry.npmjs.org/homebridge/-/homebridge-1.2.4.tgz", "resolved": "https://registry.npmjs.org/homebridge/-/homebridge-1.2.5.tgz",
"integrity": "sha512-uyhLgJumhivAQrauoH5EfxKC2hcX2r8fC2ckAScBx3M7/+XuobHVNYF7yNND69mlg+Jd/KBfaF5zS3ckVl807g==", "integrity": "sha512-tiJi31Ereo75pPhXz9DVLM8lXW8bopXo5aEmBU8elwvfkyTXlGc2dToz9dnc+Vt8ls7jsQAIEl6MkGWrQ7XqtA==",
"dev": true,
"requires": { "requires": {
"chalk": "^4.1.0", "chalk": "^4.1.0",
"commander": "5.1.0", "commander": "5.1.0",
"hap-nodejs": "~0.8.3", "hap-nodejs": "~0.8.5",
"node-persist": "^0.0.11", "node-persist": "^0.0.11",
"qrcode-terminal": "^0.12.0", "qrcode-terminal": "^0.12.0",
"semver": "^7.3.2", "semver": "^7.3.2",
@ -1438,14 +1448,16 @@
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"requires": { "requires": {
"color-convert": "^2.0.1" "color-convert": "^2.0.1"
} }
}, },
"chalk": { "chalk": {
"version": "4.1.0", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"requires": { "requires": {
"ansi-styles": "^4.1.0", "ansi-styles": "^4.1.0",
"supports-color": "^7.1.0" "supports-color": "^7.1.0"
@ -1455,6 +1467,7 @@
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"requires": { "requires": {
"color-name": "~1.1.4" "color-name": "~1.1.4"
} }
@ -1462,17 +1475,20 @@
"color-name": { "color-name": {
"version": "1.1.4", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
}, },
"has-flag": { "has-flag": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
}, },
"semver": { "semver": {
"version": "7.3.4", "version": "7.3.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
"dev": true,
"requires": { "requires": {
"lru-cache": "^6.0.0" "lru-cache": "^6.0.0"
} }
@ -1481,6 +1497,7 @@
"version": "7.2.0", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": { "requires": {
"has-flag": "^4.0.0" "has-flag": "^4.0.0"
} }
@ -1524,7 +1541,8 @@
"ip": { "ip": {
"version": "1.1.5", "version": "1.1.5",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
"integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=",
"dev": true
}, },
"is-callable": { "is-callable": {
"version": "1.1.5", "version": "1.1.5",
@ -1588,9 +1606,9 @@
"integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA=="
}, },
"json-schema": { "json-schema": {
"version": "0.2.3", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="
}, },
"json-schema-traverse": { "json-schema-traverse": {
"version": "0.4.1", "version": "0.4.1",
@ -1611,13 +1629,13 @@
} }
}, },
"jsprim": { "jsprim": {
"version": "1.4.1", "version": "1.4.2",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
"integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==",
"requires": { "requires": {
"assert-plus": "1.0.0", "assert-plus": "1.0.0",
"extsprintf": "1.3.0", "extsprintf": "1.3.0",
"json-schema": "0.2.3", "json-schema": "0.4.0",
"verror": "1.10.0" "verror": "1.10.0"
} }
}, },
@ -1634,19 +1652,10 @@
"leven": "^3.1.0" "leven": "^3.1.0"
} }
}, },
"locate-path": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
"integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
"requires": {
"p-locate": "^2.0.0",
"path-exists": "^3.0.0"
}
},
"lodash": { "lodash": {
"version": "4.17.15", "version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
}, },
"loose-envify": { "loose-envify": {
"version": "1.4.0", "version": "1.4.0",
@ -1660,6 +1669,7 @@
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"requires": { "requires": {
"yallist": "^4.0.0" "yallist": "^4.0.0"
} }
@ -1695,6 +1705,7 @@
"version": "0.5.5", "version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dev": true,
"requires": { "requires": {
"minimist": "^1.2.5" "minimist": "^1.2.5"
} }
@ -1718,15 +1729,16 @@
"version": "0.0.11", "version": "0.0.11",
"resolved": "https://registry.npmjs.org/node-persist/-/node-persist-0.0.11.tgz", "resolved": "https://registry.npmjs.org/node-persist/-/node-persist-0.0.11.tgz",
"integrity": "sha1-1m66Pr72IPB5Uw+nsTB2qQZmWHQ=", "integrity": "sha1-1m66Pr72IPB5Uw+nsTB2qQZmWHQ=",
"dev": true,
"requires": { "requires": {
"mkdirp": "~0.5.1", "mkdirp": "~0.5.1",
"q": "~1.1.1" "q": "~1.1.1"
} }
}, },
"node-releases": { "node-releases": {
"version": "1.1.53", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.53.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.1.tgz",
"integrity": "sha512-wp8zyQVwef2hpZ/dJH7SfSrIPD6YoJz6BDQDpGEkcA0s3LpAQoxBIYmfIq6QAhC1DhwsyCgTaTTcONwX8qzCuQ==" "integrity": "sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA=="
}, },
"oauth-sign": { "oauth-sign": {
"version": "0.9.0", "version": "0.9.0",
@ -1763,32 +1775,6 @@
"wrappy": "1" "wrappy": "1"
} }
}, },
"p-limit": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
"integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
"requires": {
"p-try": "^1.0.0"
}
},
"p-locate": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
"integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
"requires": {
"p-limit": "^1.1.0"
}
},
"p-try": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M="
},
"path-exists": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
"integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU="
},
"path-is-absolute": { "path-is-absolute": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
@ -1796,22 +1782,19 @@
"dev": true "dev": true
}, },
"path-parse": { "path-parse": {
"version": "1.0.6", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
}, },
"performance-now": { "performance-now": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
}, },
"pkg-up": { "picocolors": {
"version": "2.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-2.0.0.tgz", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha1-yBmscoBZpGHKscOImivjxJoATX8=", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
"requires": {
"find-up": "^2.1.0"
}
}, },
"private": { "private": {
"version": "0.1.8", "version": "0.1.8",
@ -1846,18 +1829,25 @@
"q": { "q": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/q/-/q-1.1.2.tgz", "resolved": "https://registry.npmjs.org/q/-/q-1.1.2.tgz",
"integrity": "sha1-Y1fikSBnAdmfGXq4TlforRlvKok=" "integrity": "sha1-Y1fikSBnAdmfGXq4TlforRlvKok=",
"dev": true
}, },
"qrcode-terminal": { "qrcode-terminal": {
"version": "0.12.0", "version": "0.12.0",
"resolved": "https://registry.npmjs.org/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz", "resolved": "https://registry.npmjs.org/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz",
"integrity": "sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ==" "integrity": "sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ==",
"dev": true
}, },
"qs": { "qs": {
"version": "6.5.2", "version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
}, },
"reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
},
"regenerate": { "regenerate": {
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz",
@ -2012,9 +2002,10 @@
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
}, },
"source-map-support": { "source-map-support": {
"version": "0.5.19", "version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"dev": true,
"requires": { "requires": {
"buffer-from": "^1.0.0", "buffer-from": "^1.0.0",
"source-map": "^0.6.0" "source-map": "^0.6.0"
@ -2023,7 +2014,8 @@
"source-map": { "source-map": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
} }
} }
}, },
@ -2117,8 +2109,7 @@
"tslib": { "tslib": {
"version": "1.11.1", "version": "1.11.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz",
"integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==", "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA=="
"dev": true
}, },
"tslint": { "tslint": {
"version": "5.20.1", "version": "5.20.1",
@ -2158,6 +2149,14 @@
"tslib": "^1.8.1" "tslib": "^1.8.1"
} }
}, },
"tsyringe": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/tsyringe/-/tsyringe-4.6.0.tgz",
"integrity": "sha512-BMQAZamSfEmIQzH8WJeRu1yZGQbPSDuI9g+yEiKZFIcO46GPZuMOC2d0b52cVBdw1d++06JnDSIIZvEnogMdAw==",
"requires": {
"tslib": "^1.9.3"
}
},
"tunnel-agent": { "tunnel-agent": {
"version": "0.6.0", "version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
@ -2185,9 +2184,9 @@
} }
}, },
"typescript": { "typescript": {
"version": "3.8.3", "version": "3.9.10",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz",
"integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
"dev": true "dev": true
}, },
"unicode-canonical-property-names-ecmascript": { "unicode-canonical-property-names-ecmascript": {
@ -2288,7 +2287,8 @@
"yallist": { "yallist": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
} }
} }
} }

View File

@ -28,10 +28,11 @@
"node": ">=7.6.0" "node": ">=7.6.0"
}, },
"devDependencies": { "devDependencies": {
"homebridge": "^1.2.5",
"rollup-plugin-typescript": "^1.0.1", "rollup-plugin-typescript": "^1.0.1",
"tslib": "^1.10.0", "tslib": "^1.10.0",
"tslint": "^5.17.0", "tslint": "^5.17.0",
"typescript": "^3.5.1" "typescript": "^3.9.10"
}, },
"dependencies": { "dependencies": {
"@babel/core": "^7.4.5", "@babel/core": "^7.4.5",
@ -39,7 +40,8 @@
"@babel/preset-typescript": "^7.3.3", "@babel/preset-typescript": "^7.3.3",
"@types/node": "^12.0.7", "@types/node": "^12.0.7",
"harmony-websocket": "^1.1.0", "harmony-websocket": "^1.1.0",
"homebridge": "^1.1.16", "reflect-metadata": "^0.1.13",
"request": "^2.88.0" "request": "^2.88.0",
"tsyringe": "^4.6.0"
} }
} }

View File

@ -7,6 +7,9 @@ import { IHub } from "../Models/Config/IHub";
import { IDeviceConfig } from "../Models/Config/IDeviceConfig"; import { IDeviceConfig } from "../Models/Config/IDeviceConfig";
import { HarmonyDevice } from "../Models/HarmonyDevice"; import { HarmonyDevice } from "../Models/HarmonyDevice";
import { HarmonyHub } from "../Models/HarmonyHub"; import { HarmonyHub } from "../Models/HarmonyHub";
import { IConfig } from "../Models/Config";
import { inject, injectable } from "tsyringe";
import { Logger, Logging } from "homebridge";
const Harmony = require("harmony-websocket"); const Harmony = require("harmony-websocket");
@ -21,8 +24,8 @@ interface IHarmonyDataProviderProps {
matrix: IMatrix; matrix: IMatrix;
} }
@injectable()
class HarmonyDataProvider extends EventEmitter { class HarmonyDataProvider extends EventEmitter {
private _log: any;
private _hubsByDevice: { [deviceName: string]: string } = {}; private _hubsByDevice: { [deviceName: string]: string } = {};
private _hubs: { [hubName: string]: HarmonyHub } = {}; private _hubs: { [hubName: string]: HarmonyHub } = {};
// private _devicesByHub: { [hubName: string]: { [deviceName: string]: HarmonyDevice } } = {}; // private _devicesByHub: { [hubName: string]: { [deviceName: string]: HarmonyDevice } } = {};
@ -32,16 +35,18 @@ class HarmonyDataProvider extends EventEmitter {
private _matrix: IMatrix; private _matrix: IMatrix;
constructor(props: IHarmonyDataProviderProps) { constructor(
@inject("IConfig") private _config: IConfig,
@inject("log") private _log: Logging
) {
super(); super();
this._log = props.log; this._matrix = _config.Matrix;
this._matrix = props.matrix; _config.Devices.forEach((deviceConfig: IDeviceConfig) => {
props.deviceConfigs.forEach((deviceConfig: IDeviceConfig) => {
this._hubsByDevice[deviceConfig.Name] = deviceConfig.Hub; this._hubsByDevice[deviceConfig.Name] = deviceConfig.Hub;
}); });
// this._deviceConfigs = props.deviceConfigs; // this._deviceConfigs = props.deviceConfigs;
this.connect(props.hubs); this.connect(_config.Hubs);
} }
// public get devicesByHub(): { [hubName: string]: { [deviceName: string]: HarmonyDevice } } { // public get devicesByHub(): { [hubName: string]: { [deviceName: string]: HarmonyDevice } } {
@ -104,7 +109,7 @@ class HarmonyDataProvider extends EventEmitter {
controlUnitName: string, controlUnitName: string,
activity: IActivity activity: IActivity
) => { ) => {
this._log( this._log.info(
`Starting activity ${activity.DisplayName} for controlUnit: ${controlUnitName}` `Starting activity ${activity.DisplayName} for controlUnit: ${controlUnitName}`
); );
let lastActivity: IActivity | undefined = undefined; let lastActivity: IActivity | undefined = undefined;
@ -127,7 +132,7 @@ class HarmonyDataProvider extends EventEmitter {
devicesToTurnOn.map(async (device: HarmonyDevice) => { devicesToTurnOn.map(async (device: HarmonyDevice) => {
if (device && device.name) { if (device && device.name) {
if (!device.on) { if (!device.on) {
this._log(`Turning on device ${device.name}`); this._log.info(`Turning on device ${device.name}`);
await device.powerOn(); await device.powerOn();
} }
} }
@ -175,11 +180,12 @@ class HarmonyDataProvider extends EventEmitter {
//Build potential list of devices to turn off //Build potential list of devices to turn off
if (lastActivity) { if (lastActivity) {
let devicesToTurnOff: Array<HarmonyDevice> = lastActivity.DeviceSetupList.map( let devicesToTurnOff: Array<HarmonyDevice> =
(value: IDeviceSetupItem): HarmonyDevice => { lastActivity.DeviceSetupList.map(
return this.getDeviceFromName(value.DeviceName); (value: IDeviceSetupItem): HarmonyDevice => {
} return this.getDeviceFromName(value.DeviceName);
); }
);
//remove devices that will be used for next activity from list //remove devices that will be used for next activity from list
//delete array[index] is stupid because it just nulls out the index. But now i have to deal with nulls //delete array[index] is stupid because it just nulls out the index. But now i have to deal with nulls
@ -201,7 +207,7 @@ class HarmonyDataProvider extends EventEmitter {
controlUnitName controlUnitName
); );
this._log( this._log.info(
`Sanatized devices to turn off: ${JSON.stringify( `Sanatized devices to turn off: ${JSON.stringify(
devicesToTurnOff.map((e) => (e ? e.name : "")) devicesToTurnOff.map((e) => (e ? e.name : ""))
)}` )}`
@ -212,7 +218,7 @@ class HarmonyDataProvider extends EventEmitter {
devicesToTurnOff.map(async (device: HarmonyDevice) => { devicesToTurnOff.map(async (device: HarmonyDevice) => {
if (device) { if (device) {
if (device.on) { if (device.on) {
this._log(`Turning off device ${device.name}`); this._log.info(`Turning off device ${device.name}`);
await device.powerOff(); await device.powerOff();
} }
} }
@ -323,11 +329,10 @@ class HarmonyDataProvider extends EventEmitter {
public getDeviceFromName(deviceName: string): HarmonyDevice { public getDeviceFromName(deviceName: string): HarmonyDevice {
let device: HarmonyDevice | undefined; let device: HarmonyDevice | undefined;
try { try {
device = this._hubs[this._hubsByDevice[deviceName]].getDeviceByName( device =
deviceName this._hubs[this._hubsByDevice[deviceName]].getDeviceByName(deviceName);
);
} catch (err) { } catch (err) {
this._log(`Error retrieving device from hub: ${err}`); this._log.info(`Error retrieving device from hub: ${err}`);
} }
return device!; return device!;
@ -350,19 +355,17 @@ class HarmonyDataProvider extends EventEmitter {
private connect = async (hubs: Array<IHub>) => { private connect = async (hubs: Array<IHub>) => {
let readyCount = 0; let readyCount = 0;
await Promise.all( await Promise.all(
hubs.map( hubs.map(async (hub: IHub): Promise<void> => {
async (hub: IHub): Promise<void> => { const newHarmonyHub = new HarmonyHub(hub.Name, hub.Ip, this._log.info);
const newHarmonyHub = new HarmonyHub(hub.Name, hub.Ip, this._log); this._hubs[hub.Name] = newHarmonyHub;
this._hubs[hub.Name] = newHarmonyHub; newHarmonyHub.on("Ready", () => {
newHarmonyHub.on("Ready", () => { readyCount++;
readyCount++; if (readyCount === Object.keys(this._hubs).length) {
if (readyCount === Object.keys(this._hubs).length) { this.emit("Ready");
this.emit("Ready"); }
} });
}); await newHarmonyHub.initialize();
await newHarmonyHub.initialize(); })
}
)
); );
}; };

View File

@ -1,3 +1,4 @@
import "reflect-metadata";
import { import {
API, API,
Characteristic, Characteristic,
@ -12,9 +13,8 @@ import { Sequence } from "./Accessories/Sequence";
import HarmonyDataProvider from "./DataProviders/HarmonyDataProvider"; import HarmonyDataProvider from "./DataProviders/HarmonyDataProvider";
import { IConfig, IControlUnit, IDeviceButton } from "./Models/Config"; import { IConfig, IControlUnit, IDeviceButton } from "./Models/Config";
import { ISequence } from "./Models/Config/ISequence"; import { ISequence } from "./Models/Config/ISequence";
import { HarmonyDevice } from "./Models/HarmonyDevice";
import { HarmonyHub } from "./Models/HarmonyHub";
import { PLATFORM_NAME, PLUGIN_NAME } from "./settings"; import { PLATFORM_NAME, PLUGIN_NAME } from "./settings";
import { container } from "tsyringe";
export class Platform implements DynamicPlatformPlugin { export class Platform implements DynamicPlatformPlugin {
constructor( constructor(
@ -23,57 +23,58 @@ export class Platform implements DynamicPlatformPlugin {
public readonly api: API public readonly api: API
) { ) {
this.log.debug("Finished initializing platform:", config.name); this.log.debug("Finished initializing platform:", config.name);
this.config = config as unknown as IConfig; this.config = config as unknown as IConfig;
this.register();
//construct data provider //construct data provider
const dataProvider = new HarmonyDataProvider({ // const dataProvider = new HarmonyDataProvider({
hubs: this.config.Hubs, // hubs: this.config.Hubs,
deviceConfigs: this.config.Devices, // deviceConfigs: this.config.Devices,
matrix: this.config.Matrix, // matrix: this.config.Matrix,
log: this.log, // log: this.log,
}); // });
let didFinishLaunching = false; let didFinishLaunching = false;
this.api.on("didFinishLaunching", async () => { this.api.on("didFinishLaunching", async () => {
log.debug("Executed didFinishLaunching callback"); log.debug("Executed didFinishLaunching callback");
this.discoverControlUnitAccessories();
this.discoverDeviceButtonAccessories();
this.discoverSequenceAccessories();
this.pruneAccessories();
didFinishLaunching = true; didFinishLaunching = true;
}); });
this.dataProvider = null; // this.dataProvider = null;
if (this.config) { if (this.config) {
//construct data provider //construct data provider
this.dataProvider = new HarmonyDataProvider({ // this.dataProvider = new HarmonyDataProvider({
hubs: this.config.Hubs, // hubs: this.config.Hubs,
deviceConfigs: this.config.Devices, // deviceConfigs: this.config.Devices,
matrix: this.config.Matrix, // matrix: this.config.Matrix,
log: this.log, // log: this.log,
}); // });
//Emit devices if requested //Emit devices if requested
// this.dataProvider.on("Ready", () => {
this.dataProvider.on("Ready", () => { // this.log.info("All hubs connected");
this.log.info("All hubs connected"); // this.discoverControlUnitAccessories(dataProvider);
this.discoverControlUnitAccessories(dataProvider); // this.discoverDeviceButtonAccessories(dataProvider);
this.discoverDeviceButtonAccessories(dataProvider); // this.discoverSequenceAccessories(dataProvider);
this.discoverSequenceAccessories(dataProvider); // this.pruneAccessories();
this.pruneAccessories(); // if (this.config.EmitDevicesOnStartup) {
// const hubs = this.dataProvider!.hubs;
if (this.config.EmitDevicesOnStartup) { // Object.values(hubs).forEach((hub: HarmonyHub) => {
const hubs = this.dataProvider!.hubs; // const deviceDictionary = hub.devices;
Object.values(hubs).forEach((hub: HarmonyHub) => { // this.log.info(`${hub.hubName}`);
const deviceDictionary = hub.devices; // Object.values(deviceDictionary).forEach((device: HarmonyDevice) => {
this.log.info(`${hub.hubName}`); // this.log.info(` ${device.name} : ${device.id}`);
// Object.keys(device.commands).forEach((command: string) => {
Object.values(deviceDictionary).forEach((device: HarmonyDevice) => { // this.log.info(` ${command}`);
this.log.info(` ${device.name} : ${device.id}`); // });
Object.keys(device.commands).forEach((command: string) => { // });
this.log.info(` ${command}`); // });
}); // }
}); // });
});
}
});
} }
} }
@ -84,15 +85,12 @@ export class Platform implements DynamicPlatformPlugin {
// this is used to track restored cached accessories // this is used to track restored cached accessories
public readonly accessories: PlatformAccessory[] = []; public readonly accessories: PlatformAccessory[] = [];
public config: IConfig; public config: IConfig;
public dataProvider: HarmonyDataProvider | null;
/** /**
* Discover new control unit accessories * Discover new control unit accessories
* @param dataProvider * @param dataProvider
*/ */
private discoverControlUnitAccessories( private discoverControlUnitAccessories(): void {
dataProvider: HarmonyDataProvider
): void {
this.config.ControlUnits.forEach((unit: IControlUnit) => { this.config.ControlUnits.forEach((unit: IControlUnit) => {
const uuid = this.api.hap.uuid.generate(unit.DisplayName); const uuid = this.api.hap.uuid.generate(unit.DisplayName);
const existingAccessory = this.accessories.find((e) => e.UUID === uuid); const existingAccessory = this.accessories.find((e) => e.UUID === uuid);
@ -103,7 +101,12 @@ export class Platform implements DynamicPlatformPlugin {
existingAccessory.displayName existingAccessory.displayName
); );
new ControlUnit(this, existingAccessory, dataProvider, unit.Activities); new ControlUnit(
this,
existingAccessory,
container.resolve(HarmonyDataProvider),
unit.Activities
);
this.api.publishExternalAccessories(PLUGIN_NAME, [existingAccessory]); this.api.publishExternalAccessories(PLUGIN_NAME, [existingAccessory]);
console.log("Publishing external accessory: " + uuid); console.log("Publishing external accessory: " + uuid);
@ -116,7 +119,12 @@ export class Platform implements DynamicPlatformPlugin {
accessory.context["DeviceName"] = unit.DisplayName; accessory.context["DeviceName"] = unit.DisplayName;
accessory.context["Type"] = typeof ControlUnit.name; accessory.context["Type"] = typeof ControlUnit.name;
new ControlUnit(this, accessory, dataProvider, unit.Activities); new ControlUnit(
this,
accessory,
container.resolve(HarmonyDataProvider),
unit.Activities
);
this.api.publishExternalAccessories(PLUGIN_NAME, [accessory]); this.api.publishExternalAccessories(PLUGIN_NAME, [accessory]);
console.log("Publishing external accessory: " + uuid); console.log("Publishing external accessory: " + uuid);
@ -128,9 +136,7 @@ export class Platform implements DynamicPlatformPlugin {
* Discover new device button accessories * Discover new device button accessories
* @param dataProvider * @param dataProvider
*/ */
private discoverDeviceButtonAccessories( private discoverDeviceButtonAccessories(): void {
dataProvider: HarmonyDataProvider
): void {
this.config.DeviceButtons.forEach((button: IDeviceButton) => { this.config.DeviceButtons.forEach((button: IDeviceButton) => {
const uuid = this.api.hap.uuid.generate(button.DisplayName); const uuid = this.api.hap.uuid.generate(button.DisplayName);
const existingAccessory = this.accessories.find((e) => e.UUID === uuid); const existingAccessory = this.accessories.find((e) => e.UUID === uuid);
@ -140,7 +146,12 @@ export class Platform implements DynamicPlatformPlugin {
existingAccessory.displayName existingAccessory.displayName
); );
new DeviceButton(this, existingAccessory, dataProvider, button); new DeviceButton(
this,
existingAccessory,
container.resolve(HarmonyDataProvider),
button
);
this.api.updatePlatformAccessories([existingAccessory]); this.api.updatePlatformAccessories([existingAccessory]);
} else { } else {
this.log.info("Adding new accessory: " + button.DisplayName); this.log.info("Adding new accessory: " + button.DisplayName);
@ -151,7 +162,12 @@ export class Platform implements DynamicPlatformPlugin {
accessory.context["DeviceName"] = button.DisplayName; accessory.context["DeviceName"] = button.DisplayName;
accessory.context["Type"] = typeof DeviceButton; accessory.context["Type"] = typeof DeviceButton;
new DeviceButton(this, accessory, dataProvider, button); new DeviceButton(
this,
accessory,
container.resolve(HarmonyDataProvider),
button
);
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [ this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [
accessory, accessory,
@ -165,7 +181,7 @@ export class Platform implements DynamicPlatformPlugin {
* Discover new sequence accessories * Discover new sequence accessories
* @param dataProvider * @param dataProvider
*/ */
private discoverSequenceAccessories(dataProvider: HarmonyDataProvider): void { private discoverSequenceAccessories(): void {
this.config.Sequences.forEach((sequence: ISequence) => { this.config.Sequences.forEach((sequence: ISequence) => {
const uuid = this.api.hap.uuid.generate(sequence.DisplayName); const uuid = this.api.hap.uuid.generate(sequence.DisplayName);
const existingAccessory = this.accessories.find((e) => e.UUID === uuid); const existingAccessory = this.accessories.find((e) => e.UUID === uuid);
@ -175,7 +191,12 @@ export class Platform implements DynamicPlatformPlugin {
existingAccessory.displayName existingAccessory.displayName
); );
new Sequence(this, existingAccessory, dataProvider, sequence); new Sequence(
this,
existingAccessory,
container.resolve(HarmonyDataProvider),
sequence
);
this.api.updatePlatformAccessories([existingAccessory]); this.api.updatePlatformAccessories([existingAccessory]);
} else { } else {
this.log.info("Adding new accessory: " + sequence.DisplayName); this.log.info("Adding new accessory: " + sequence.DisplayName);
@ -186,7 +207,12 @@ export class Platform implements DynamicPlatformPlugin {
accessory.context["DeviceName"] = sequence.DisplayName; accessory.context["DeviceName"] = sequence.DisplayName;
accessory.context["Type"] = typeof "Sequence"; accessory.context["Type"] = typeof "Sequence";
new Sequence(this, accessory, dataProvider, sequence); new Sequence(
this,
accessory,
container.resolve(HarmonyDataProvider),
sequence
);
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [ this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [
accessory, accessory,
@ -222,4 +248,11 @@ export class Platform implements DynamicPlatformPlugin {
// add the restored accessory to the accessories cache so we can track if it has already been registered // add the restored accessory to the accessories cache so we can track if it has already been registered
this.accessories.push(accessory); this.accessories.push(accessory);
} }
private register(): void {
container.register<Platform>(Platform, { useValue: this });
container.register<IConfig>("IConfig", { useValue: this.config });
container.register<Logger>("log", { useValue: this.log });
container.registerSingleton<HarmonyDataProvider>(HarmonyDataProvider);
}
} }

View File

@ -6,4 +6,4 @@ export const PLATFORM_NAME = "HarmonyHubMatrix";
/** /**
* This must match the name of your plugin as defined the package.json * This must match the name of your plugin as defined the package.json
*/ */
export const PLUGIN_NAME = "homebridge-harmony-control"; export const PLUGIN_NAME = "@watsonb8/homebridge-harmony-control";

View File

@ -6,7 +6,9 @@
"outDir": "./bin", "outDir": "./bin",
"strict": true, "strict": true,
"sourceMap": true, "sourceMap": true,
"skipLibCheck": true "skipLibCheck": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}, },
"include": ["src"], "include": ["src"],
"exclude": ["**/node_modules", "**/__tests__/*"] "exclude": ["**/node_modules", "**/__tests__/*"]