()
| 39 | */ |
| 40 | class ExampleDimmableLight extends Thing { |
| 41 | constructor() { |
| 42 | super( |
| 43 | 'urn:dev:ops:my-lamp-1234', |
| 44 | 'My Lamp', |
| 45 | ['OnOffSwitch', 'Light'], |
| 46 | 'A web connected lamp' |
| 47 | ); |
| 48 | |
| 49 | this.addProperty( |
| 50 | new Property( |
| 51 | this, |
| 52 | 'on', |
| 53 | new Value(true, (v) => console.log('On-State is now', v)), |
| 54 | { |
| 55 | '@type': 'OnOffProperty', |
| 56 | title: 'On/Off', |
| 57 | type: 'boolean', |
| 58 | description: 'Whether the lamp is turned on', |
| 59 | })); |
| 60 | |
| 61 | this.addProperty( |
| 62 | new Property( |
| 63 | this, |
| 64 | 'brightness', |
| 65 | new Value(50, (v) => console.log('Brightness is now', v)), |
| 66 | { |
| 67 | '@type': 'BrightnessProperty', |
| 68 | title: 'Brightness', |
| 69 | type: 'integer', |
| 70 | description: 'The level of light from 0-100', |
| 71 | minimum: 0, |
| 72 | maximum: 100, |
| 73 | unit: 'percent', |
| 74 | })); |
| 75 | |
| 76 | this.addAvailableAction( |
| 77 | 'fade', |
| 78 | { |
| 79 | title: 'Fade', |
| 80 | description: 'Fade the lamp to a given level', |
| 81 | input: { |
| 82 | type: 'object', |
| 83 | required: [ |
| 84 | 'brightness', |
| 85 | 'duration', |
| 86 | ], |
| 87 | properties: { |
| 88 | brightness: { |
| 89 | type: 'integer', |
| 90 | minimum: 0, |
| 91 | maximum: 100, |
| 92 | unit: 'percent', |
| 93 | }, |
| 94 | duration: { |
| 95 | type: 'integer', |
| 96 | minimum: 1, |
| 97 | unit: 'milliseconds', |
| 98 | }, |
nothing calls this directly
no test coverage detected