How to use the webthing.Property function in webthing

To help you get started, we’ve selected a few webthing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rzr / webthing-iotjs / example / multiple-things.js View on Github external
constructor() {
    super(
      'urn:dev:ops:my-lamp-1234',
      'My Lamp',
      ['OnOffSwitch', 'Light'],
      'A web connected lamp'
    );

    this.addProperty(
      new Property(
        this,
        'on',
        new Value(true, (v) => console.log('On-State is now', v)),
        {
          '@type': 'OnOffProperty',
          title: 'On/Off',
          type: 'boolean',
          description: 'Whether the lamp is turned on',
        }));

    this.addProperty(
      new Property(
        this,
        'brightness',
        new Value(50, (v) => console.log('Brightness is now', v)),
        {
github rzr / webthing-iotjs / example / single-thing.js View on Github external
'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,
                   maximum: 100,
                   unit: 'percent',
                 }));

  thing.addAvailableAction(
    'fade',
    {
      title: 'Fade',
github rzr / webthing-iotjs / example / gpio-binary-sensor-thing.js View on Github external
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;
}
github rzr / webthing-iotjs / example / single-thing.js View on Github external
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',
github rzr / webthing-iotjs / example / mastodon-thing.js View on Github external
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;
}

webthing

HTTP Web Thing implementation

MPL-2.0
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis