homebridge-miot
Version:
Homebridge plugin for devices supporting the miot protocol
86 lines (47 loc) • 1.81 kB
JavaScript
const BaseDevice = require('../../base/BaseDevice.js');
const Constants = require('../../constants/Constants.js');
const DevTypes = require('../../constants/DevTypes.js');
const PropFormat = require('../../constants/PropFormat.js');
const PropUnit = require('../../constants/PropUnit.js');
const PropAccess = require('../../constants/PropAccess.js');
class MotionSensorDevice extends BaseDevice {
constructor(device, name, logger) {
super(device, name, logger);
}
/*----------========== LIFECYCLE ==========----------*/
initialPropertyFetchDone() {
super.initialPropertyFetchDone();
}
/*----------========== DEVICE INFO ==========----------*/
getType() {
return DevTypes.MOTION_SENSOR;
}
getDeviceName() {
return 'Unknown motion sensor device';
}
getMainService() {
return this.getServiceByType('motion-sensor');
}
/*----------========== CONFIG ==========----------*/
propertiesToMonitor() {
return ['motion-sensor:motion-state', 'battery:battery-level'];
}
/*----------========== VALUES ==========----------*/
/*----------========== PROPERTIES ==========----------*/
//overrides
//device specific
motionStateProp() {
return this.getProperty('motion-sensor:motion-state');
}
/*----------========== ACTIONS ==========----------*/
/*----------========== FEATURES ==========----------*/
/*----------========== GETTERS ==========----------*/
isMotionStateOn() {
return this.getPropertyValue(this.motionStateProp());
}
/*----------========== SETTERS ==========----------*/
/*----------========== CONVENIENCE ==========----------*/
/*----------========== VALUE CONVENIENCE ==========----------*/
/*----------========== HELPERS ==========----------*/
}
module.exports = MotionSensorDevice;