Skip to main content

Motion

caution

This service is experimental and may change in the future.

A sensor, typically PIR, that detects object motion within a certain range

import { Motion } from "@devicescript/core"

const motion = new Motion()

Registers

reading

Reports is movement is currently detected by the sensor.

  • type: Register<boolean> (packing format u8)

  • read only

import { Motion } from "@devicescript/core"

const motion = new Motion()
// ...
const value = await motion.reading.read()
  • track incoming values
import { Motion } from "@devicescript/core"

const motion = new Motion()
// ...
motion.reading.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

maxDistance

Maximum distance where objects can be detected.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { Motion } from "@devicescript/core"

const motion = new Motion()
// ...
const value = await motion.maxDistance.read()
note

write and read will block until a server is bound to the client.

angle

Opening of the field of view

  • type: Register<number> (packing format u16)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { Motion } from "@devicescript/core"

const motion = new Motion()
// ...
const value = await motion.angle.read()
note

write and read will block until a server is bound to the client.

variant

Type of physical sensor

  • type: Register<number> (packing format u8)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { Motion } from "@devicescript/core"

const motion = new Motion()
// ...
const value = await motion.variant.read()
note

write and read will block until a server is bound to the client.

Events

movement

A movement was detected.

motion.movement.subscribe(() => {

})