mirror of
https://github.com/koush/scrypted.git
synced 2026-02-11 01:32:02 +00:00
mqtt: add motion sensor example
This commit is contained in:
13
plugins/mqtt/fs/examples/motion-sensor.ts
Normal file
13
plugins/mqtt/fs/examples/motion-sensor.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { ScriptDevice } from "@scrypted/common/src/eval/monaco/script-device"; // SCRYPTED_FILTER_EXAMPLE_LINE
|
||||
import { ScryptedDeviceBase, ScryptedInterface } from "@scrypted/sdk"; // SCRYPTED_FILTER_EXAMPLE_LINE
|
||||
import { MqttClient } from "../../src/api/mqtt-client"; // SCRYPTED_FILTER_EXAMPLE_LINE
|
||||
declare const device: ScriptDevice & ScryptedDeviceBase; // SCRYPTED_FILTER_EXAMPLE_LINE
|
||||
declare const mqtt: MqttClient; // SCRYPTED_FILTER_EXAMPLE_LINE
|
||||
|
||||
mqtt.subscribe({
|
||||
// this example expects the device to publish either ON or OFF text values
|
||||
// to the mqtt endpoint.
|
||||
'/': value => device.motionDetected = value.text === 'ON',
|
||||
});
|
||||
|
||||
mqtt.handleTypes(ScryptedInterface.MotionSensor);
|
||||
4
plugins/mqtt/package-lock.json
generated
4
plugins/mqtt/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/mqtt",
|
||||
"version": "0.0.56",
|
||||
"version": "0.0.57",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/mqtt",
|
||||
"version": "0.0.56",
|
||||
"version": "0.0.57",
|
||||
"dependencies": {
|
||||
"@types/node": "^16.6.1",
|
||||
"aedes": "^0.46.1",
|
||||
|
||||
@@ -41,5 +41,5 @@
|
||||
"@scrypted/common": "file:../../common",
|
||||
"@types/nunjucks": "^3.2.0"
|
||||
},
|
||||
"version": "0.0.56"
|
||||
"version": "0.0.57"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user