Skip to content

Commit

Permalink
Merge branch 'master' into disable-sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschilling committed Feb 28, 2021
2 parents 5520639 + d10db86 commit 15e3823
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/) <sup>4</sup>
* [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/)
Expand All @@ -50,6 +51,10 @@ must have been calibrated and be running firmware version 1.4.9 or later.

<sup>3</sup> Requires firmware version 1.8.0 or later.

<sup>4</sup> 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).
Expand Down
15 changes: 15 additions & 0 deletions accessories/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = homebridge => {
ShellyRelayMotionSensorAccessory,
ShellyRelayOccupancySensorAccessory,
ShellySenseAccessory,
ShellyMotionAccessory,
} = require('./sensors')(homebridge)

const {
Expand Down Expand Up @@ -561,6 +562,20 @@ module.exports = homebridge => {
}
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.
*/
Expand Down
11 changes: 11 additions & 0 deletions accessories/sensors.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,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,
Expand All @@ -187,5 +197,6 @@ module.exports = homebridge => {
ShellyRelayMotionSensorAccessory,
ShellyRelayOccupancySensorAccessory,
ShellySenseAccessory,
ShellyMotionAccessory,
}
}
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-shelly",
"version": "0.16.0",
"version": "0.18.0",
"description": "Shelly plugin for Homebridge",
"main": "index.js",
"bin": "bin/homebridge-shelly",
Expand Down Expand Up @@ -37,7 +37,7 @@
"colors": "^1.3.3",
"command-line-commands": "^2.0.1",
"express": "^4.17.1",
"shellies": "^1.3.0"
"shellies": "^1.5.0"
},
"devDependencies": {
"eslint": "^7.5.0",
Expand Down

0 comments on commit 15e3823

Please sign in to comment.