import { Device } from "./device" ; import { IDeviceInterface } from "../interfaces" ; import * as Consts from "../consts" ; class extends Device export class MotionSensor extends Device { constructor ( hub , portId ) { super ( hub , portId , ModeMap , Consts . DeviceType . MOTION_SENSOR ) ; } public receive ( message ) { const mode = this . _mode ; switch ( mode ) { case Mode . DISTANCE : let distance = message [ this . isWeDo2SmartHub ? 2 : 4 ] ; if ( message [ this . isWeDo2SmartHub ? 3 : 5 ] === 1 ) { distance = distance + 255 ; } distance *= 10 ; event type { object } param { number } distance this . notify ( "distance" , { distance } ) ; break ; } } } export enum Mode { DISTANCE = 0x00 } export const ModeMap = { "distance" : Mode . DISTANCE } ;