-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #259 from Drenso/add-vibration-sensor
Add vibration sensor
- Loading branch information
Showing
20 changed files
with
254 additions
and
16 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
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
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,24 @@ | ||
import TuyaOAuth2DeviceSensor from '../../lib/sensor/TuyaOAuth2DeviceSensor'; | ||
import { TuyaStatus } from '../../types/TuyaTypes'; | ||
|
||
module.exports = class TuyaOAuth2DeviceSensorVibration extends TuyaOAuth2DeviceSensor { | ||
async onOAuth2Init(): Promise<void> { | ||
await this.initAlarm('alarm_vibration').catch(this.error); | ||
|
||
return super.onOAuth2Init(); | ||
} | ||
|
||
async onTuyaStatus(status: TuyaStatus, changedStatusCodes: string[]): Promise<void> { | ||
await super.onTuyaStatus(status, changedStatusCodes); | ||
|
||
for (const tuyaCapability in status) { | ||
const value = status[tuyaCapability]; | ||
if ( | ||
tuyaCapability === 'shock_state' && | ||
(!this.getSetting('use_alarm_timeout') || changedStatusCodes.includes(tuyaCapability)) | ||
) { | ||
this.setAlarmCapabilityValue('alarm_vibration', value !== 'normal').catch(this.error); | ||
} | ||
} | ||
} | ||
}; |
Oops, something went wrong.