Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(thing, name, value, metadata, config) {
super(thing, name, new Value(Boolean(value)),
{
'@type': 'OnOffProperty',
title: (metadata && metadata.title) || `On/Off: ${name}`,
type: 'boolean',
description: (metadata && metadata.description) ||
(`GPIO Actuator on pin=${config.pin}`),
});
const self = this;
this.config = config;
this.port = gpio.export(config.pin,
{direction: 'out',
ready: () => {
log(`log: GPIO: ${self.getName()}: open:`);
self.value.valueForwarder = (value) => {
try {
log(`log: GPIO: ${self.getName()}: \
function makeThing() {
const thing = new Thing('urn:dev:ops:my-lamp-1234',
'My Lamp',
['OnOffSwitch', 'Light'],
'A web connected lamp');
thing.addProperty(
new Property(thing,
'on',
new Value(true),
{
'@type': 'OnOffProperty',
title: 'On/Off',
type: 'boolean',
description: 'Whether the lamp is turned on',
}));
thing.addProperty(
new Property(thing,
'brightness',
new Value(50),
{
'@type': 'BrightnessProperty',
title: 'Brightness',
type: 'integer',
description: 'The level of light from 0-100',
minimum: 0,
constructor() {
super(
'urn:dev:ops:my-humidity-sensor-1234',
'My Humidity Sensor',
['MultiLevelSensor'],
'A web connected humidity sensor'
);
this.level = new Value(0.0);
this.addProperty(
new Property(
this,
'level',
this.level,
{
'@type': 'LevelProperty',
title: 'Humidity',
type: 'number',
description: 'The current humidity in %',
minimum: 0,
maximum: 100,
unit: 'percent',
readOnly: true,
}));
function makeThing() {
const thing = new Thing('MastodonMultiLevelSwitchExample', 'multiLevelSwitch', 'An actuator example that just blog');
thing.addProperty(
new Property(thing,
'level',
new Value(0, handleLevelUpdate),
{
label: 'Level',
type: 'number',
description: 'Whether the output is changed',
}));
return thing;
}
'A web connected lamp');
thing.addProperty(
new Property(thing,
'on',
new Value(true),
{
'@type': 'OnOffProperty',
title: 'On/Off',
type: 'boolean',
description: 'Whether the lamp is turned on',
}));
thing.addProperty(
new Property(thing,
'brightness',
new Value(50),
{
'@type': 'BrightnessProperty',
title: 'Brightness',
type: 'integer',
description: 'The level of light from 0-100',
minimum: 0,
maximum: 100,
unit: 'percent',
}));
thing.addAvailableAction(
'fade',
{
title: 'Fade',
description: 'Fade the lamp to a given level',
input: {
function makeThing() {
const thing = new Thing('GpioBinarySensorExample',
'binarySensor',
'A sensor example that monitor GPIO input ie: button');
thing.value = new Value(false);
thing.addProperty(
new Property(thing,
'on',
thing.value,
{
'@type': 'OnOffProperty',
label: 'On/Off',
type: 'boolean',
description: 'Whether the input is changed'
}));
return thing;
}