-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for newer magnet and motion devices and add support…
… for cube (#9) * new motion sensor with light intensity measurements * added support for newer magnet sensors * added support for the cube
- Loading branch information
1 parent
1a0d3f4
commit 03d2020
Showing
4 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const Subdevice = require('./subdevice') | ||
|
||
class Cube extends Subdevice { | ||
constructor (opts) { | ||
super({ sid: opts.sid, type: 'cube' }) | ||
|
||
this._status = null | ||
this._rotateDegrees = null | ||
} | ||
|
||
_handleState (state) { | ||
super._handleState(state) | ||
|
||
if ('rotate' in state) { | ||
this._status = 'rotate' | ||
this._rotateDegrees = state.rotate | ||
} else { | ||
this._status = state.status | ||
this._rotateDegrees = null | ||
} | ||
|
||
this.emit('update') | ||
|
||
} | ||
|
||
getStatus () { | ||
return this._status | ||
} | ||
getRotateDegrees () { | ||
return this._rotateDegrees | ||
} | ||
} | ||
|
||
module.exports = Cube |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters