obniz Parts Library

Switchbot_MotionSensor

GitHub
Switchbot_MotionSensor
Usable Devices :
obniz_board
m5stickc
obnizble
esp32
esp32gateway
m5stackbasic
ak-030
obnizble_lte
obniz_plc

Switchbot_MotionSensor

Switchbot Motion Sensor (WoMotion) module

getData()

  • battery: number;
  • scopeTested: boolean;
  • someoneIsMoving: boolean;
  • pirUtc: number;
  • ledState: 'enable' | 'disable';
  • iotState: 'enable' | 'disable';
  • sensingDistance: 'long' | 'middle' | 'short';
  • lightIntensity: 'dark' | 'bright';

Example

// Javascript
const Switchbot_MotionSensor = Obniz.getPartsClass("Switchbot_MotionSensor");
await obniz.ble.initWait();
obniz.ble.scan.onfind = async (peripheral) => {
  if (Switchbot_MotionSensor.isDevice(peripheral)) {
    console.log(Switchbot_MotionSensor.getData(peripheral));
  }
};
await obniz.ble.scan.startWait(null, {duplicate: true, duration: null});

Supported from: obniz.js 3.30.0