mqtt: add motion sensor example

This commit is contained in:
Koushik Dutta
2022-10-24 19:56:31 -07:00
parent 36a8622a05
commit ba64d05044
3 changed files with 16 additions and 3 deletions

View 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);

View File

@@ -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",

View File

@@ -41,5 +41,5 @@
"@scrypted/common": "file:../../common",
"@types/nunjucks": "^3.2.0"
},
"version": "0.0.56"
"version": "0.0.57"
}