Compare commits
41 Commits
Author | SHA1 | Date | |
---|---|---|---|
4e1dce3e32 | |||
2f030fa08c | |||
|
bfba6e47d1 | ||
|
28abf136b7 | ||
|
ed652b2f76 | ||
|
0846a72931 | ||
|
f1d1da0945 | ||
|
76438d6811 | ||
|
7971fd3ec1 | ||
|
3fe902c50b | ||
|
52a259dafd | ||
|
128bb933bd | ||
|
4519edf679 | ||
|
6794d58594 | ||
|
5470b6185d | ||
|
51441a706d | ||
|
e6e3d45b5b | ||
|
c22a8a0325 | ||
|
506c170746 | ||
|
4fd9341cea | ||
|
c65853220e | ||
|
1a51e4d8c5 | ||
|
503b4c9d59 | ||
|
63cd6ce3ce | ||
|
ff1f500fa1 | ||
|
686054e9b3 | ||
|
d7e241b381 | ||
|
3a2db8397b | ||
|
f0c4cd7824 | ||
|
1d8d483e8f | ||
|
904b8c4fab | ||
|
a01ae86794 | ||
|
f28b6429c5 | ||
|
5eff708b05 | ||
|
ece54b54e7 | ||
|
6b3ea14520 | ||
|
5dc28b2409 | ||
|
cdab6327f5 | ||
|
1121dbc52c | ||
|
bc2208b5cb | ||
|
845071c274 |
41
.drone.yml
41
.drone.yml
@ -1,41 +0,0 @@
|
|||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: default
|
|
||||||
|
|
||||||
clone:
|
|
||||||
disable: true
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: clone
|
|
||||||
image: alpine/git
|
|
||||||
commands:
|
|
||||||
- git clone https://gitea.watsonlabs.net/watsonb8/homebridge-harmony-control.git .
|
|
||||||
- git checkout $DRONE_COMMIT
|
|
||||||
|
|
||||||
- name: build
|
|
||||||
image: node
|
|
||||||
commands:
|
|
||||||
- npm install
|
|
||||||
- npm run build
|
|
||||||
|
|
||||||
- name: publish
|
|
||||||
image: plugins/npm
|
|
||||||
settings:
|
|
||||||
username: admin
|
|
||||||
password:
|
|
||||||
from_secret: npm_password
|
|
||||||
email: brandon@watsonlabs.net
|
|
||||||
registry: "http://linuxhost.me:4873/"
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
notify:
|
|
||||||
image: drillster/drone-email
|
|
||||||
host: smtp.watsonlabs.net
|
|
||||||
username: srvGitea
|
|
||||||
password:
|
|
||||||
from_secret: smtp_password
|
|
||||||
from: drone@watsonlabs.net
|
|
||||||
when:
|
|
||||||
status: [failure]
|
|
82
.gitea/workflows/ci.yaml
Normal file
82
.gitea/workflows/ci.yaml
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
name: Build homebridge-harmony-control
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- run: |
|
||||||
|
npm ci
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
version:
|
||||||
|
name: Version
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.get_version.outputs.version }}
|
||||||
|
commit: ${{ steps.get_version.outputs.commit }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- id: get_version
|
||||||
|
name: Set Version
|
||||||
|
run: |
|
||||||
|
export version=`node -p "require('./package.json').version"`
|
||||||
|
export commit=`echo $GITHUB_SHA | cut -c1-5`
|
||||||
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "commit=$commit" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
publish_tagged:
|
||||||
|
name: Publish Latest
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
- version
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
- run: npm config set @watsonb8:registry https://gitea.watsonlabs.net/api/packages/watsonb8/npm/
|
||||||
|
- name: Publish
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
COMMIT: ${{ needs.version.outputs.commit }}
|
||||||
|
run: |
|
||||||
|
npm ci
|
||||||
|
npm config set -- '//gitea.watsonlabs.net/api/packages/watsonb8/npm/:_authToken' "$NPM_TOKEN"
|
||||||
|
npm version prerelease --preid="$COMMIT" --git-tag-version=false --allow-same-version=true
|
||||||
|
npm publish
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on:
|
||||||
|
- ubuntu-latest
|
||||||
|
- internal
|
||||||
|
name: Deploy
|
||||||
|
needs: publish_tagged
|
||||||
|
steps:
|
||||||
|
- name: Set up SSH key
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.ELEVATED_HOMEBRIDGE_SSH_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan -p 22 homebridge.me >> ~/.ssh/known_hosts
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install sshpass
|
||||||
|
|
||||||
|
- name: Remove old Package
|
||||||
|
run: |
|
||||||
|
sshpass -p '${{ secrets.ELEVATED_HOMEBRIDGE_PASSWORD }}' ssh -v -o StrictHostKeyChecking=no ${{ secrets.ELEVATED_HOMEBRIDGE_USER }}@${{ secrets.HOMEBRIDGE_HOST }} <<'ENDSSH'
|
||||||
|
rm -r /home/${{ secrets.HOMEBRIDGE_USER }}/.npm-global/lib/node_modules/@watsonb8/homebridge-harmony-control
|
||||||
|
ENDSSH
|
||||||
|
- name: Deploy
|
||||||
|
run: |
|
||||||
|
sshpass -p '${{ secrets.ELEVATED_HOMEBRIDGE_PASSWORD }}' ssh -v -o StrictHostKeyChecking=no ${{ secrets.ELEVATED_HOMEBRIDGE_USER }}@${{ secrets.HOMEBRIDGE_HOST }} <<'ENDSSH'
|
||||||
|
npm install -g @watsonb8/homebridge-harmony-control
|
||||||
|
ENDSSH
|
22
deploy.sh
22
deploy.sh
@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
remote_user="bmw"
|
|
||||||
remote_server="linuxhost.me"
|
|
||||||
deploy_location="/home/bmw/homebridge-harmony-control"
|
|
||||||
homebridge_location="/var/lib/homebridge/"
|
|
||||||
|
|
||||||
#build
|
|
||||||
tsc --build
|
|
||||||
#copy files to remote machine
|
|
||||||
scp -r bin $remote_user@$remote_server:$deploy_location
|
|
||||||
scp package.json $remote_user@$remote_server:$deploy_location
|
|
||||||
|
|
||||||
#install package
|
|
||||||
ssh -t $remote_user@$remote_server "sudo npm install -g --unsafe-perm $deploy_location"
|
|
||||||
|
|
||||||
#restart service
|
|
||||||
ssh -t
|
|
||||||
ssh -t $remote_user@$remote_server "sudo systemctl restart homebridge.service"
|
|
||||||
ssh -t $remote_user@$remote_server "sudo systemctl status homebridge.service"
|
|
||||||
|
|
||||||
echo done
|
|
||||||
exit
|
|
@ -3,5 +3,8 @@
|
|||||||
{
|
{
|
||||||
"path": "."
|
"path": "."
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"settings": {
|
||||||
|
"editor.tabSize": 2
|
||||||
|
}
|
||||||
}
|
}
|
270
package-lock.json
generated
270
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "homebridge-harmony-control",
|
"name": "@watsonb8/homebridge-harmony-control",
|
||||||
"version": "1.1.0",
|
"version": "1.2.3",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
88
package.json
88
package.json
@ -1,45 +1,47 @@
|
|||||||
{
|
{
|
||||||
"name": "homebridge-harmony-control",
|
"name": "@watsonb8/homebridge-harmony-control",
|
||||||
"version": "1.1.0",
|
"version": "1.3.0",
|
||||||
"description": "Homebridge platform to control smart home equipment by room.",
|
"description": "Homebridge platform to control smart home equipment by room.",
|
||||||
"main": "bin/index.js",
|
"main": "bin/index.js",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "http://linuxhost.me:4873/"
|
"registry": "https://gitea.watsonlabs.net"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --build",
|
"build": "tsc --build",
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://git@watsonb8.ddns.net:2122/misc/homebridge-harmony-control.git"
|
"url": "ssh://git@watsonb8.ddns.net:2122/misc/homebridge-harmony-control.git"
|
||||||
},
|
},
|
||||||
"author": "Brandon Watson",
|
"author": "Brandon Watson",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"homebridge-plugin",
|
"homebridge-plugin",
|
||||||
"harmony",
|
"harmony",
|
||||||
"websocket",
|
"websocket",
|
||||||
"harmonyhub",
|
"harmonyhub",
|
||||||
"homekit"
|
"homekit"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"homebridge": ">=1.1.6",
|
"homebridge": ">=1.1.6",
|
||||||
"node": ">=7.6.0"
|
"node": ">=7.6.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"rollup-plugin-typescript": "^1.0.1",
|
"homebridge": "^1.2.5",
|
||||||
"tslib": "^1.10.0",
|
"rollup-plugin-typescript": "^1.0.1",
|
||||||
"tslint": "^5.17.0",
|
"tslib": "^1.10.0",
|
||||||
"typescript": "^3.5.1"
|
"tslint": "^5.17.0",
|
||||||
},
|
"typescript": "^3.9.10"
|
||||||
"dependencies": {
|
},
|
||||||
"@babel/core": "^7.4.5",
|
"dependencies": {
|
||||||
"@babel/preset-env": "^7.4.5",
|
"@babel/core": "^7.4.5",
|
||||||
"@babel/preset-typescript": "^7.3.3",
|
"@babel/preset-env": "^7.4.5",
|
||||||
"@types/node": "^12.0.7",
|
"@babel/preset-typescript": "^7.3.3",
|
||||||
"harmony-websocket": "^1.1.0",
|
"@types/node": "^12.0.7",
|
||||||
"homebridge": "^1.1.16",
|
"harmony-websocket": "^1.1.0",
|
||||||
"request": "^2.88.0"
|
"reflect-metadata": "^0.1.13",
|
||||||
}
|
"request": "^2.88.0",
|
||||||
|
"tsyringe": "^4.6.0"
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,2 +0,0 @@
|
|||||||
export { ControlUnit } from './ControlUnit';
|
|
||||||
export { DeviceButton } from './DeviceButton';
|
|
@ -1,404 +0,0 @@
|
|||||||
import { IActivity } from "../Models/Config/IActivity";
|
|
||||||
import { IDeviceSetupItem } from "../Models/Config/IDeviceSetupItem";
|
|
||||||
import { IInput, IMatrix, IOutput } from "../Models/Config/IMatrix";
|
|
||||||
import { RemoteKey } from "../Accessories/ControlUnit";
|
|
||||||
import { EventEmitter } from "events";
|
|
||||||
import { IHub } from "../Models/Config/IHub";
|
|
||||||
import { IDeviceConfig } from "../Models/Config/IDeviceConfig";
|
|
||||||
import { HarmonyDevice } from "../Models/HarmonyDevice";
|
|
||||||
import { HarmonyHub } from "../Models/HarmonyHub";
|
|
||||||
|
|
||||||
const Harmony = require("harmony-websocket");
|
|
||||||
|
|
||||||
interface IActivityState {
|
|
||||||
currentActivity: IActivity;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IHarmonyDataProviderProps {
|
|
||||||
hubs: Array<IHub>;
|
|
||||||
deviceConfigs: Array<IDeviceConfig>;
|
|
||||||
log: any;
|
|
||||||
matrix: IMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
class HarmonyDataProvider extends EventEmitter {
|
|
||||||
private _log: any;
|
|
||||||
private _hubsByDevice: { [deviceName: string]: string } = {};
|
|
||||||
private _hubs: { [hubName: string]: HarmonyHub } = {};
|
|
||||||
// private _devicesByHub: { [hubName: string]: { [deviceName: string]: HarmonyDevice } } = {};
|
|
||||||
private _states: {
|
|
||||||
[controlUnitName: string]: IActivityState | undefined;
|
|
||||||
} = {};
|
|
||||||
|
|
||||||
private _matrix: IMatrix;
|
|
||||||
|
|
||||||
constructor(props: IHarmonyDataProviderProps) {
|
|
||||||
super();
|
|
||||||
this._log = props.log;
|
|
||||||
this._matrix = props.matrix;
|
|
||||||
props.deviceConfigs.forEach((deviceConfig: IDeviceConfig) => {
|
|
||||||
this._hubsByDevice[deviceConfig.Name] = deviceConfig.Hub;
|
|
||||||
});
|
|
||||||
// this._deviceConfigs = props.deviceConfigs;
|
|
||||||
|
|
||||||
this.connect(props.hubs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public get devicesByHub(): { [hubName: string]: { [deviceName: string]: HarmonyDevice } } {
|
|
||||||
// return this._devicesByHub;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public get hubs(): { [hubName: string]: HarmonyHub } {
|
|
||||||
return this._hubs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Power on all devices in an activity.
|
|
||||||
*/
|
|
||||||
public powerOn = async (controlUnitName: string, activity: IActivity) => {
|
|
||||||
//Only power on if not alread on
|
|
||||||
let currentActivity = this._states[controlUnitName]
|
|
||||||
? this._states[controlUnitName]!.currentActivity
|
|
||||||
: undefined;
|
|
||||||
if (!currentActivity) {
|
|
||||||
await this.startActivity(controlUnitName, activity);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Power off all devices in an activity that aren't being used.
|
|
||||||
*/
|
|
||||||
public powerOff = async (controlUnitName: string) => {
|
|
||||||
if (!this._states[controlUnitName]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//Build potential list of devices to turn off
|
|
||||||
let devicesToTurnOff: Array<HarmonyDevice> = this._states[
|
|
||||||
controlUnitName
|
|
||||||
]!.currentActivity.DeviceSetupList.map(
|
|
||||||
(value: IDeviceSetupItem): HarmonyDevice => {
|
|
||||||
return this.getDeviceFromName(value.DeviceName);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
//Resolve device conflicts with other controlUnits
|
|
||||||
devicesToTurnOff = this.sanitizeDeviceList(
|
|
||||||
devicesToTurnOff,
|
|
||||||
controlUnitName
|
|
||||||
);
|
|
||||||
|
|
||||||
//Turn off devices
|
|
||||||
devicesToTurnOff.forEach(async (device: HarmonyDevice) => {
|
|
||||||
if (device) {
|
|
||||||
await device.powerOff();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this._states[controlUnitName] = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start an activity
|
|
||||||
*/
|
|
||||||
public startActivity = async (
|
|
||||||
controlUnitName: string,
|
|
||||||
activity: IActivity
|
|
||||||
) => {
|
|
||||||
this._log(
|
|
||||||
`Starting activity ${activity.DisplayName} for controlUnit: ${controlUnitName}`
|
|
||||||
);
|
|
||||||
let lastActivity: IActivity | undefined = undefined;
|
|
||||||
if (this._states[controlUnitName]) {
|
|
||||||
lastActivity = this._states[controlUnitName]!.currentActivity;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Build potential list of devices to to turn on
|
|
||||||
let devicesToTurnOn: Array<HarmonyDevice> = activity.DeviceSetupList.map(
|
|
||||||
(value: IDeviceSetupItem): HarmonyDevice => {
|
|
||||||
return this.getDeviceFromName(value.DeviceName);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
//Resolve device conflicts with other controlUnits
|
|
||||||
devicesToTurnOn = this.sanitizeDeviceList(devicesToTurnOn, controlUnitName);
|
|
||||||
|
|
||||||
//Turn on devices
|
|
||||||
await Promise.all(
|
|
||||||
devicesToTurnOn.map(async (device: HarmonyDevice) => {
|
|
||||||
if (device && device.name) {
|
|
||||||
if (!device.on) {
|
|
||||||
this._log(`Turning on device ${device.name}`);
|
|
||||||
await device.powerOn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
//Assign correct input
|
|
||||||
await Promise.all(
|
|
||||||
activity.DeviceSetupList.map(async (value: IDeviceSetupItem) => {
|
|
||||||
let device: HarmonyDevice = this.getDeviceFromName(value.DeviceName);
|
|
||||||
|
|
||||||
if (device && device.supportsCommand(`Input${value.Input}`)) {
|
|
||||||
await device.sendCommand(`Input${value.Input}`);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
if (activity.UseMatrix) {
|
|
||||||
//get input and output
|
|
||||||
let input: IInput = this._matrix.Inputs.filter(
|
|
||||||
(e) => e.InputDevice === activity.ControlDevice
|
|
||||||
)[0];
|
|
||||||
let output: IOutput = this._matrix.Outputs.filter(
|
|
||||||
(e) => e.OutputDevice === activity.OutputDevice
|
|
||||||
)[0];
|
|
||||||
|
|
||||||
let inputCommandName: string = `In ${input.InputNumber}`;
|
|
||||||
let outputCommandName: string = `Out ${output.OutputLetter}`;
|
|
||||||
|
|
||||||
let matrixDevice: HarmonyDevice = this.getDeviceFromName(
|
|
||||||
this._matrix.DeviceName
|
|
||||||
);
|
|
||||||
|
|
||||||
//Route hdmi
|
|
||||||
if (
|
|
||||||
matrixDevice.supportsCommand(inputCommandName) &&
|
|
||||||
matrixDevice.supportsCommand(outputCommandName)
|
|
||||||
) {
|
|
||||||
await matrixDevice.sendCommand(outputCommandName);
|
|
||||||
await matrixDevice.sendCommand(inputCommandName);
|
|
||||||
await matrixDevice.sendCommand(outputCommandName);
|
|
||||||
await matrixDevice.sendCommand(inputCommandName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Build potential list of devices to turn off
|
|
||||||
if (lastActivity) {
|
|
||||||
let devicesToTurnOff: Array<HarmonyDevice> = lastActivity.DeviceSetupList.map(
|
|
||||||
(value: IDeviceSetupItem): HarmonyDevice => {
|
|
||||||
return this.getDeviceFromName(value.DeviceName);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
//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
|
|
||||||
devicesToTurnOff.forEach((device: HarmonyDevice, index: number) => {
|
|
||||||
if (
|
|
||||||
device &&
|
|
||||||
device.name &&
|
|
||||||
activity.DeviceSetupList.some((e) => {
|
|
||||||
return e && e.DeviceName === device.name;
|
|
||||||
})
|
|
||||||
) {
|
|
||||||
delete devicesToTurnOff[index];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//Resolve device conflicts with other controlUnits
|
|
||||||
devicesToTurnOff = this.sanitizeDeviceList(
|
|
||||||
devicesToTurnOff,
|
|
||||||
controlUnitName
|
|
||||||
);
|
|
||||||
|
|
||||||
this._log(
|
|
||||||
`Sanatized devices to turn off: ${JSON.stringify(
|
|
||||||
devicesToTurnOff.map((e) => (e ? e.name : ""))
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
await Promise.all(
|
|
||||||
//Turn off devices
|
|
||||||
devicesToTurnOff.map(async (device: HarmonyDevice) => {
|
|
||||||
if (device) {
|
|
||||||
if (device.on) {
|
|
||||||
this._log(`Turning off device ${device.name}`);
|
|
||||||
await device.powerOff();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Assign current activity
|
|
||||||
this._states[controlUnitName] = { currentActivity: activity };
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn the volume up for the current running activity.
|
|
||||||
*/
|
|
||||||
public volumeUp = async (controlUnitName: string) => {
|
|
||||||
let volumeUpCommand: string = "Volume Up";
|
|
||||||
if (this._states[controlUnitName]) {
|
|
||||||
let volumeDevice: HarmonyDevice = this.getDeviceFromName(
|
|
||||||
this._states[controlUnitName]!.currentActivity.VolumeDevice
|
|
||||||
);
|
|
||||||
await volumeDevice.sendCommand(volumeUpCommand);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Volume down for current running activity.
|
|
||||||
*/
|
|
||||||
public volumeDown = async (controlUnitName: string) => {
|
|
||||||
let volumeDownCommand: string = "Volume Down";
|
|
||||||
if (this._states[controlUnitName]) {
|
|
||||||
let volumeDevice: HarmonyDevice = this.getDeviceFromName(
|
|
||||||
this._states[controlUnitName]!.currentActivity.VolumeDevice
|
|
||||||
);
|
|
||||||
await volumeDevice.sendCommand(volumeDownCommand);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send key press for current activity.
|
|
||||||
*
|
|
||||||
* @param controlUnitName The name of the control unit to act on.
|
|
||||||
* @param key The key to send.
|
|
||||||
*/
|
|
||||||
public sendKeyPress = async (controlUnitName: string, key: any) => {
|
|
||||||
if (this._states[controlUnitName]) {
|
|
||||||
let commandName: string = "";
|
|
||||||
|
|
||||||
let device: HarmonyDevice = this.getDeviceFromName(
|
|
||||||
this._states[controlUnitName]!.currentActivity.ControlDevice
|
|
||||||
);
|
|
||||||
switch (key) {
|
|
||||||
case RemoteKey.ARROW_UP: {
|
|
||||||
commandName = "Direction Up";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RemoteKey.ARROW_DOWN: {
|
|
||||||
commandName = "Direction Down";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RemoteKey.ARROW_LEFT: {
|
|
||||||
commandName = "Direction Left";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RemoteKey.ARROW_RIGHT: {
|
|
||||||
commandName = "Direction Right";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RemoteKey.SELECT: {
|
|
||||||
commandName = "Select";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RemoteKey.PLAY_PAUSE: {
|
|
||||||
commandName = "Pause";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RemoteKey.INFORMATION: {
|
|
||||||
commandName = "Menu";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RemoteKey.BACK: {
|
|
||||||
commandName = "Back";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case RemoteKey.EXIT: {
|
|
||||||
commandName = "Back";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await device.sendCommand(commandName);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return if a control unit is active
|
|
||||||
* @param controlUnitName
|
|
||||||
*/
|
|
||||||
public getIsActive(controlUnitName: string): IActivity | undefined {
|
|
||||||
return this._states[controlUnitName]
|
|
||||||
? this._states[controlUnitName]!.currentActivity
|
|
||||||
: undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the IDevice by name.
|
|
||||||
* @param deviceName The device to retrieve.
|
|
||||||
*/
|
|
||||||
public getDeviceFromName(deviceName: string): HarmonyDevice {
|
|
||||||
let device: HarmonyDevice | undefined;
|
|
||||||
try {
|
|
||||||
device = this._hubs[this._hubsByDevice[deviceName]].getDeviceByName(
|
|
||||||
deviceName
|
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
this._log(`Error retrieving device from hub: ${err}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return device!;
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Gets device button commands
|
|
||||||
// * @param deviceCommandName The device command name
|
|
||||||
// * @param deviceName The device name
|
|
||||||
// */
|
|
||||||
// public getCommand(deviceCommandName: string, deviceName: string): ICommand | undefined {
|
|
||||||
// const device: HarmonyDevice = this.getDeviceFromName(deviceName);
|
|
||||||
// if (device && device.supportsCommand(deviceCommandName)) {
|
|
||||||
// return device.getCommand(deviceCommandName);
|
|
||||||
// } else {
|
|
||||||
// return undefined;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private connect = async (hubs: Array<IHub>) => {
|
|
||||||
let readyCount = 0;
|
|
||||||
await Promise.all(
|
|
||||||
hubs.map(
|
|
||||||
async (hub: IHub): Promise<void> => {
|
|
||||||
const newHarmonyHub = new HarmonyHub(hub.Name, hub.Ip, this._log);
|
|
||||||
this._hubs[hub.Name] = newHarmonyHub;
|
|
||||||
newHarmonyHub.on("Ready", () => {
|
|
||||||
readyCount++;
|
|
||||||
if (readyCount === Object.keys(this._hubs).length) {
|
|
||||||
this.emit("Ready");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
await newHarmonyHub.initialize();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to make sure no control unit depends on device list.
|
|
||||||
* @param devicesToTurnOn The list of devices to modify.
|
|
||||||
* @param controlUnitName The name of the control unit in question.
|
|
||||||
*/
|
|
||||||
private sanitizeDeviceList(
|
|
||||||
devicesToTurnOn: Array<HarmonyDevice>,
|
|
||||||
controlUnitName: string
|
|
||||||
): Array<HarmonyDevice> {
|
|
||||||
for (let controlUnitKey in this._states) {
|
|
||||||
//Skip self
|
|
||||||
if (controlUnitKey === controlUnitName) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let currentOtherState: IActivityState = this._states[controlUnitKey]!;
|
|
||||||
|
|
||||||
if (currentOtherState) {
|
|
||||||
currentOtherState.currentActivity.DeviceSetupList.forEach(
|
|
||||||
(value: IDeviceSetupItem) => {
|
|
||||||
//there are devices to remove
|
|
||||||
if (devicesToTurnOn.some((e) => e && e.name === value.DeviceName)) {
|
|
||||||
let deviceToRemove: HarmonyDevice = devicesToTurnOn.filter(
|
|
||||||
(i) => i.name === value.DeviceName
|
|
||||||
)[0];
|
|
||||||
delete devicesToTurnOn[devicesToTurnOn.indexOf(deviceToRemove)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return devicesToTurnOn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default HarmonyDataProvider;
|
|
@ -1,11 +0,0 @@
|
|||||||
import { IDeviceSetupItem } from './IDeviceSetupItem';
|
|
||||||
|
|
||||||
export interface IActivity {
|
|
||||||
OutputDevice: string;
|
|
||||||
VolumeDevice: string;
|
|
||||||
ControlDevice: string;
|
|
||||||
DisplayName: string;
|
|
||||||
DeviceSetupList: Array<IDeviceSetupItem>;
|
|
||||||
UseMatrix: boolean;
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
import { IMatrix } from "./IMatrix";
|
|
||||||
import { IActivity } from "./IActivity";
|
|
||||||
import { IDeviceButton } from "./IDeviceButton";
|
|
||||||
import { IDeviceConfig } from "./IDeviceConfig";
|
|
||||||
import { IHub } from './IHub';
|
|
||||||
|
|
||||||
export interface IControlUnit {
|
|
||||||
DisplayName: string;
|
|
||||||
Activities: Array<IActivity>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IConfig {
|
|
||||||
hubIp: string;
|
|
||||||
EmitDevicesOnStartup: boolean;
|
|
||||||
Matrix: IMatrix;
|
|
||||||
ControlUnits: Array<IControlUnit>;
|
|
||||||
DeviceButtons: Array<IDeviceButton>;
|
|
||||||
Devices: Array<IDeviceConfig>;
|
|
||||||
Hubs: Array<IHub>;
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
export interface IDeviceConfig {
|
|
||||||
Name: string;
|
|
||||||
Hub: string;
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
export * from './IActivity';
|
|
||||||
export * from './IConfig';
|
|
||||||
export * from './IDeviceButton';
|
|
||||||
export * from './IDeviceSetupItem';
|
|
||||||
export * from './IMatrix';
|
|
@ -1,94 +0,0 @@
|
|||||||
import { ICommand } from "./IDevice";
|
|
||||||
import { sleep } from "../Util/Sleep";
|
|
||||||
|
|
||||||
export interface IHarmonyDeviceProps {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
harmony: any;
|
|
||||||
log: any;
|
|
||||||
commands: { [name: string]: ICommand };
|
|
||||||
}
|
|
||||||
|
|
||||||
export class HarmonyDevice {
|
|
||||||
private _harmony: any;
|
|
||||||
private _log: any;
|
|
||||||
private _commands: { [name: string]: ICommand } = {};
|
|
||||||
private _on: boolean;
|
|
||||||
|
|
||||||
constructor(props: IHarmonyDeviceProps) {
|
|
||||||
this.id = props.id;
|
|
||||||
this.name = props.name;
|
|
||||||
this._harmony = props.harmony;
|
|
||||||
this._on = false;
|
|
||||||
this._commands = props.commands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public id: string;
|
|
||||||
public name: string;
|
|
||||||
|
|
||||||
public get on(): boolean {
|
|
||||||
return this._on;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get commands(): { [name: string]: ICommand } {
|
|
||||||
return this._commands;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Define device methods
|
|
||||||
public supportsCommand(commandName: string): boolean {
|
|
||||||
let command = this._commands[commandName];
|
|
||||||
return (command) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getCommand(commandName: string): ICommand {
|
|
||||||
return this._commands[commandName];
|
|
||||||
}
|
|
||||||
|
|
||||||
public async powerOn(): Promise<void> {
|
|
||||||
let powerOnCommand: string = "Power On";
|
|
||||||
let powerToggleCommand: string = "Power Toggle";
|
|
||||||
if (this.supportsCommand(powerOnCommand)) {
|
|
||||||
await this.sendCommand(powerOnCommand);
|
|
||||||
this._on = true;
|
|
||||||
} else if (this.supportsCommand(powerToggleCommand)) {
|
|
||||||
await this.sendCommand(powerToggleCommand);
|
|
||||||
this._on = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async powerOff(): Promise<void> {
|
|
||||||
let powerOffCommand: string = "Power Off";
|
|
||||||
let powerToggleCommand: string = "Power Toggle";
|
|
||||||
if (this.supportsCommand(powerOffCommand)) {
|
|
||||||
await this.sendCommand(powerOffCommand);
|
|
||||||
this._on = false;
|
|
||||||
} else if (this.supportsCommand(powerToggleCommand)) {
|
|
||||||
await this.sendCommand(powerToggleCommand);
|
|
||||||
this._on = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async sendCommand(commandName: string): Promise<void> {
|
|
||||||
let command!: ICommand;
|
|
||||||
if (this.supportsCommand(commandName)) {
|
|
||||||
command = this.getCommand(commandName);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
//Execute command
|
|
||||||
//HACK to fix Harmon Kardon receiver not turning off
|
|
||||||
if (command.command === "PowerOff") {
|
|
||||||
for (let i = 0; i < 2; i++) {
|
|
||||||
await this._harmony.sendCommand(JSON.stringify(command));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
await this._harmony.sendCommand(JSON.stringify(command));
|
|
||||||
|
|
||||||
//Sleep
|
|
||||||
await sleep(800);
|
|
||||||
} catch (err) {
|
|
||||||
this._log(`ERROR - error sending command to harmony: ${err}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
import { HarmonyDevice } from './HarmonyDevice';
|
|
||||||
const Harmony = require("harmony-websocket");
|
|
||||||
import { ICommand } from './IDevice';
|
|
||||||
import { EventEmitter } from 'events';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export class HarmonyHub extends EventEmitter {
|
|
||||||
private _devices: { [deviceName: string]: HarmonyDevice } = {}
|
|
||||||
private _ip: string;
|
|
||||||
private _harmony: any;
|
|
||||||
private _log: any;
|
|
||||||
private _name: string;
|
|
||||||
|
|
||||||
constructor(hubName: string, ipAddress: string, log: any) {
|
|
||||||
super();
|
|
||||||
this._ip = ipAddress;
|
|
||||||
this._log = log;
|
|
||||||
this._name = hubName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get devices(): { [deviceName: string]: HarmonyDevice } {
|
|
||||||
return this._devices;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get hubName(): string {
|
|
||||||
return this._name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getDeviceByName = (deviceName: string): HarmonyDevice => {
|
|
||||||
return this._devices[deviceName];
|
|
||||||
}
|
|
||||||
|
|
||||||
public initialize = async () => {
|
|
||||||
this._harmony = new Harmony();
|
|
||||||
await this._harmony.connect(this._ip);
|
|
||||||
this._harmony.on('stateDigest', (data: any) => {
|
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
this._harmony.on('automationState', (data: any) => {
|
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
//Gather devices
|
|
||||||
let devices: any = await this._harmony.getDevices();
|
|
||||||
try {
|
|
||||||
await Promise.all(
|
|
||||||
//Add each to dictionary
|
|
||||||
devices.map(async (dev: any) => {
|
|
||||||
//get commands
|
|
||||||
let commands: { [name: string]: ICommand } = {};
|
|
||||||
let deviceCommands: any = await this._harmony.getDeviceCommands(dev.id);
|
|
||||||
deviceCommands.forEach((command: any) => {
|
|
||||||
commands[command.label] = command.action;
|
|
||||||
});
|
|
||||||
this._devices[dev.label] = new HarmonyDevice({
|
|
||||||
id: dev.id,
|
|
||||||
name: dev.label,
|
|
||||||
commands: commands,
|
|
||||||
log: this._log,
|
|
||||||
harmony: this._harmony
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
this.emit("Ready");
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
this._log(`ERROR - error connecting to harmony: ${err}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private connect = async (): Promise<void> => {
|
|
||||||
await this._harmony.Connect(this._ip);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from './IDevice';
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from "./Callbackify";
|
|
||||||
export * from "./Sleep";
|
|
@ -1,8 +1,10 @@
|
|||||||
import { PlatformAccessory, RemoteController, Service } from "homebridge";
|
import { PlatformAccessory, Service } from "homebridge";
|
||||||
import HarmonyDataProvider from "../DataProviders/HarmonyDataProvider";
|
import { IActivity } from "../models/config";
|
||||||
import { IActivity } from "../Models/Config";
|
|
||||||
import { Platform } from "../platform";
|
import { Platform } from "../platform";
|
||||||
import callbackify from "../Util/Callbackify";
|
import { ActivityService } from "../services/activityService";
|
||||||
|
import { CommandService } from "../services/commandService";
|
||||||
|
import { VolumeService } from "../services/volumeService";
|
||||||
|
import callbackify from "../util/callbackify";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum describing remote key presses from homebridge.
|
* Enum describing remote key presses from homebridge.
|
||||||
@ -27,7 +29,9 @@ export class ControlUnit {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly _platform: Platform,
|
private readonly _platform: Platform,
|
||||||
private readonly _accessory: PlatformAccessory,
|
private readonly _accessory: PlatformAccessory,
|
||||||
private _dataProvider: HarmonyDataProvider,
|
private _activityService: ActivityService,
|
||||||
|
private _commandService: CommandService,
|
||||||
|
private _volumeService: VolumeService,
|
||||||
private _activities: Array<IActivity>
|
private _activities: Array<IActivity>
|
||||||
) {
|
) {
|
||||||
this._accessory
|
this._accessory
|
||||||
@ -129,11 +133,14 @@ export class ControlUnit {
|
|||||||
private onSetAccessoryActive = async (value: any) => {
|
private onSetAccessoryActive = async (value: any) => {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0:
|
case 0:
|
||||||
this._dataProvider.powerOff(this._accessory.displayName);
|
this._activityService.stopCurrentActivity(this._accessory.displayName);
|
||||||
break;
|
break;
|
||||||
//Turn on with first activity
|
//Turn on with first activity
|
||||||
case 1:
|
case 1:
|
||||||
this._dataProvider.powerOn(
|
if (this._activityService.getIsActive(this._accessory.displayName)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this._activityService.startLastOrDefaultActivity(
|
||||||
this._accessory.displayName,
|
this._accessory.displayName,
|
||||||
this._activities[0]
|
this._activities[0]
|
||||||
);
|
);
|
||||||
@ -146,7 +153,8 @@ export class ControlUnit {
|
|||||||
*/
|
*/
|
||||||
private onGetAccessoryActive = async () => {
|
private onGetAccessoryActive = async () => {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return this._dataProvider.getIsActive(this._accessory.displayName)
|
return this._activityService.getCurrentActivity(this._accessory.displayName)
|
||||||
|
?.DisplayName
|
||||||
? this._platform.Characteristic.Active.ACTIVE
|
? this._platform.Characteristic.Active.ACTIVE
|
||||||
: this._platform.Characteristic.Active.INACTIVE;
|
: this._platform.Characteristic.Active.INACTIVE;
|
||||||
};
|
};
|
||||||
@ -155,14 +163,14 @@ export class ControlUnit {
|
|||||||
* Event handler for SET remote key
|
* Event handler for SET remote key
|
||||||
*/
|
*/
|
||||||
private onSetRemoteKey = async (key: any) => {
|
private onSetRemoteKey = async (key: any) => {
|
||||||
this._dataProvider.sendKeyPress(this._accessory.displayName, key);
|
this._commandService.sendKeyPress(this._accessory.displayName, key);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event handler for SET active identifier characteristic
|
* Event handler for SET active identifier characteristic
|
||||||
*/
|
*/
|
||||||
private onSetActiveIdentifier = async (identifier: any) => {
|
private onSetActiveIdentifier = async (identifier: any) => {
|
||||||
this._dataProvider.startActivity(
|
this._activityService.startActivity(
|
||||||
this._accessory.displayName,
|
this._accessory.displayName,
|
||||||
this._activities[identifier]
|
this._activities[identifier]
|
||||||
);
|
);
|
||||||
@ -172,7 +180,7 @@ export class ControlUnit {
|
|||||||
* Event handler for GET active identifier characteristic
|
* Event handler for GET active identifier characteristic
|
||||||
*/
|
*/
|
||||||
private onGetActiveIdentifier = async () => {
|
private onGetActiveIdentifier = async () => {
|
||||||
let currentActivity: IActivity = this._dataProvider.getIsActive(
|
let currentActivity: IActivity = this._activityService.getCurrentActivity(
|
||||||
this._accessory.displayName
|
this._accessory.displayName
|
||||||
)!;
|
)!;
|
||||||
let identifier: number = 0;
|
let identifier: number = 0;
|
||||||
@ -230,10 +238,10 @@ export class ControlUnit {
|
|||||||
private onSetVolumeSelector = async (value: any) => {
|
private onSetVolumeSelector = async (value: any) => {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0:
|
case 0:
|
||||||
this._dataProvider.volumeUp(this._accessory.displayName);
|
this._volumeService.volumeUp(this._accessory.displayName);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
this._dataProvider.volumeDown(this._accessory.displayName);
|
this._volumeService.volumeDown(this._accessory.displayName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -1,7 +1,7 @@
|
|||||||
import { PlatformAccessory, Service } from "homebridge";
|
import { PlatformAccessory, Service } from "homebridge";
|
||||||
import HarmonyDataProvider from "../DataProviders/HarmonyDataProvider";
|
import { HarmonyDataProvider } from "../dataProviders/harmonyDataProvider";
|
||||||
import { IDeviceButton } from "../Models/Config";
|
import { IDeviceButton } from "../models/config";
|
||||||
import { HarmonyDevice } from "../Models/HarmonyDevice";
|
import { HarmonyDevice } from "../models/harmonyDevice";
|
||||||
import { Platform } from "../platform";
|
import { Platform } from "../platform";
|
||||||
|
|
||||||
export class DeviceButton {
|
export class DeviceButton {
|
||||||
@ -69,29 +69,40 @@ export class DeviceButton {
|
|||||||
|
|
||||||
//Get device command if we don't have it
|
//Get device command if we don't have it
|
||||||
if (!this._device) {
|
if (!this._device) {
|
||||||
this._device = this._dataProvider.getDeviceFromName(
|
this._device = this._dataProvider.getDeviceByName(
|
||||||
this._deviceInfo.DeviceName
|
this._deviceInfo.DeviceName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Execute command
|
//Execute command
|
||||||
if (this._device) {
|
if (!this._device) {
|
||||||
//change state if stateful
|
return callback();
|
||||||
if (this._deviceInfo.IsStateful && this._buttonState != newState) {
|
}
|
||||||
this._buttonState = newState;
|
|
||||||
await this._device.sendCommand(this._deviceInfo.ButtonName);
|
//change state if stateful
|
||||||
} else if (!this._deviceInfo.IsStateful) {
|
if (this._deviceInfo.IsStateful && this._buttonState != newState) {
|
||||||
//Send the number of configured key presses
|
this._buttonState = newState;
|
||||||
for (let i = 0; i < this._deviceInfo.NumberOfKeyPresses; i++) {
|
await this._dataProvider.sendCommand(
|
||||||
await this._device.sendCommand(this._deviceInfo.ButtonName);
|
this._deviceInfo.ButtonName,
|
||||||
}
|
this._device
|
||||||
this._switchService
|
);
|
||||||
.getCharacteristic(this._platform.Characteristic.On)
|
return callback();
|
||||||
.updateValue(false);
|
} else if (!this._deviceInfo.IsStateful) {
|
||||||
return callback(new Error("Normal Response"));
|
//Send the number of configured key presses
|
||||||
}
|
for (let i = 0; i < this._deviceInfo.NumberOfKeyPresses; i++) {
|
||||||
|
await this._dataProvider.sendCommand(
|
||||||
|
this._deviceInfo.ButtonName,
|
||||||
|
this._device
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._switchService
|
||||||
|
.getCharacteristic(this._platform.Characteristic.On)
|
||||||
|
.updateValue(false);
|
||||||
|
|
||||||
|
this._buttonState = false;
|
||||||
|
return callback();
|
||||||
}
|
}
|
||||||
return callback();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
2
src/accessories/index.ts
Normal file
2
src/accessories/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export { ControlUnit } from "./controlUnit";
|
||||||
|
export { DeviceButton } from "./deviceButton";
|
105
src/accessories/sequence.ts
Normal file
105
src/accessories/sequence.ts
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import {
|
||||||
|
CharacteristicGetCallback,
|
||||||
|
CharacteristicSetCallback,
|
||||||
|
CharacteristicValue,
|
||||||
|
PlatformAccessory,
|
||||||
|
Service,
|
||||||
|
} from "homebridge";
|
||||||
|
import { HarmonyDataProvider } from "../dataProviders/harmonyDataProvider";
|
||||||
|
import { ISequence } from "../models/config/sequence";
|
||||||
|
import { HarmonyDevice } from "../models/harmonyDevice";
|
||||||
|
import { Platform } from "../platform";
|
||||||
|
import { sleep } from "../util";
|
||||||
|
|
||||||
|
export class Sequence {
|
||||||
|
private _devices: { [deviceName: string]: HarmonyDevice };
|
||||||
|
private _switchService: Service;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly _platform: Platform,
|
||||||
|
private readonly _accessory: PlatformAccessory,
|
||||||
|
private _dataProvider: HarmonyDataProvider,
|
||||||
|
private _sequence: ISequence
|
||||||
|
) {
|
||||||
|
this._accessory
|
||||||
|
.getService(this._platform.Service.AccessoryInformation)!
|
||||||
|
.setCharacteristic(
|
||||||
|
this._platform.Characteristic.Manufacturer,
|
||||||
|
"Brandon Watson"
|
||||||
|
)
|
||||||
|
.setCharacteristic(this._platform.Characteristic.Model, "Sequence Button")
|
||||||
|
.setCharacteristic(
|
||||||
|
this._platform.Characteristic.SerialNumber,
|
||||||
|
"123-456-789"
|
||||||
|
);
|
||||||
|
|
||||||
|
const switchUUID = this._platform.api.hap.uuid.generate(
|
||||||
|
`${this._accessory.displayName} Switch`
|
||||||
|
);
|
||||||
|
|
||||||
|
this._switchService =
|
||||||
|
this._accessory.getService(this._platform.Service.Switch) ||
|
||||||
|
this._accessory.addService(
|
||||||
|
this._platform.Service.Switch,
|
||||||
|
this._accessory.displayName,
|
||||||
|
switchUUID
|
||||||
|
);
|
||||||
|
|
||||||
|
this._switchService
|
||||||
|
.getCharacteristic(this._platform.Characteristic.On)
|
||||||
|
.on("set", this.onSwitchSet)
|
||||||
|
.updateValue(false)
|
||||||
|
.on("get", (callback: CharacteristicGetCallback): void => {
|
||||||
|
return callback(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
this._devices = {};
|
||||||
|
// Get devices in sequence
|
||||||
|
for (const deviceName of _sequence.Steps.map((e) => e.DeviceName)) {
|
||||||
|
if (!deviceName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const device = this._dataProvider.getDeviceByName(deviceName);
|
||||||
|
if (device) {
|
||||||
|
this._devices[deviceName] = device;
|
||||||
|
} else {
|
||||||
|
this._platform.log.warn(
|
||||||
|
`Device ${deviceName} was not found in harmony configuration`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for switchSet command
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
|
public onSwitchSet = async (
|
||||||
|
_value: CharacteristicValue,
|
||||||
|
callback: CharacteristicSetCallback
|
||||||
|
): Promise<void> => {
|
||||||
|
// Execute sequence
|
||||||
|
for (const step of this._sequence.Steps) {
|
||||||
|
await sleep(step.Delay);
|
||||||
|
const device: HarmonyDevice = this._devices[step.DeviceName ?? ""];
|
||||||
|
if (
|
||||||
|
device &&
|
||||||
|
step.DeviceCommand &&
|
||||||
|
device.supportsCommand(step.DeviceCommand)
|
||||||
|
) {
|
||||||
|
await this._dataProvider.sendCommand(step.DeviceCommand, device);
|
||||||
|
} else {
|
||||||
|
this._platform.log.warn(
|
||||||
|
`Attempted to execute command ${step.DeviceCommand} on device ${step.DeviceName} but the device or command was not found`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deactivate button
|
||||||
|
this._switchService
|
||||||
|
.getCharacteristic(this._platform.Characteristic.On)
|
||||||
|
.updateValue(false);
|
||||||
|
|
||||||
|
callback(null);
|
||||||
|
};
|
||||||
|
}
|
166
src/dataProviders/harmonyDataProvider.ts
Normal file
166
src/dataProviders/harmonyDataProvider.ts
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
import { Logging } from "homebridge";
|
||||||
|
import { inject, injectable } from "tsyringe";
|
||||||
|
import { ICommand } from "../models";
|
||||||
|
import { IConfig } from "../models/config";
|
||||||
|
import { IDeviceConfig } from "../models/config/deviceConfig";
|
||||||
|
import { IHub } from "../models/config/hub";
|
||||||
|
import { HarmonyDevice } from "../models/harmonyDevice";
|
||||||
|
import { HarmonyHub } from "../models/harmonyHub";
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class HarmonyDataProvider {
|
||||||
|
private _hubs: { [hubName: string]: HarmonyHub } = {};
|
||||||
|
private _deviceConfigByName: { [deviceName: string]: IDeviceConfig } = {};
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@inject("IConfig") private _config: IConfig,
|
||||||
|
@inject("log") private _log: Logging
|
||||||
|
) {
|
||||||
|
_config.Devices.forEach((deviceConfig: IDeviceConfig) => {
|
||||||
|
this._deviceConfigByName[deviceConfig.Name] = deviceConfig;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.connect(_config.Hubs);
|
||||||
|
this.emitInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async powerOnDevices(devices: Array<HarmonyDevice>): Promise<void> {
|
||||||
|
await Promise.all(
|
||||||
|
devices.map(async (device: HarmonyDevice) => {
|
||||||
|
if (device && device.name) {
|
||||||
|
if (!device.on) {
|
||||||
|
this._log.info(`Turning on device ${device.name}`);
|
||||||
|
await this.powerOnDevice(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async powerOffDevices(devices: Array<HarmonyDevice>) {
|
||||||
|
await Promise.all(
|
||||||
|
//Turn off devices
|
||||||
|
devices.map(async (device: HarmonyDevice) => {
|
||||||
|
if (device) {
|
||||||
|
if (device.on) {
|
||||||
|
this._log.info(`Turning off device ${device.name}`);
|
||||||
|
await this.powerOffDevice(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sendCommand(
|
||||||
|
commandName: string,
|
||||||
|
harmonyDevice: HarmonyDevice
|
||||||
|
): Promise<void> {
|
||||||
|
let command!: ICommand;
|
||||||
|
|
||||||
|
commandName = this.getOverrideCommand(commandName, harmonyDevice);
|
||||||
|
|
||||||
|
if (harmonyDevice.supportsCommand(commandName)) {
|
||||||
|
command = harmonyDevice.getCommand(commandName);
|
||||||
|
}
|
||||||
|
const hub = this.getHubByDevice(harmonyDevice);
|
||||||
|
await hub.sendCommand(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the IDevice by name.
|
||||||
|
* @param deviceName The device to retrieve.
|
||||||
|
*/
|
||||||
|
public getDeviceByName(deviceName: string): HarmonyDevice {
|
||||||
|
let device: HarmonyDevice | undefined;
|
||||||
|
try {
|
||||||
|
device =
|
||||||
|
this._hubs[this._deviceConfigByName[deviceName].Hub].getDeviceByName(
|
||||||
|
deviceName
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
this._log.info(`Error retrieving device from hub: ${err}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return device!;
|
||||||
|
}
|
||||||
|
|
||||||
|
private connect = async (hubs: Array<IHub>) => {
|
||||||
|
let readyCount = 0;
|
||||||
|
await Promise.all(
|
||||||
|
hubs.map(async (hub: IHub): Promise<void> => {
|
||||||
|
const newHarmonyHub = new HarmonyHub(hub.Name, hub.Ip, this._log.info);
|
||||||
|
this._hubs[hub.Name] = newHarmonyHub;
|
||||||
|
newHarmonyHub.on("Ready", () => {
|
||||||
|
readyCount++;
|
||||||
|
if (readyCount === Object.keys(this._hubs).length) {
|
||||||
|
// this.emit("Ready");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await newHarmonyHub.initialize();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
private emitInfo(): void {
|
||||||
|
//Emit devices if requested
|
||||||
|
this._log.info("All hubs connected");
|
||||||
|
if (this._config.EmitDevicesOnStartup) {
|
||||||
|
const hubs = this._hubs;
|
||||||
|
Object.values(hubs).forEach((hub: HarmonyHub) => {
|
||||||
|
const deviceDictionary = hub.devices;
|
||||||
|
this._log.info(`${hub.hubName}`);
|
||||||
|
Object.values(deviceDictionary).forEach((device: HarmonyDevice) => {
|
||||||
|
this._log.info(` ${device.name} : ${device.id}`);
|
||||||
|
Object.keys(device.commands).forEach((command: string) => {
|
||||||
|
this._log.info(` ${command}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getHubByDevice(device: HarmonyDevice) {
|
||||||
|
return this._hubs[this._deviceConfigByName[device.name].Hub];
|
||||||
|
}
|
||||||
|
|
||||||
|
private async powerOnDevice(harmonyDevice: HarmonyDevice): Promise<void> {
|
||||||
|
let powerOnCommand: string = "Power On";
|
||||||
|
let powerToggleCommand: string = "Power Toggle";
|
||||||
|
if (harmonyDevice.supportsCommand(powerOnCommand)) {
|
||||||
|
await this.sendCommand(powerOnCommand, harmonyDevice);
|
||||||
|
harmonyDevice.on = true;
|
||||||
|
} else if (harmonyDevice.supportsCommand(powerToggleCommand)) {
|
||||||
|
await this.sendCommand(powerToggleCommand, harmonyDevice);
|
||||||
|
harmonyDevice.on = true;
|
||||||
|
} else {
|
||||||
|
await this.sendCommand(powerOnCommand, harmonyDevice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async powerOffDevice(harmonyDevice: HarmonyDevice): Promise<void> {
|
||||||
|
let powerOffCommand: string = "Power Off";
|
||||||
|
let powerToggleCommand: string = "Power Toggle";
|
||||||
|
if (harmonyDevice.supportsCommand(powerOffCommand)) {
|
||||||
|
await this.sendCommand(powerOffCommand, harmonyDevice);
|
||||||
|
harmonyDevice.on = false;
|
||||||
|
} else if (harmonyDevice.supportsCommand(powerToggleCommand)) {
|
||||||
|
await this.sendCommand(powerToggleCommand, harmonyDevice);
|
||||||
|
harmonyDevice.on = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getOverrideCommand(
|
||||||
|
commandName: string,
|
||||||
|
harmonyDevice: HarmonyDevice
|
||||||
|
) {
|
||||||
|
const deviceConfig: IDeviceConfig =
|
||||||
|
this._deviceConfigByName[harmonyDevice.name];
|
||||||
|
if (!deviceConfig.Overrides) {
|
||||||
|
return commandName;
|
||||||
|
}
|
||||||
|
const overrideCommand = deviceConfig.Overrides.find(
|
||||||
|
(e) => e.Command == commandName
|
||||||
|
);
|
||||||
|
return overrideCommand ? overrideCommand.Override : commandName;
|
||||||
|
}
|
||||||
|
}
|
43
src/dataProviders/stateDataProvider.ts
Normal file
43
src/dataProviders/stateDataProvider.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { injectable } from "tsyringe";
|
||||||
|
import { IActivityState } from "../models/activityState";
|
||||||
|
import { IActivity } from "../models/config";
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class StateDataProvider {
|
||||||
|
private _states: {
|
||||||
|
[controlUnitName: string]: IActivityState | undefined;
|
||||||
|
} = {};
|
||||||
|
|
||||||
|
public updateState(activity: IActivity, controlUnitName: string): void {
|
||||||
|
const oldState = this._states[controlUnitName];
|
||||||
|
this._states[controlUnitName] = {
|
||||||
|
currentActivity: activity,
|
||||||
|
lastActivity: oldState?.lastActivity,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public deactivateState(controlUnitName: string): void {
|
||||||
|
const oldState = this._states[controlUnitName];
|
||||||
|
this._states[controlUnitName] = {
|
||||||
|
currentActivity: undefined,
|
||||||
|
lastActivity: oldState?.currentActivity,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public removeState(controlUnitName: string): void {
|
||||||
|
this._states[controlUnitName] = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getState(controlUnitName: string): IActivityState | undefined {
|
||||||
|
if (!this._states[controlUnitName]) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return this._states[controlUnitName];
|
||||||
|
}
|
||||||
|
|
||||||
|
public get states(): {
|
||||||
|
[controlUnitName: string]: IActivityState | undefined;
|
||||||
|
} {
|
||||||
|
return this._states;
|
||||||
|
}
|
||||||
|
}
|
6
src/models/activityState.ts
Normal file
6
src/models/activityState.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { IActivity } from "./config";
|
||||||
|
|
||||||
|
export interface IActivityState {
|
||||||
|
currentActivity?: IActivity;
|
||||||
|
lastActivity?: IActivity;
|
||||||
|
}
|
10
src/models/config/activity.ts
Normal file
10
src/models/config/activity.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { IDeviceSetupItem } from "./deviceSetupItem";
|
||||||
|
|
||||||
|
export interface IActivity {
|
||||||
|
OutputDevice: string;
|
||||||
|
VolumeDevice: string;
|
||||||
|
ControlDevice: string;
|
||||||
|
DisplayName: string;
|
||||||
|
DeviceSetupList: Array<IDeviceSetupItem>;
|
||||||
|
UseMatrix: boolean;
|
||||||
|
}
|
22
src/models/config/config.ts
Normal file
22
src/models/config/config.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { IMatrix } from "./matrix";
|
||||||
|
import { IActivity } from "./activity";
|
||||||
|
import { IDeviceButton } from "./deviceButton";
|
||||||
|
import { IDeviceConfig } from "./deviceConfig";
|
||||||
|
import { IHub } from "./hub";
|
||||||
|
import { ISequence } from "./sequence";
|
||||||
|
|
||||||
|
export interface IControlUnit {
|
||||||
|
DisplayName: string;
|
||||||
|
Activities: Array<IActivity>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IConfig {
|
||||||
|
hubIp: string;
|
||||||
|
EmitDevicesOnStartup: boolean;
|
||||||
|
Matrix: IMatrix;
|
||||||
|
ControlUnits: Array<IControlUnit>;
|
||||||
|
DeviceButtons: Array<IDeviceButton>;
|
||||||
|
Sequences: Array<ISequence>;
|
||||||
|
Devices: Array<IDeviceConfig>;
|
||||||
|
Hubs: Array<IHub>;
|
||||||
|
}
|
5
src/models/config/deviceConfig.ts
Normal file
5
src/models/config/deviceConfig.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface IDeviceConfig {
|
||||||
|
Name: string;
|
||||||
|
Hub: string;
|
||||||
|
Overrides: Array<{ Command: string; Override: string }>;
|
||||||
|
}
|
5
src/models/config/index.ts
Normal file
5
src/models/config/index.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export * from "./activity";
|
||||||
|
export * from "./config";
|
||||||
|
export * from "./deviceButton";
|
||||||
|
export * from "./deviceSetupItem";
|
||||||
|
export * from "./matrix";
|
10
src/models/config/sequence.ts
Normal file
10
src/models/config/sequence.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export interface ISequence {
|
||||||
|
DisplayName: string;
|
||||||
|
Steps: Array<IStep>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IStep {
|
||||||
|
DeviceName?: string;
|
||||||
|
DeviceCommand?: string;
|
||||||
|
Delay: number;
|
||||||
|
}
|
47
src/models/harmonyDevice.ts
Normal file
47
src/models/harmonyDevice.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { ICommand } from "./device";
|
||||||
|
import { sleep } from "../util/sleep";
|
||||||
|
|
||||||
|
export interface IHarmonyDeviceProps {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
harmony: any;
|
||||||
|
log: any;
|
||||||
|
commands: { [name: string]: ICommand };
|
||||||
|
}
|
||||||
|
|
||||||
|
export class HarmonyDevice {
|
||||||
|
private _commands: { [name: string]: ICommand } = {};
|
||||||
|
private _on: boolean;
|
||||||
|
|
||||||
|
constructor(props: IHarmonyDeviceProps) {
|
||||||
|
this.id = props.id;
|
||||||
|
this.name = props.name;
|
||||||
|
this._on = false;
|
||||||
|
this._commands = props.commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public id: string;
|
||||||
|
public name: string;
|
||||||
|
|
||||||
|
public get on(): boolean {
|
||||||
|
return this._on;
|
||||||
|
}
|
||||||
|
|
||||||
|
public set on(value: boolean) {
|
||||||
|
this._on = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get commands(): { [name: string]: ICommand } {
|
||||||
|
return this._commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Define device methods
|
||||||
|
public supportsCommand(commandName: string): boolean {
|
||||||
|
let command = this._commands[commandName];
|
||||||
|
return command ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getCommand(commandName: string): ICommand {
|
||||||
|
return this._commands[commandName];
|
||||||
|
}
|
||||||
|
}
|
94
src/models/harmonyHub.ts
Normal file
94
src/models/harmonyHub.ts
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
import { HarmonyDevice } from "./harmonyDevice";
|
||||||
|
const Harmony = require("harmony-websocket");
|
||||||
|
import { ICommand } from "./device";
|
||||||
|
import { EventEmitter } from "events";
|
||||||
|
import { sleep } from "../util";
|
||||||
|
|
||||||
|
export class HarmonyHub extends EventEmitter {
|
||||||
|
private _devices: { [deviceName: string]: HarmonyDevice } = {};
|
||||||
|
private _ip: string;
|
||||||
|
private _harmony: any;
|
||||||
|
private _log: any;
|
||||||
|
private _name: string;
|
||||||
|
|
||||||
|
constructor(hubName: string, ipAddress: string, log: any) {
|
||||||
|
super();
|
||||||
|
this._ip = ipAddress;
|
||||||
|
this._log = log;
|
||||||
|
this._name = hubName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get devices(): { [deviceName: string]: HarmonyDevice } {
|
||||||
|
return this._devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get hubName(): string {
|
||||||
|
return this._name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getDeviceByName = (deviceName: string): HarmonyDevice => {
|
||||||
|
return this._devices[deviceName];
|
||||||
|
};
|
||||||
|
|
||||||
|
public initialize = async () => {
|
||||||
|
this._harmony = new Harmony();
|
||||||
|
await this._harmony.connect(this._ip);
|
||||||
|
this._harmony.on("stateDigest", (data: any) => {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
this._harmony.on("automationState", (data: any) => {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
//Gather devices
|
||||||
|
let devices: any = await this._harmony.getDevices();
|
||||||
|
try {
|
||||||
|
await Promise.all(
|
||||||
|
//Add each to dictionary
|
||||||
|
devices.map(async (dev: any) => {
|
||||||
|
//get commands
|
||||||
|
let commands: { [name: string]: ICommand } = {};
|
||||||
|
let deviceCommands: any = await this._harmony.getDeviceCommands(
|
||||||
|
dev.id
|
||||||
|
);
|
||||||
|
deviceCommands.forEach((command: any) => {
|
||||||
|
commands[command.label] = command.action;
|
||||||
|
});
|
||||||
|
this._devices[dev.label] = new HarmonyDevice({
|
||||||
|
id: dev.id,
|
||||||
|
name: dev.label,
|
||||||
|
commands: commands,
|
||||||
|
log: this._log,
|
||||||
|
harmony: this._harmony,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
this.emit("Ready");
|
||||||
|
} catch (err) {
|
||||||
|
this._log(`ERROR - error connecting to harmony: ${err}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private connect = async (): Promise<void> => {
|
||||||
|
await this._harmony.Connect(this._ip);
|
||||||
|
};
|
||||||
|
|
||||||
|
public async sendCommand(command: ICommand): Promise<void> {
|
||||||
|
try {
|
||||||
|
//Execute command
|
||||||
|
//HACK to fix Harmon Kardon receiver not turning off
|
||||||
|
if (command.command === "PowerOff") {
|
||||||
|
for (let i = 0; i < 2; i++) {
|
||||||
|
await this._harmony.sendCommand(JSON.stringify(command));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await this._harmony.sendCommand(JSON.stringify(command));
|
||||||
|
|
||||||
|
//Sleep
|
||||||
|
await sleep(800);
|
||||||
|
} catch (err) {
|
||||||
|
this._log(`ERROR - error sending command to harmony: ${err}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
src/models/index.ts
Normal file
1
src/models/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "./device";
|
194
src/platform.ts
194
src/platform.ts
@ -1,3 +1,4 @@
|
|||||||
|
import "reflect-metadata";
|
||||||
import {
|
import {
|
||||||
API,
|
API,
|
||||||
Characteristic,
|
Characteristic,
|
||||||
@ -7,12 +8,17 @@ import {
|
|||||||
PlatformConfig,
|
PlatformConfig,
|
||||||
Service,
|
Service,
|
||||||
} from "homebridge";
|
} from "homebridge";
|
||||||
import { ControlUnit, DeviceButton } from "./Accessories";
|
import { ControlUnit, DeviceButton } from "./accessories";
|
||||||
import HarmonyDataProvider from "./DataProviders/HarmonyDataProvider";
|
import { Sequence } from "./accessories/sequence";
|
||||||
import { IConfig, IControlUnit, IDeviceButton } from "./Models/Config";
|
import { IConfig, IControlUnit, IDeviceButton } from "./models/config";
|
||||||
import { HarmonyDevice } from "./Models/HarmonyDevice";
|
import { ISequence } from "./models/config/sequence";
|
||||||
import { HarmonyHub } from "./Models/HarmonyHub";
|
|
||||||
import { PLATFORM_NAME, PLUGIN_NAME } from "./settings";
|
import { PLATFORM_NAME, PLUGIN_NAME } from "./settings";
|
||||||
|
import { container } from "tsyringe";
|
||||||
|
import { HarmonyDataProvider } from "./dataProviders/harmonyDataProvider";
|
||||||
|
import { StateDataProvider } from "./dataProviders/stateDataProvider";
|
||||||
|
import { CommandService } from "./services/commandService";
|
||||||
|
import { ActivityService } from "./services/activityService";
|
||||||
|
import { VolumeService } from "./services/volumeService";
|
||||||
|
|
||||||
export class Platform implements DynamicPlatformPlugin {
|
export class Platform implements DynamicPlatformPlugin {
|
||||||
constructor(
|
constructor(
|
||||||
@ -21,74 +27,51 @@ 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.register();
|
||||||
|
|
||||||
this.config = (config as unknown) as IConfig;
|
let didFinishLaunching = false;
|
||||||
//construct data provider
|
|
||||||
const dataProvider = new HarmonyDataProvider({
|
|
||||||
hubs: this.config.Hubs,
|
|
||||||
deviceConfigs: this.config.Devices,
|
|
||||||
matrix: this.config.Matrix,
|
|
||||||
log: this.log,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.api.on("didFinishLaunching", async () => {
|
this.api.on("didFinishLaunching", async () => {
|
||||||
log.debug("Executed didFinishLaunching callback");
|
log.debug("Executed didFinishLaunching callback");
|
||||||
this.discoverDevices(dataProvider);
|
this.discoverControlUnitAccessories();
|
||||||
|
this.discoverDeviceButtonAccessories();
|
||||||
|
this.discoverSequenceAccessories();
|
||||||
|
this.pruneAccessories();
|
||||||
|
didFinishLaunching = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dataProvider = null;
|
|
||||||
|
|
||||||
if (this.config) {
|
|
||||||
//construct data provider
|
|
||||||
this.dataProvider = new HarmonyDataProvider({
|
|
||||||
hubs: this.config.Hubs,
|
|
||||||
deviceConfigs: this.config.Devices,
|
|
||||||
matrix: this.config.Matrix,
|
|
||||||
log: this.log,
|
|
||||||
});
|
|
||||||
|
|
||||||
//Emit devices if requested
|
|
||||||
|
|
||||||
this.dataProvider.on("Ready", () => {
|
|
||||||
this.log.info("All hubs connected");
|
|
||||||
if (this.config.EmitDevicesOnStartup) {
|
|
||||||
const hubs = this.dataProvider!.hubs;
|
|
||||||
Object.values(hubs).forEach((hub: HarmonyHub) => {
|
|
||||||
const deviceDictionary = hub.devices;
|
|
||||||
this.log.info(`${hub.hubName}`);
|
|
||||||
|
|
||||||
Object.values(deviceDictionary).forEach((device: HarmonyDevice) => {
|
|
||||||
this.log.info(` ${device.name} : ${device.id}`);
|
|
||||||
Object.keys(device.commands).forEach((command: string) => {
|
|
||||||
this.log.info(` ${command}`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly Service: typeof Service = this.api.hap.Service;
|
public readonly Service: typeof Service = this.api.hap.Service;
|
||||||
public readonly Characteristic: typeof Characteristic = this.api.hap
|
public readonly Characteristic: typeof Characteristic =
|
||||||
.Characteristic;
|
this.api.hap.Characteristic;
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
public discoverDevices(dataProvider: HarmonyDataProvider) {
|
/**
|
||||||
|
* Discover new control unit accessories
|
||||||
|
* @param dataProvider
|
||||||
|
*/
|
||||||
|
private discoverControlUnitAccessories(): 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);
|
||||||
|
|
||||||
if (existingAccessory) {
|
if (existingAccessory) {
|
||||||
this.log.info(
|
this.log.info(
|
||||||
"Restoring existing accessory from cache: " +
|
"Restoring existing accessory from cache: " +
|
||||||
existingAccessory.displayName
|
existingAccessory.displayName
|
||||||
);
|
);
|
||||||
|
|
||||||
new ControlUnit(this, existingAccessory, dataProvider, unit.Activities);
|
new ControlUnit(
|
||||||
|
this,
|
||||||
|
existingAccessory,
|
||||||
|
container.resolve(ActivityService),
|
||||||
|
container.resolve(CommandService),
|
||||||
|
container.resolve(VolumeService),
|
||||||
|
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);
|
||||||
@ -99,14 +82,28 @@ export class Platform implements DynamicPlatformPlugin {
|
|||||||
uuid
|
uuid
|
||||||
);
|
);
|
||||||
accessory.context["DeviceName"] = unit.DisplayName;
|
accessory.context["DeviceName"] = unit.DisplayName;
|
||||||
|
accessory.context["Type"] = typeof ControlUnit.name;
|
||||||
|
|
||||||
new ControlUnit(this, accessory, dataProvider, unit.Activities);
|
new ControlUnit(
|
||||||
|
this,
|
||||||
|
accessory,
|
||||||
|
container.resolve(ActivityService),
|
||||||
|
container.resolve(CommandService),
|
||||||
|
container.resolve(VolumeService),
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discover new device button accessories
|
||||||
|
* @param dataProvider
|
||||||
|
*/
|
||||||
|
private discoverDeviceButtonAccessories(): 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);
|
||||||
@ -116,7 +113,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);
|
||||||
@ -125,20 +127,102 @@ export class Platform implements DynamicPlatformPlugin {
|
|||||||
uuid
|
uuid
|
||||||
);
|
);
|
||||||
accessory.context["DeviceName"] = button.DisplayName;
|
accessory.context["DeviceName"] = button.DisplayName;
|
||||||
|
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,
|
||||||
]);
|
]);
|
||||||
|
this.accessories.push(accessory);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discover new sequence accessories
|
||||||
|
* @param dataProvider
|
||||||
|
*/
|
||||||
|
private discoverSequenceAccessories(): void {
|
||||||
|
this.config.Sequences.forEach((sequence: ISequence) => {
|
||||||
|
const uuid = this.api.hap.uuid.generate(sequence.DisplayName);
|
||||||
|
const existingAccessory = this.accessories.find((e) => e.UUID === uuid);
|
||||||
|
if (existingAccessory) {
|
||||||
|
this.log.info(
|
||||||
|
"Restoring existing accessory from cache: " +
|
||||||
|
existingAccessory.displayName
|
||||||
|
);
|
||||||
|
|
||||||
|
new Sequence(
|
||||||
|
this,
|
||||||
|
existingAccessory,
|
||||||
|
container.resolve(HarmonyDataProvider),
|
||||||
|
sequence
|
||||||
|
);
|
||||||
|
this.api.updatePlatformAccessories([existingAccessory]);
|
||||||
|
} else {
|
||||||
|
this.log.info("Adding new accessory: " + sequence.DisplayName);
|
||||||
|
const accessory = new this.api.platformAccessory(
|
||||||
|
sequence.DisplayName,
|
||||||
|
uuid
|
||||||
|
);
|
||||||
|
accessory.context["DeviceName"] = sequence.DisplayName;
|
||||||
|
accessory.context["Type"] = typeof "Sequence";
|
||||||
|
|
||||||
|
new Sequence(
|
||||||
|
this,
|
||||||
|
accessory,
|
||||||
|
container.resolve(HarmonyDataProvider),
|
||||||
|
sequence
|
||||||
|
);
|
||||||
|
|
||||||
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [
|
||||||
|
accessory,
|
||||||
|
]);
|
||||||
|
this.accessories.push(accessory);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private pruneAccessories(): void {
|
||||||
|
// Remove devices not discovered
|
||||||
|
const listOfConfiguredAccessories = [
|
||||||
|
...this.config.DeviceButtons.map((e) => e.DisplayName),
|
||||||
|
...this.config.Sequences.map((e) => e.DisplayName),
|
||||||
|
...this.config.ControlUnits.map((e) => e.DisplayName),
|
||||||
|
];
|
||||||
|
for (const accessory of this.accessories) {
|
||||||
|
if (
|
||||||
|
listOfConfiguredAccessories.filter(
|
||||||
|
(displayName) => displayName === accessory.displayName
|
||||||
|
).length === 0
|
||||||
|
) {
|
||||||
|
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [
|
||||||
|
accessory,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
configureAccessory(accessory: PlatformAccessory<Record<string, any>>): void {
|
configureAccessory(accessory: PlatformAccessory<Record<string, any>>): void {
|
||||||
this.log.info("Loading accessory from cache:", accessory.displayName);
|
this.log.info("Loading accessory from cache:", accessory.displayName);
|
||||||
|
|
||||||
// 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);
|
||||||
|
container.registerSingleton<ActivityService>(ActivityService);
|
||||||
|
container.registerSingleton<StateDataProvider>(StateDataProvider);
|
||||||
|
container.registerSingleton<CommandService>(CommandService);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
243
src/services/activityService.ts
Normal file
243
src/services/activityService.ts
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
import { Logging } from "homebridge";
|
||||||
|
import { inject, injectable } from "tsyringe";
|
||||||
|
import { HarmonyDataProvider } from "../dataProviders/harmonyDataProvider";
|
||||||
|
import { StateDataProvider } from "../dataProviders/stateDataProvider";
|
||||||
|
import { IActivityState } from "../models/activityState";
|
||||||
|
import {
|
||||||
|
IActivity,
|
||||||
|
IConfig,
|
||||||
|
IDeviceSetupItem,
|
||||||
|
IInput,
|
||||||
|
IOutput,
|
||||||
|
} from "../models/config";
|
||||||
|
import { HarmonyDevice } from "../models/harmonyDevice";
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class ActivityService {
|
||||||
|
constructor(
|
||||||
|
@inject(HarmonyDataProvider)
|
||||||
|
private _harmonyDataProvider: HarmonyDataProvider,
|
||||||
|
@inject(StateDataProvider) private _stateDataProvider: StateDataProvider,
|
||||||
|
@inject("IConfig") private _config: IConfig,
|
||||||
|
@inject("log") private _log: Logging
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public startLastOrDefaultActivity = async (
|
||||||
|
controlUnitName: string,
|
||||||
|
defaultActivity: IActivity
|
||||||
|
) => {
|
||||||
|
const lastActivity = this.getLastActivity(controlUnitName);
|
||||||
|
if (!lastActivity) {
|
||||||
|
return this.startActivity(controlUnitName, defaultActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.startActivity(controlUnitName, lastActivity);
|
||||||
|
};
|
||||||
|
|
||||||
|
public startActivity = async (
|
||||||
|
controlUnitName: string,
|
||||||
|
activity: IActivity
|
||||||
|
) => {
|
||||||
|
this._log.info(
|
||||||
|
`Starting activity ${activity.DisplayName} for controlUnit: ${controlUnitName}`
|
||||||
|
);
|
||||||
|
let devicesToTurnOn: Array<HarmonyDevice> = this.getDevicesToTurnOn(
|
||||||
|
activity,
|
||||||
|
controlUnitName
|
||||||
|
);
|
||||||
|
|
||||||
|
await this._harmonyDataProvider.powerOnDevices(devicesToTurnOn);
|
||||||
|
|
||||||
|
await this.assignDeviceInput(activity);
|
||||||
|
|
||||||
|
await this.routeInputsToOutputs(activity);
|
||||||
|
|
||||||
|
let lastActivity = this.getCurrentActivity(controlUnitName);
|
||||||
|
|
||||||
|
let devicesToTurnOff: Array<HarmonyDevice> = this.getDevicesToTurnOff(
|
||||||
|
controlUnitName,
|
||||||
|
lastActivity,
|
||||||
|
activity
|
||||||
|
);
|
||||||
|
await this._harmonyDataProvider.powerOffDevices(devicesToTurnOff);
|
||||||
|
|
||||||
|
this._stateDataProvider.updateState(activity, controlUnitName);
|
||||||
|
};
|
||||||
|
|
||||||
|
public stopCurrentActivity = async (
|
||||||
|
controlUnitName: string
|
||||||
|
): Promise<void> => {
|
||||||
|
if (!this.getCurrentActivity(controlUnitName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let lastActivity: IActivity | undefined =
|
||||||
|
this.getCurrentActivity(controlUnitName);
|
||||||
|
|
||||||
|
let devicesToTurnOff: Array<HarmonyDevice> = this.getDevicesToTurnOff(
|
||||||
|
controlUnitName,
|
||||||
|
lastActivity
|
||||||
|
);
|
||||||
|
await this._harmonyDataProvider.powerOffDevices(devicesToTurnOff);
|
||||||
|
|
||||||
|
this._stateDataProvider.deactivateState(controlUnitName);
|
||||||
|
};
|
||||||
|
|
||||||
|
public getCurrentActivity(controlUnitName: string): IActivity | undefined {
|
||||||
|
return this._stateDataProvider.getState(controlUnitName)?.currentActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getLastActivity(controlUnitName: string): IActivity | undefined {
|
||||||
|
return this._stateDataProvider.getState(controlUnitName)?.lastActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if a control unit is active
|
||||||
|
* @param controlUnitName
|
||||||
|
*/
|
||||||
|
public getIsActive(controlUnitName: string): boolean {
|
||||||
|
const state = this._stateDataProvider.getState(controlUnitName);
|
||||||
|
return state != undefined && state.currentActivity != undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to make sure no control unit depends on device list.
|
||||||
|
* @param devicesToTurnOn The list of devices to modify.
|
||||||
|
* @param controlUnitName The name of the control unit in question.
|
||||||
|
*/
|
||||||
|
private sanitizeDeviceList(
|
||||||
|
devicesToTurnOn: Array<HarmonyDevice>,
|
||||||
|
controlUnitName: string
|
||||||
|
): Array<HarmonyDevice> {
|
||||||
|
for (let controlUnitKey in this._stateDataProvider.states) {
|
||||||
|
//Skip self
|
||||||
|
if (controlUnitKey === controlUnitName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let currentOtherState: IActivityState =
|
||||||
|
this._stateDataProvider.states[controlUnitKey]!;
|
||||||
|
|
||||||
|
if (!currentOtherState || !currentOtherState.currentActivity) {
|
||||||
|
return devicesToTurnOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentOtherState.currentActivity!.DeviceSetupList.forEach(
|
||||||
|
(value: IDeviceSetupItem) => {
|
||||||
|
//there are devices to remove
|
||||||
|
if (devicesToTurnOn.some((e) => e && e.name === value.DeviceName)) {
|
||||||
|
let deviceToRemove: HarmonyDevice = devicesToTurnOn.filter(
|
||||||
|
(i) => i.name === value.DeviceName
|
||||||
|
)[0];
|
||||||
|
delete devicesToTurnOn[devicesToTurnOn.indexOf(deviceToRemove)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return devicesToTurnOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDevicesToTurnOn(
|
||||||
|
activity: IActivity,
|
||||||
|
controlUnitName: string
|
||||||
|
): Array<HarmonyDevice> {
|
||||||
|
let potentialDevices = this.buildPotentialDeviceList(activity);
|
||||||
|
return this.sanitizeDeviceList(potentialDevices, controlUnitName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDevicesToTurnOff(
|
||||||
|
controlUnitName: string,
|
||||||
|
lastActivity?: IActivity,
|
||||||
|
nextActivity?: IActivity
|
||||||
|
) {
|
||||||
|
let potentialDevices = lastActivity
|
||||||
|
? this.buildPotentialDeviceList(lastActivity)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
//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
|
||||||
|
if (nextActivity) {
|
||||||
|
potentialDevices.forEach((device: HarmonyDevice, index: number) => {
|
||||||
|
if (
|
||||||
|
device &&
|
||||||
|
device.name &&
|
||||||
|
nextActivity.DeviceSetupList.some((e) => {
|
||||||
|
return e && e.DeviceName === device.name;
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
delete potentialDevices[index];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.sanitizeDeviceList(potentialDevices, controlUnitName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildPotentialDeviceList(activity: IActivity): HarmonyDevice[] {
|
||||||
|
return activity.DeviceSetupList.map(
|
||||||
|
(value: IDeviceSetupItem): HarmonyDevice => {
|
||||||
|
return this._harmonyDataProvider.getDeviceByName(value.DeviceName);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async assignDeviceInput(activity: IActivity): Promise<void> {
|
||||||
|
await Promise.all(
|
||||||
|
activity.DeviceSetupList.map(async (value: IDeviceSetupItem) => {
|
||||||
|
let device: HarmonyDevice = this._harmonyDataProvider.getDeviceByName(
|
||||||
|
value.DeviceName
|
||||||
|
);
|
||||||
|
|
||||||
|
if (device && device.supportsCommand(`Input${value.Input}`)) {
|
||||||
|
await this._harmonyDataProvider.sendCommand(
|
||||||
|
`Input${value.Input}`,
|
||||||
|
device
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async routeInputsToOutputs(activity: IActivity) {
|
||||||
|
if (activity.UseMatrix) {
|
||||||
|
//get input and output
|
||||||
|
let input: IInput = this._config.Matrix.Inputs.filter(
|
||||||
|
(e) => e.InputDevice === activity.ControlDevice
|
||||||
|
)[0];
|
||||||
|
let output: IOutput = this._config.Matrix.Outputs.filter(
|
||||||
|
(e) => e.OutputDevice === activity.OutputDevice
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
let inputCommandName: string = `In ${input.InputNumber}`;
|
||||||
|
let outputCommandName: string = `Out ${output.OutputLetter}`;
|
||||||
|
|
||||||
|
let matrixDevice: HarmonyDevice =
|
||||||
|
this._harmonyDataProvider.getDeviceByName(
|
||||||
|
this._config.Matrix.DeviceName
|
||||||
|
);
|
||||||
|
|
||||||
|
//Route hdmi
|
||||||
|
if (
|
||||||
|
matrixDevice.supportsCommand(inputCommandName) &&
|
||||||
|
matrixDevice.supportsCommand(outputCommandName)
|
||||||
|
) {
|
||||||
|
await this._harmonyDataProvider.sendCommand(
|
||||||
|
outputCommandName,
|
||||||
|
matrixDevice
|
||||||
|
);
|
||||||
|
await this._harmonyDataProvider.sendCommand(
|
||||||
|
inputCommandName,
|
||||||
|
matrixDevice
|
||||||
|
);
|
||||||
|
await this._harmonyDataProvider.sendCommand(
|
||||||
|
outputCommandName,
|
||||||
|
matrixDevice
|
||||||
|
);
|
||||||
|
await this._harmonyDataProvider.sendCommand(
|
||||||
|
inputCommandName,
|
||||||
|
matrixDevice
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
71
src/services/commandService.ts
Normal file
71
src/services/commandService.ts
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { inject, injectable } from "tsyringe";
|
||||||
|
import { RemoteKey } from "../accessories/controlUnit";
|
||||||
|
import { HarmonyDataProvider } from "../dataProviders/harmonyDataProvider";
|
||||||
|
import { StateDataProvider } from "../dataProviders/stateDataProvider";
|
||||||
|
import { HarmonyDevice } from "../models/harmonyDevice";
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class CommandService {
|
||||||
|
constructor(
|
||||||
|
@inject(StateDataProvider) private _stateDataProvider: StateDataProvider,
|
||||||
|
@inject(HarmonyDataProvider)
|
||||||
|
private _harmonyDataProvider: HarmonyDataProvider
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send key press for current activity.
|
||||||
|
*
|
||||||
|
* @param controlUnitName The name of the control unit to act on.
|
||||||
|
* @param key The key to send.
|
||||||
|
*/
|
||||||
|
public sendKeyPress = async (controlUnitName: string, key: any) => {
|
||||||
|
let currentActivity = this._stateDataProvider.getState(controlUnitName);
|
||||||
|
if (currentActivity) {
|
||||||
|
let commandName: string = "";
|
||||||
|
|
||||||
|
let device: HarmonyDevice = this._harmonyDataProvider.getDeviceByName(
|
||||||
|
currentActivity.currentActivity!.ControlDevice
|
||||||
|
);
|
||||||
|
switch (key) {
|
||||||
|
case RemoteKey.ARROW_UP: {
|
||||||
|
commandName = "Direction Up";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RemoteKey.ARROW_DOWN: {
|
||||||
|
commandName = "Direction Down";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RemoteKey.ARROW_LEFT: {
|
||||||
|
commandName = "Direction Left";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RemoteKey.ARROW_RIGHT: {
|
||||||
|
commandName = "Direction Right";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RemoteKey.SELECT: {
|
||||||
|
commandName = "Select";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RemoteKey.PLAY_PAUSE: {
|
||||||
|
commandName = "Pause";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RemoteKey.INFORMATION: {
|
||||||
|
commandName = "Menu";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RemoteKey.BACK: {
|
||||||
|
commandName = "Back";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RemoteKey.EXIT: {
|
||||||
|
commandName = "Back";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await this._harmonyDataProvider.sendCommand(commandName, device);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
49
src/services/volumeService.ts
Normal file
49
src/services/volumeService.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { inject, injectable } from "tsyringe";
|
||||||
|
import { HarmonyDataProvider } from "../dataProviders/harmonyDataProvider";
|
||||||
|
import { StateDataProvider } from "../dataProviders/stateDataProvider";
|
||||||
|
import { HarmonyDevice } from "../models/harmonyDevice";
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class VolumeService {
|
||||||
|
constructor(
|
||||||
|
@inject(StateDataProvider) private _stateDataProvider: StateDataProvider,
|
||||||
|
@inject(HarmonyDataProvider)
|
||||||
|
private _harmonyDataProvider: HarmonyDataProvider
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn the volume up for the current running activity.
|
||||||
|
*/
|
||||||
|
public volumeUp = async (controlUnitName: string) => {
|
||||||
|
let volumeUpCommand: string = "Volume Up";
|
||||||
|
let currentState = this._stateDataProvider.getState(controlUnitName);
|
||||||
|
if (currentState) {
|
||||||
|
let volumeDevice: HarmonyDevice =
|
||||||
|
this._harmonyDataProvider.getDeviceByName(
|
||||||
|
currentState.currentActivity!.VolumeDevice
|
||||||
|
);
|
||||||
|
await this._harmonyDataProvider.sendCommand(
|
||||||
|
volumeUpCommand,
|
||||||
|
volumeDevice
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Volume down for current running activity.
|
||||||
|
*/
|
||||||
|
public volumeDown = async (controlUnitName: string) => {
|
||||||
|
let volumeDownCommand: string = "Volume Down";
|
||||||
|
let currentState = this._stateDataProvider.getState(controlUnitName);
|
||||||
|
if (currentState) {
|
||||||
|
let volumeDevice: HarmonyDevice =
|
||||||
|
this._harmonyDataProvider.getDeviceByName(
|
||||||
|
currentState.currentActivity!.VolumeDevice
|
||||||
|
);
|
||||||
|
await this._harmonyDataProvider.sendCommand(
|
||||||
|
volumeDownCommand,
|
||||||
|
volumeDevice
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -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";
|
||||||
|
2
src/util/index.ts
Normal file
2
src/util/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from "./callbackify";
|
||||||
|
export * from "./sleep";
|
@ -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__/*"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user