From 76662fbcd6862f07f212c069f7c7418ed6f2585d Mon Sep 17 00:00:00 2001 From: Pascal Kirtz Date: Sat, 20 Feb 2021 01:33:02 +0100 Subject: [PATCH 1/8] Added support for shelly motion --- accessories/factory.js | 17 ++++++++++++++++- accessories/sensors.js | 11 +++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/accessories/factory.js b/accessories/factory.js index c675007..fc087be 100644 --- a/accessories/factory.js +++ b/accessories/factory.js @@ -29,6 +29,7 @@ module.exports = homebridge => { ShellyRelayMotionSensorAccessory, ShellyRelayOccupancySensorAccessory, ShellySenseAccessory, + ShellyMotionAccessory, } = require('./sensors')(homebridge) const { @@ -559,7 +560,21 @@ module.exports = homebridge => { return new ShellyFloodAccessory(this.device, ...opts) } } - FACTORIES.set('SHWT-1', ShellyFloodFactory) + FACTORIES.set('SHWT-1', ShellyFloodFactory) + + /** + * Shelly Motion factory. + */ + class ShellyMotionFactory extends AccessoryFactory { + get defaultAccessoryType() { + return 'sensor' + } + + _createAccessory(accessoryType, ...opts) { + return new ShellyMotionAccessory(this.device, ...opts) + } + } + FACTORIES.set('SHMOS-01', ShellyMotionFactory) /** * Returns the factory for the given device. diff --git a/accessories/sensors.js b/accessories/sensors.js index a849fa4..56f9b66 100644 --- a/accessories/sensors.js +++ b/accessories/sensors.js @@ -142,6 +142,16 @@ module.exports = homebridge => { } } + class ShellyMotionAccessory extends ShellySensorAccessory { + constructor(device, index, config, log) { + super(device, index, config, log, [ + new MotionSensorAbility('motion'), + new LightSensorAbility('illuminance'), + new BatteryAbility('battery'), + ]); + } + } + return { ShellyDoorWindowAccessory, ShellyDoorWindow2Accessory, @@ -152,5 +162,6 @@ module.exports = homebridge => { ShellyRelayMotionSensorAccessory, ShellyRelayOccupancySensorAccessory, ShellySenseAccessory, + ShellyMotionAccessory, } } From 4122a11895376935ae7d3e16c6e270005a9f13f1 Mon Sep 17 00:00:00 2001 From: Alexander Ryden Date: Tue, 23 Feb 2021 21:34:04 +0100 Subject: [PATCH 2/8] Update shellies to 1.4.0 --- package-lock.json | 24 ++++++++++++------------ package.json | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4b8cec8..343489a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -252,9 +252,9 @@ "dev": true }, "bl": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz", - "integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", "requires": { "buffer": "^5.5.0", "inherits": "^2.0.4", @@ -1810,9 +1810,9 @@ "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" }, "mime": { - "version": "2.4.7", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.7.tgz", - "integrity": "sha512-dhNd1uA2u397uQk3Nv5LM4lm93WYDUXFn3Fu291FJerns4jyTudqhIWe4W04YLy7Uk1tm1Ore04NpjRvQp/NPA==" + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", + "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==" }, "mime-db": { "version": "1.40.0", @@ -2303,9 +2303,9 @@ "dev": true }, "qs": { - "version": "6.9.4", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", - "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==" + "version": "6.9.6", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.6.tgz", + "integrity": "sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ==" }, "randombytes": { "version": "2.1.0", @@ -2519,9 +2519,9 @@ "dev": true }, "shellies": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/shellies/-/shellies-1.3.0.tgz", - "integrity": "sha512-W0m2la5d3YOBfLfE6g9M4JqupGK169+MyysIGgj/5u/jCmvdBbDoO6LEP4WEoiy5y5N1CPZ/lmoAY04EgO5VMQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/shellies/-/shellies-1.4.0.tgz", + "integrity": "sha512-hIay2fDlVkGttoh59rzfsgN8LsclFhqMT3tdOvaihtN+Rp/IpGh7AtBd2I92W8zovWux5Sd9VG+6PoBLNi2f3Q==", "requires": { "coap": "^0.24.0", "colors": "^1.3.3", diff --git a/package.json b/package.json index 08447cf..da12add 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "colors": "^1.3.3", "command-line-commands": "^2.0.1", "express": "^4.17.1", - "shellies": "^1.3.0" + "shellies": "^1.4.0" }, "devDependencies": { "eslint": "^7.5.0", From 17090e0b481b7553c69c79c4272b77633808f62b Mon Sep 17 00:00:00 2001 From: Alexander Ryden Date: Tue, 23 Feb 2021 21:38:52 +0100 Subject: [PATCH 3/8] ESLint fixes --- accessories/factory.js | 14 +++++++------- accessories/sensors.js | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/accessories/factory.js b/accessories/factory.js index fc087be..f43d173 100644 --- a/accessories/factory.js +++ b/accessories/factory.js @@ -560,19 +560,19 @@ module.exports = homebridge => { return new ShellyFloodAccessory(this.device, ...opts) } } - FACTORIES.set('SHWT-1', ShellyFloodFactory) + FACTORIES.set('SHWT-1', ShellyFloodFactory) /** * Shelly Motion factory. */ class ShellyMotionFactory extends AccessoryFactory { - get defaultAccessoryType() { - return 'sensor' - } + get defaultAccessoryType() { + return 'sensor' + } - _createAccessory(accessoryType, ...opts) { - return new ShellyMotionAccessory(this.device, ...opts) - } + _createAccessory(accessoryType, ...opts) { + return new ShellyMotionAccessory(this.device, ...opts) + } } FACTORIES.set('SHMOS-01', ShellyMotionFactory) diff --git a/accessories/sensors.js b/accessories/sensors.js index 56f9b66..f668085 100644 --- a/accessories/sensors.js +++ b/accessories/sensors.js @@ -143,13 +143,13 @@ module.exports = homebridge => { } class ShellyMotionAccessory extends ShellySensorAccessory { - constructor(device, index, config, log) { - super(device, index, config, log, [ + constructor(device, index, config, log) { + super(device, index, config, log, [ new MotionSensorAbility('motion'), new LightSensorAbility('illuminance'), new BatteryAbility('battery'), - ]); - } + ]) + } } return { From 2fd180da75e25f71a78db3ec44c640171687cef3 Mon Sep 17 00:00:00 2001 From: Alexander Ryden Date: Tue, 23 Feb 2021 21:39:34 +0100 Subject: [PATCH 4/8] Add Shelly Motion to the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b9d3358..7d12c3c 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Note that this is an unofficial plugin. * Shelly HD * [Shelly H&T](https://shelly.cloud/shelly-humidity-and-temperature/) * [Shelly i3](https://shelly.cloud/products/shelly-i3-smart-home-automation-device/) +* [Shelly Motion](https://shelly.cloud/shelly-motion-smart-home-automation-sensor/) * [Shelly Plug](https://shelly.cloud/shelly-plug/) * [Shelly Plug S](https://shelly.cloud/shelly-plug-s/) * [Shelly Plug US](https://shelly.cloud/products/shelly-plug-us-smart-home-automation-device/) From 02d02d0325c2cdac1b7275b4d92d88a3a7d021d1 Mon Sep 17 00:00:00 2001 From: Alexander Ryden Date: Tue, 23 Feb 2021 21:40:28 +0100 Subject: [PATCH 5/8] Version 0.17.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 343489a..ec17322 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-shelly", - "version": "0.16.0", + "version": "0.17.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index da12add..42d5df1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-shelly", - "version": "0.16.0", + "version": "0.17.0", "description": "Shelly plugin for Homebridge", "main": "index.js", "bin": "bin/homebridge-shelly", From 54f570489b9b5a3dffe05e0ec3e743e9868e8dee Mon Sep 17 00:00:00 2001 From: Alexander Ryden Date: Sun, 28 Feb 2021 09:44:36 +0100 Subject: [PATCH 6/8] Update shellies to 1.5.0 --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index ec17322..0fd2339 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2519,9 +2519,9 @@ "dev": true }, "shellies": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/shellies/-/shellies-1.4.0.tgz", - "integrity": "sha512-hIay2fDlVkGttoh59rzfsgN8LsclFhqMT3tdOvaihtN+Rp/IpGh7AtBd2I92W8zovWux5Sd9VG+6PoBLNi2f3Q==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/shellies/-/shellies-1.5.0.tgz", + "integrity": "sha512-mD+5eN0BB4DsngaqWN2kiq/DtbvTuvP0maWVrvq/UqEhU2WVGsXsD2UMnZCEsLx3HNN06MJxEjvGLpAVikod7g==", "requires": { "coap": "^0.24.0", "colors": "^1.3.3", diff --git a/package.json b/package.json index 42d5df1..5752756 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "colors": "^1.3.3", "command-line-commands": "^2.0.1", "express": "^4.17.1", - "shellies": "^1.4.0" + "shellies": "^1.5.0" }, "devDependencies": { "eslint": "^7.5.0", From e04717a442fe0305672422258e3768f8d45fb98b Mon Sep 17 00:00:00 2001 From: Alexander Ryden Date: Sun, 28 Feb 2021 09:45:34 +0100 Subject: [PATCH 7/8] Version 0.18.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0fd2339..8b1e1a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-shelly", - "version": "0.17.0", + "version": "0.18.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5752756..e75ad4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-shelly", - "version": "0.17.0", + "version": "0.18.0", "description": "Shelly plugin for Homebridge", "main": "index.js", "bin": "bin/homebridge-shelly", From d10db86b50de2507cbc2f05e5347070d68dca2d1 Mon Sep 17 00:00:00 2001 From: Alexander Ryden Date: Sun, 28 Feb 2021 09:49:44 +0100 Subject: [PATCH 8/8] Add a note about setting the UDP unicast remote address option --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d12c3c..d46472b 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Note that this is an unofficial plugin. * Shelly HD * [Shelly H&T](https://shelly.cloud/shelly-humidity-and-temperature/) * [Shelly i3](https://shelly.cloud/products/shelly-i3-smart-home-automation-device/) -* [Shelly Motion](https://shelly.cloud/shelly-motion-smart-home-automation-sensor/) +* [Shelly Motion](https://shelly.cloud/shelly-motion-smart-home-automation-sensor/) 4 * [Shelly Plug](https://shelly.cloud/shelly-plug/) * [Shelly Plug S](https://shelly.cloud/shelly-plug-s/) * [Shelly Plug US](https://shelly.cloud/products/shelly-plug-us-smart-home-automation-device/) @@ -51,6 +51,10 @@ must have been calibrated and be running firmware version 1.4.9 or later. 3 Requires firmware version 1.8.0 or later. +4 Requires setting the `Internet & Security -> CoIoT -> Remote +address` option on the Shelly device to the IP address of your device running +homebridge. + ## Installation 1. Install Homebridge by following [the instructions](https://github.com/homebridge/homebridge/wiki).