Skip to content

Latest commit

 

History

History
738 lines (658 loc) · 28.6 KB

templates.md

File metadata and controls

738 lines (658 loc) · 28.6 KB

Code Templates

This document provides many templates of IPSO-defined devices (Smart Objects starter pack 1.0) for your reference in defining gadgets with smartobject.

  • Each template gives a code snippet of how to initialize an Object Instance with its oid and iid, and lists every Resource the Object Instance may have.
  • In a code snippet, commented lines are optional Resources. You are free to uncomment and define those optional Resources you like to use within an Object Instance.
  • A phrase < rid number, access, data type { range or enum }, unit > tells the numeric id, access permission, and data type of a Resource defined by IPSO.
  • Just copy and paste the snippets, then make some changes to fit your needs.

Catalog of Objects

3200 Digital Input 3201 Digital Output 3202 Analog Input 3203 Analog Output
3300 Generic Sensor 3301 Illuminance Sensor 3302 Presence Sensor 3303 Temperature Sensor
3304 Humidity Sensor 3305 Power Measurement 3306 Actuation 3308 Set Point
3310 Load Control 3311 Light Control 3312 Power Control 3313 Accelerometer
3314 Magnetometer 3315 Barometer 3316 Voltage 3317 Current
3318 Frequency 3319 Depth 3320 Percentage 3321 Altitude
3322 Load 3323 Pressure 3324 Loudness 3325 Concentration
3326 Acidity 3327 Conductivity 3328 Power 3329 Power Factor
3330 Distance 3331 Energy 3332 Direction 3333 Time
3334 Gyrometer 3335 Colour 3336 GPS Location 3337 Positioner
3338 Buzzer 3339 Audio Clip 3340 Timer 3341 Addressable Text Display
3342 On/Off Switch 3343 Level Controller 3344 Up/Down Controller 3345 Multiple Axis Joystick
3346 Rate 3347 Push Button 3348 Multi-state Selector

3200 Digital Input

// Digital Input (oid = 3200 or 'dIn')
so.init('dIn', 0, {
    dInState: {                     // < rid = 5500, R, Boolean >
        read: function (cb) {}
    },
    // counter: ,                   // < rid = 5501,  R, Integer >
    // dInPolarity: ,               // < rid = 5502, RW, Boolean >
    // debouncePeriod: ,            // < rid = 5503, RW, Integer, ms >
    // edgeSelection: ,             // < rid = 5504, RW, Integer { 1: fall, 2: rise, 3: both } >
    // counterReset: ,              // < rid = 5505,  E, Opaque >
    // appType: ,                   // < rid = 5750, RW, String >
    // sensorType:                  // < rid = 5751,  R, String >
});

3201 Digital Output

// Digital Output (oid = 3201 or 'dOut')
so.init('dOut', 0, {
    dOutState: {                    // < rid = 5550, RW, Boolean >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // dOutpolarity: ,              // < rid = 5551, RW, Boolean { 0: normal, 1: reversed } >
    // appType:                     // < rid = 5750, RW, String >
});

3202 Analog Input

// Analog Input (oid = 3202 or 'aIn')
so.init('aIn', 0, {
    aInCurrValue: {                 // < rid = 5600, R, Float >
        read: function (cb) {}
    },
    // minMeaValue: ,               // < rid = 5601,  R, Float >
    // maxMeaValue: ,               // < rid = 5602,  R, Float >
    // minRangeValue: ,             // < rid = 5603,  R, Float >
    // maxRangeValue: ,             // < rid = 5604,  R, Float >
    // resetMinMaxMeaValues: ,      // < rid = 5605,  E, Opaque >
    // appType: ,                   // < rid = 5750, RW, String >
    // sensorType:                  // < rid = 5751,  R, String >
});

3203 Analog Output

// Analog Output (oid = 3203 or 'aOut')
so.init('aOut', 0, {
    aOutCurrValue: {                // < rid = 5650, RW, Float >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // minRangeValue: ,             // < rid = 5603,  R, Float >
    // maxRangeValue: ,             // < rid = 5604,  R, Float >
    // appType:                     // < rid = 5750, RW, String >
});

3300 Generic Sensor

// Generic Sensor (oid = 3300 or 'generic')
so.init('generic', 0, {
    sensorValue: {                  // < rid = 5700, R, Float >
        read: function (cb) {}
    },
    // units: ,                     // < rid = 5701,  R, String >
    // minMeaValue: ,               // < rid = 5601,  R, Float >
    // maxMeaValue: ,               // < rid = 5602,  R, Float >
    // minRangeValue: ,             // < rid = 5603,  R, Float >
    // maxRangeValue: ,             // < rid = 5604,  R, Float >
    // resetMinMaxMeaValues: ,      // < rid = 5605,  E, Opaque >
    // appType: ,                   // < rid = 5750, RW, String >
    // sensorType:                  // < rid = 5751,  R, String >
});

3301 Illuminance Sensor

// Illuminance Sensor (oid = 3301 or 'illuminance')
so.init('illuminance', 0, {
    sensorValue: {                  // < rid = 5700, R, Float >
        read: function (cb) {}
    },
    // units: ,                     // < rid = 5701, R, String >
    // minMeaValue: ,               // < rid = 5601, R, Float >
    // maxMeaValue: ,               // < rid = 5602, R, Float >
    // minRangeValue: ,             // < rid = 5603, R, Float >
    // maxRangeValue: ,             // < rid = 5604, R, Float >
    // resetMinMaxMeaValues:        // < rid = 5605, E, Opaque >
});

3302 Presence Sensor

// Presence Sensor (oid = 3302 or 'presence')
so.init('presence', 0, {
    dInState: {                     // < rid = 5500, R, Boolean >
        read: function (cb) {}
    },
    // counter: ,                   // < rid = 5501,  R, Integer >
    // counterReset: ,              // < rid = 5505,  E, Opaque >
    // sensorType: ,                // < rid = 5751,  R, String >
    // busyToClearDelay: ,          // < rid = 5903, RW, Integer, ms >
    // clearToBusyDelay:            // < rid = 5904  RW, Integer, ms >
});

3303 Temperature Sensor

// Temperature Sensor (oid = 3303 or 'temperature')
so.init('temperature', 0, {
    sensorValue: {                  // < rid = 5700, R, Float >
        read: function (cb) {}
    },
    // units: ,                     // < rid = 5701, R, String >
    // minMeaValue: ,               // < rid = 5601, R, Float >
    // maxMeaValue: ,               // < rid = 5602, R, Float >
    // minRangeValue: ,             // < rid = 5603, R, Float >
    // maxRangeValue: ,             // < rid = 5604, R, Float >
    // resetMinMaxMeaValues:        // < rid = 5605, E, Opaque >
});

3304 Humidity Sensor

// Humidity Sensor (oid = 3304 or 'humidity')
so.init('humidity', 0, {
    sensorValue: {                  // < rid = 5700, R, Float >
        read: function (cb) {}
    },
    // units: ,                     // < rid = 5701, R, String >
    // minMeaValue: ,               // < rid = 5601, R, Float >
    // maxMeaValue: ,               // < rid = 5602, R, Float >
    // minRangeValue: ,             // < rid = 5603, R, Float >
    // maxRangeValue: ,             // < rid = 5604, R, Float >
    // resetMinMaxMeaValues:        // < rid = 5605, E, Opaque >
});

3305 Power Measurement

// Power Measurement (oid = 3305 or 'pwrMea')
so.init('pwrMea', 0, {
    instActivePwr: {                // < rid = 5800, R, Float, Wh >
        read: function (cb) {}
    },
    // minMeaActivePwr: ,           // < rid = 5801,  R, Float, W >
    // maxMeaActivePwr: ,           // < rid = 5802,  R, Float, W >
    // minRangeActivePwr: ,         // < rid = 5803,  R, Float, W >
    // maxRangeActivePwr: ,         // < rid = 5804,  R, Float, W >
    // cumulActivePwr: ,            // < rid = 5805,  R, Float, Wh >
    // activePwrCal: ,              // < rid = 5806,  W, Float, W >
    // instReactivePwr: ,           // < rid = 5810,  R, Float, VAR >
    // minMeaReactivePwr: ,         // < rid = 5811,  R, Float, VAR >
    // maxMeaReactivePwr: ,         // < rid = 5812,  R, Float, VAR >
    // minRangeReactivePwr: ,       // < rid = 5813,  R, Float, VAR >
    // maxRangeReactivePwr: ,       // < rid = 5814,  R, Float, VAR >
    // resetMinMaxMeaValues: ,      // < rid = 5605,  E, Opaque >
    // cumulReactivePwr: ,          // < rid = 5815,  R, Float, VARh >
    // reactivePwrCal: ,            // < rid = 5816,  W, Float, VAR >
    // pwrFactor: ,                 // < rid = 5820,  R, Float >
    // currCal: ,                   // < rid = 5821, RW, Float >
    // resetCumulEnergy: ,          // < rid = 5822,  E, Opaque >
});

3306 Actuation

// Actuation (oid = 3306 or 'actuation')
so.init('actuation', 0, {
    onOff: {                        // < rid = 5850, RW, Boolean { 0: off, 1: on } >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // dimmer: ,                    // < rid = 5851, RW, Integer { 0 ~ 100 }, % >
    // onTime: ,                    // < rid = 5852, RW, Integer, s >
    // mstateOut: ,                 // < rid = 5853, RW, String >
    // appType:                     // < rid = 5750, RW, String >
});

3308 Set Point

// Set Point (oid = 3308 or 'setPoint')
so.init('setPoint', 0, {
    setPointValue: {                // < rid = 5900, RW, Float >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // colour: ,                    // < rid = 5706, RW, String >
    // units: ,                     // < rid = 5701,  R, String >
    // appType:                     // < rid = 5750, RW, String >
});

3310 Load Control

// Load Control (oid = 3310 or 'loadCtrl')
so.init('loadCtrl', 0, {
    eventId: {                      // < rid = 5823, RW, String >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    startTime: {                    // < rid = 5824, RW, Time >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    durationInMin: {                // < rid = 5825, RW, Integer, min >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // criticalLevel: ,             // < rid = 5826, RW, Integer { 0: normal, 1: warning, 2: danger, 3: fatal } >
    // avgLoadAdjPct: ,             // < rid = 5827, RW, Integer { 0 ~ 100 }, % >
    // dutyCycle:                   // < rid = 5828, RW, Interger { 0 ~ 100 }, % >
});

3311 Light Control

// Light Control (oid = 3311 or 'lightCtrl')
so.init('lightCtrl', 0, {
    onOff: {                        // < rid = 5850, RW, Boolean { 0: off, 1: on } >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // dimmer: ,                    // < rid = 5851, RW, Integer { 0 ~ 100 }, %  >
    // colour: ,                    // < rid = 5706, RW, String >
    // units: ,                     // < rid = 5701,  R, String >
    // onTime: ,                    // < rid = 5852, RW, Integer, s >
    // cumulActivePwr: ,            // < rid = 5805,  R, Float, Wh >
    // pwrFactor:                   // < rid = 5820,  R, Float >
});

3312 Power Control

// Power Control (oid = 3312 or 'pwrCtrl')
so.init('pwrCtrl', 0, {
    onOff: {                        // < rid = 5850, RW, Boolean { 0: off, 1: on } >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // dimmer: ,                    // < rid = 5851, RW, Integer { 0 ~ 100 }, % >
    // onTime: ,                    // < rid = 5852, RW, Integer, s >
    // cumulActivePwr: ,            // < rid = 5805,  R, Float, Wh >
    // pwrFactor:                   // < rid = 5820,  R, Float >
});

3313 Accelerometer

// Accelerometer (oid = 3313 or 'accelerometer')
so.init('accelerometer', 0, {
    xValue: {                       // < rid = 5702, R, Float >
        read: function (cb) {}
    },
    // yValue: ,                    // < rid = 5703, R, Float >
    // zValue: ,                    // < rid = 5704, R, Float >
    // units: ,                     // < rid = 5701, R, String >
    // minRangeValue: ,             // < rid = 5603, R, Float >
    // maxRangeValue:               // < rid = 5604, R, Float >
});

3314 Magnetometer

// Magnetometer (oid = 3314 or 'magnetometer')
so.init('magnetometer', 0, {
    xValue: {                       // < rid = 5702, R, Float >
        read: function (cb) {}
    },
    // yValue: ,                    // < rid = 5703, R, Float >
    // zValue: ,                    // < rid = 5704, R, Float >
    // units:,                      // < rid = 5701, R, String >
    // compassDir:                  // < rid = 5705, R, Float { 0 ~ 360 }, deg >
});

3315 Barometer

// Barometer (oid = 3315 or 'barometer')
so.init('barometer', 0, {
    sensorValue: {                  // < rid = 5700, R, Float >
        read: function (cb) {}
    },
    // units: ,                     // < rid = 5701, R, String >
    // minMeaValue: ,               // < rid = 5601, R, Float >
    // maxMeaValue: ,               // < rid = 5602, R, Float >
    // minRangeValue: ,             // < rid = 5603, R, Float >
    // maxRangeValue: ,             // < rid = 5604, R, Float >
    // resetMinMaxMeaValues:        // < rid = 5605, E, Opaque >
});

3316 Voltage, 3317 Current, 3318 Frequency, 3319 Depth, 3320 Percentage, 3321 Altitude, 3322 Load, 3323 Pressure, 3324 Loudness, 3325 Concentration, 3326 Acidity, 3327 Conductivity, 3328 Power, 3329 Power Factor, 3330 Distance

// 'xxx' Can be 'voltage', 'current', 'frequency', ..., and 'distance'
so.init('xxx', 0, {
    sensorValue: {                  // < rid = 5700, R, Float >
        read: function (cb) {}
    },
    // units: ,                     // < rid = 5701,  R, String >
    // minMeaValue: ,               // < rid = 5601,  R, Float >
    // maxMeaValue: ,               // < rid = 5602,  R, Float >
    // minRangeValue: ,             // < rid = 5603,  R, Float >
    // maxRangeValue: ,             // < rid = 5604,  R, Float >
    // resetMinMaxMeaValues: ,      // < rid = 5605,  E, Opaque >
    // calOffset: ,                 // < rid = 5535, RW, Float >
    // appType:                     // < rid = 5750, RW, String >
});

3331 Energy

// Energy (oid = 3331 or 'energy')
so.init('energy', 0, {
    cumulActivePwr: {               // < rid = 5700,  R, Float >
        read: function (cb) {}
    },
    // units: ,                     // < rid = 5701,  R, String >
    // resetCumulEnergy: ,          // < rid = 5605,  E, Opaque >
    // appType:                     // < rid = 5750, RW, String >
});

3332 Direction

// Direction (oid = 3332 or 'direction')
so.init('direction', 0, {
    compassDir: {                   // < rid = 5705,  R, Float >
        read: function (cb) {}
    },
    // compassDir: 5705,
    // minMeaValue: ,               // < rid = 5601,  R, Float >
    // maxMeaValue: ,               // < rid = 5602,  R, Float >
    // resetMinMaxMeaValues: ,      // < rid = 5605,  E, Opaque >
    // appType:                     // < rid = 5750, RW, String >
});

3333 Time

// Time (oid = 3333 or 'time')
so.init('time', 0, {
    currentTime: {                  // < rid = 5506, RW, Time >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // fracTime:                    // < rid = 5507, RW, Float {1} >
    // appType:                     // < rid = 5750, RW, String >
});

3334 Gyrometer

// Gyrometer (oid = 3334 or 'gyrometer')
so.init('gyrometer', 0, {
    xValue: {                       // < rid = 5702,  R, Float >
        read: function (cb) {}
    },
    // yValue: ,                    // < rid = 5703,  R, Float >
    // zValue: ,                    // < rid = 5704,  R, Float >
    // units: ,                     // < rid = 5701,  R, String >
    // minRangeValue: ,             // < rid = 5603,  R, Float >
    // maxRangeValue: ,             // < rid = 5604,  R, Float >

    // minXValue: ,                 // < rid = 5508,  R, Float >
    // maxXValue: ,                 // < rid = 5609,  R, Float >
    // minYValue: ,                 // < rid = 5510,  R, Float >
    // maxYValue: ,                 // < rid = 5611,  R, Float >
    // minZValue: ,                 // < rid = 5512,  R, Float >
    // maxZValue: ,                 // < rid = 5613,  R, Float >
    // resetMinMaxMeaValues: ,      // < rid = 5605,  E, Opaque >
    // appType:                     // < rid = 5750, RW, String >
});

3335 Colour

// Colour (oid = 3335 or 'colour')
so.init('colour', 0, {
    colour: {                       // < rid = 5706, RW, String >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // units: ,                     // < rid = 5701,  R, String >
    // appType:                     // < rid = 5750, RW, String >
});

3336 GPS Location

// GPS Location (oid = 3336 or 'gpsLocation')
so.init('gpsLocation', 0, {
    latitude: {                     // < rid = 5514,  R, String >
        read: function (cb) {}
    },
    longitude: {                    // < rid = 5515,  R, String >
        read: function (cb) {}
    },
    // uncertainty: ,               // < rid = 5516,  R, String >
    // compassDir: ,                // < rid = 5705,  R, Float >
    // velocity: ,                  // < rid = 5517,  R, Opaque >
    // timestamp: ,                 // < rid = 5518,  R, Time >
    // appType:                     // < rid = 5750, RW, String >
});

3337 Positioner

// Positioner (oid = 3337 or 'positioner')
so.init('positioner', 0, {
    currentPos: {                   // < rid = 5536, RW, Float {100} >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // transTime: ,                // < rid = 5537, RW, Float >
    // remainTime: ,               // < rid = 5538,  R, Float >
    // minMeaValue: ,              // < rid = 5601,  R, Float >
    // maxMeaValue: ,              // < rid = 5602,  R, Float >
    // resetMinMaxMeaValues:       // < rid = 5605,  E, Opaque >
    // minLimit: ,                 // < rid = 5519,  R, Float >
    // maxLimit: ,                 // < rid = 5520,  R, Float >
    // appType:                    // < rid = 5750, RW, String >
});

3338 Buzzer

// Buzzer (oid = 3338 or 'buzzer')
so.init('buzzer', 0, {
    onOff: {                        // < rid = 5850, RW, Boolean >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // level: ,                     // < rid = 5548, RW, Float {100} >
    // timeDuration: ,              // < rid = 5521, RW, Float >
    // minOffTime: ,                // < rid = 5525, RW, Float >
    // appType:                     // < rid = 5750, RW, String >
});

3339 Audio Clip

// Audio Clip (oid = 3339 or 'audioClip')
so.init('audioClip', 0, {
    clip: {                         // < rid = 5522, RW, Opaque >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // trigger:                     // < rid = 5523,  E, Opaque >
    // level: ,                     // < rid = 5548, RW, Float {100} >
    // soundDuration: ,             // < rid = 5524, RW, Float >
    // appType:                     // < rid = 5750, RW, String >
});

3340 Timer

// Timer (oid = 3340 or 'timer')
so.init('timer', 0, {
    timeDuration: {                 // < rid = 5521, R, Float >
        read: function (cb) {}
        write: function (value, cb) {}
    },
    // remainTime: ,                // < rid = 5538,  R, Float >
    // minOffTime: ,                // < rid = 5525, RW, Float >
    // trigger:                     // < rid = 5523,  E, Opaque >
    // onOff: ,                     // < rid = 5850, RW, Boolean >
    // counter: ,                   // < rid = 5501,  R, Integer >
    // cumulTime: ,                 // < rid = 5544, RW, Float >
    // digitalState: ,              // < rid = 5543,  R, Boolean >
    // eventCounter: ,              // < rid = 5534, RW, Integer >
    // mode: ,                      // < rid = 5526, RW, Integer {4} >
    // appType:                     // < rid = 5750, RW, String >
});

3341 Addressable Text Display

// Addressable Text Display (oid = 3341 or 'addressableTextDisplay')
so.init('addressableTextDisplay', 0, {
    text: {                         // < rid = 5527, RW, String >
        read: function (cb) {}
    },
    // xCoord:,                     // < rid = 5528, RW, Integer >
    // yCoord:,                     // < rid = 5529, RW, Integer >
    // maxXCoord:,                  // < rid = 5545,  R, Integer >
    // maxYCoord:,                  // < rid = 5546,  R, Integer >
    // clearDisplay:                // < rid = 5530,  E, Opaque >
    // contrast: ,                  // < rid = 5531, RW, Float {100} >
    // level: ,                     // < rid = 5548, RW, Float {100} >
    // appType:                     // < rid = 5750, RW, String >
});

3342 On/Off Switch

// On/Off Switch (oid = 3342 or 'onOffSwitch')
so.init('onOffSwitch', 0, {
    dInState: {                     // < rid = 5500, R, Boolean >
        read: function (cb) {}
    },
    // counter: ,                   // < rid = 5501,  R, Integer >
    // onTime: ,                    // < rid = 5852, RW, Integer, s >
    // offTime: ,                   // < rid = 5854, RW, Integer, s >
    // appType:                     // < rid = 5750, RW, String >
});

3343 Level Controller

// Level Controller (oid = 3343 or 'levelControl')
so.init('levelControl', 0, {
    level: {                        // < rid = 5548, RW, Float {100} >
        read: function (cb) {},
        write: function (value, cb) {}
    },
    // onTime: ,                    // < rid = 5852, RW, Integer, s >
    // offTime: ,                   // < rid = 5854, RW, Integer, s >
    // appType:                     // < rid = 5750, RW, String >
});

3344 Up/Down Controller

// Up/Down Controller (oid = 3343 or 'upDownControl')
so.init('upDownControl', 0, {
    incInputState: {                // < rid = 5532, R, Boolean >
        read: function (cb) {}
    },
    decInputState: {                // < rid = 5533, R, Boolean >
        read: function (cb) {}
    },
    // upCounter: ,                 // < rid = 5541, RW, Integer >
    // downCounter: ,               // < rid = 5542, RW, Integer >
    // appType:                     // < rid = 5750, RW, String >
});

3345 Multiple Axis Joystick

// Multiple Axis Joystick (oid = 3345 or 'multipleAxisJoystick')
so.init('multipleAxisJoystick', 0, {
    dInState: {                     // < rid = 5500, R, Boolean >
        read: function (cb) {}
    },
    // counter: ,                   // < rid = 5501,  R, Integer >
    // xValue: ,                    // < rid = 5702,  R, Float >
    // yValue: ,                    // < rid = 5703,  R, Float >
    // zValue: ,                    // < rid = 5704,  R, Float >
    // appType:                     // < rid = 5750, RW, String >
});

3346 Rate

// Rate (oid = 3346 or 'rate')
so.init('rate', 0, {
    sensorValue: {                  // < rid = 5700, R, Float >
        read: function (cb) {}
    },
    // units: ,                     // < rid = 5701, R, String >
    // minMeaValue: ,               // < rid = 5601, R, Float >
    // maxMeaValue: ,               // < rid = 5602, R, Float >
    // minRangeValue: ,             // < rid = 5603, R, Float >
    // maxRangeValue: ,             // < rid = 5604, R, Float >
    // resetMinMaxMeaValues:        // < rid = 5605, E, Opaque >
    // calOffset: ,                 // < rid = 5535, RW, Float >
    // appType:                     // < rid = 5750, RW, String >
});

3347 Push Button

// Push Button (oid = 3347 or 'pushButton')
so.init('pushButton', 0, {
    dInState: {                     // < rid = 5500, R, Boolean >
        read: function (cb) {}
    },
    // counter: ,                   // < rid = 5501,  R, Integer >
    // appType:                     // < rid = 5750, RW, String >
});

3348 Multi-state Selector

// Multi-state Selector (oid = 3348 or 'multistateSelector')
so.init('multistateSelector', 0, {
    mStateIn: {                     // < rid = 5547, R, Integer >
        read: function (cb) {}
    },
    // appType:                     // < rid = 5750, RW, String >
});