iobroker.iot 3.5.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +24 -9
  2. package/admin/assets/index-Y479CE6x.js +681 -0
  3. package/admin/index_m.html +1 -1
  4. package/admin/rules/assets/{ActionVisu-D9x2f6zu.js → ActionVisu-DE8dgNVF.js} +1 -1
  5. package/admin/rules/assets/{ActionVisu__loadShare__react__loadShare__-Cg21Ef1U.js → ActionVisu__loadShare__react__loadShare__-BKaC-p5K.js} +1 -1
  6. package/admin/rules/assets/{ActionVisu__loadShare__react_mf_2_dom__loadShare__-B1zRWn0u.js → ActionVisu__loadShare__react_mf_2_dom__loadShare__-Bs1o8DtQ.js} +2 -2
  7. package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-DtUoI3FU.js +5 -0
  8. package/admin/rules/assets/bootstrap-Ba57tu25.js +1 -0
  9. package/admin/rules/assets/hostInit-hos3Txsy.js +1 -1
  10. package/admin/rules/assets/{index-Duo7mFlZ.js → index-CbxmbJvB.js} +2 -2
  11. package/admin/rules/assets/{index-CAAeiKCc.js → index-DjPMvPni.js} +2 -2
  12. package/admin/rules/assets/index-_Y2FN5EZ.js +1152 -0
  13. package/admin/rules/assets/{virtualExposes-BqVak7rX.js → virtualExposes-BNZJTatg.js} +2 -2
  14. package/admin/rules/customRuleBlocks.js +2 -2
  15. package/io-package.json +27 -27
  16. package/package.json +17 -14
  17. package/admin/assets/index-Df2NS929.js +0 -681
  18. package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-Cz053nO7.js +0 -10
  19. package/admin/rules/assets/bootstrap-BCFKIiwZ.js +0 -1
  20. package/admin/rules/assets/index-BwcOGyWI.js +0 -1152
  21. package/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js +0 -262
  22. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +0 -124
  23. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +0 -15
  24. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +0 -10
  25. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +0 -15
  26. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +0 -10
  27. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +0 -10
  28. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js +0 -69
  29. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +0 -10
  30. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +0 -10
  31. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +0 -15
  32. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +0 -20
  33. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +0 -10
  34. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +0 -34
  35. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +0 -14
  36. package/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +0 -27
  37. package/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js +0 -75
  38. package/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +0 -39
  39. package/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js +0 -50
  40. package/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +0 -13
  41. package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +0 -38
  42. package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +0 -55
  43. package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +0 -56
  44. package/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +0 -14
  45. package/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +0 -11
  46. package/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +0 -108
  47. package/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +0 -14
  48. package/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +0 -40
  49. package/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js +0 -62
  50. package/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +0 -22
  51. package/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js +0 -40
  52. package/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +0 -32
  53. package/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +0 -17
  54. package/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +0 -14
  55. package/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js +0 -25
  56. package/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +0 -28
  57. package/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +0 -20
  58. package/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +0 -52
  59. package/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +0 -19
  60. package/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +0 -14
  61. package/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +0 -22
  62. package/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +0 -28
  63. package/lib/AlexaSmartHomeV3/Controls/AirCondition.js +0 -144
  64. package/lib/AlexaSmartHomeV3/Controls/Blind.js +0 -12
  65. package/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +0 -17
  66. package/lib/AlexaSmartHomeV3/Controls/Control.js +0 -352
  67. package/lib/AlexaSmartHomeV3/Controls/Ct.js +0 -172
  68. package/lib/AlexaSmartHomeV3/Controls/Dimmer.js +0 -124
  69. package/lib/AlexaSmartHomeV3/Controls/Door.js +0 -9
  70. package/lib/AlexaSmartHomeV3/Controls/Gate.js +0 -42
  71. package/lib/AlexaSmartHomeV3/Controls/Hue.js +0 -207
  72. package/lib/AlexaSmartHomeV3/Controls/Light.js +0 -54
  73. package/lib/AlexaSmartHomeV3/Controls/Lock.js +0 -36
  74. package/lib/AlexaSmartHomeV3/Controls/Motion.js +0 -17
  75. package/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +0 -25
  76. package/lib/AlexaSmartHomeV3/Controls/Slider.js +0 -10
  77. package/lib/AlexaSmartHomeV3/Controls/Socket.js +0 -21
  78. package/lib/AlexaSmartHomeV3/Controls/Temperature.js +0 -22
  79. package/lib/AlexaSmartHomeV3/Controls/Thermostat.js +0 -86
  80. package/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +0 -28
  81. package/lib/AlexaSmartHomeV3/Controls/Volume.js +0 -109
  82. package/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +0 -9
  83. package/lib/AlexaSmartHomeV3/Controls/Window.js +0 -9
  84. package/lib/AlexaSmartHomeV3/Controls/index.js +0 -14
  85. package/lib/AlexaSmartHomeV3/Device.js +0 -84
  86. package/lib/AlexaSmartHomeV3/DeviceManager.js +0 -415
  87. package/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +0 -8
  88. package/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +0 -5
  89. package/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +0 -5
  90. package/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js +0 -46
  91. package/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +0 -70
  92. package/lib/AlexaSmartHomeV3/Helpers/IotProxy.js +0 -44
  93. package/lib/AlexaSmartHomeV3/Helpers/Logger.js +0 -95
  94. package/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +0 -82
  95. package/lib/AlexaSmartHomeV3/Helpers/Utils.js +0 -583
  96. package/lib/Utils.js +0 -608
  97. package/lib/adminCommonSocket.js +0 -781
  98. package/lib/alexaCustom.js +0 -622
  99. package/lib/alexaSmartHomeV2.js +0 -2792
  100. package/lib/alexaSmartHomeV3.js +0 -117
  101. package/lib/alisa.js +0 -2412
  102. package/lib/devices.js +0 -20
  103. package/lib/functions.js +0 -21
  104. package/lib/googleHome.js +0 -3323
  105. package/lib/notifications.js +0 -37
  106. package/lib/remote.js +0 -1363
  107. package/lib/rooms.js +0 -45
  108. package/lib/texts.js +0 -79
  109. package/lib/translate.js +0 -19
  110. package/lib/visuApp.js +0 -157
  111. package/main.js +0 -1444
@@ -1,262 +0,0 @@
1
- 'use strict';
2
-
3
- const { v4: uuidv4 } = require('uuid');
4
- const Utils = require('../Helpers/Utils');
5
-
6
-
7
- /**
8
- * Helper class to generate an AlexaResponse.
9
- * @class
10
- */
11
- class AlexaResponse {
12
- static ErrorResponseName = 'ErrorResponse';
13
-
14
- static isErrorResponse(response) {
15
- return response?.event?.header?.name === AlexaResponse.ErrorResponseName;
16
- }
17
-
18
- static errorResponse(payload) {
19
- return new AlexaResponse({
20
- name: AlexaResponse.ErrorResponseName,
21
- payload,
22
- });
23
- }
24
-
25
- static endpointUnreachable() {
26
- return AlexaResponse.errorResponse({
27
- type: 'ENDPOINT_UNREACHABLE',
28
- message: 'Unable to reach endpoint.',
29
- });
30
- }
31
-
32
- static directiveNotSupportedByControl(controlName, namespace, payloadVersion) {
33
- return AlexaResponse.errorResponse({
34
- type: 'INTERNAL_ERROR',
35
- message: `Control ${controlName} doesn't support the ${namespace} with payloadVersion ${payloadVersion}`,
36
- });
37
- }
38
-
39
- static directiveNotSupportedByDevice(deviceName, namespace, payloadVersion) {
40
- return AlexaResponse.errorResponse({
41
- type: 'INTERNAL_ERROR',
42
- message: `Device ${deviceName} doesn't support the ${namespace} with payloadVersion ${payloadVersion}`,
43
- });
44
- }
45
-
46
-
47
- static nonExistingEndpoint(endpointId) {
48
- return AlexaResponse.errorResponse({
49
- type: 'INTERNAL_ERROR',
50
- message: `No endpoint with id ${endpointId} found`,
51
- });
52
- }
53
-
54
- /**
55
- * Composes Alexa respond on a successfully processed Alexa directive to change a capability's value of a device
56
- * @param {*} event
57
- * @param {string} propertyName
58
- * @param {*} value
59
- * @returns
60
- */
61
- static handled(event, propertyName, value, propertyInstance) {
62
- const response = new AlexaResponse({
63
- correlationToken: event?.directive?.header?.correlationToken,
64
- token: event?.directive?.endpoint?.scope?.token,
65
- endpointId: event?.directive?.endpoint?.endpointId,
66
- });
67
-
68
- response.addContextProperty({
69
- namespace: event?.directive?.header?.namespace,
70
- name: propertyName,
71
- instance: propertyInstance,
72
- value,
73
- });
74
-
75
- return response;
76
- }
77
-
78
-
79
- /**
80
- * Constructor for an Alexa Response.
81
- * @constructor
82
- * @param opts Contains initialization options for the response
83
- */
84
- constructor(opts) {
85
- if (opts === undefined)
86
- opts = {};
87
-
88
- if (opts.context !== undefined) {
89
- this.context = Utils.defaultIfNullOrEmpty(opts.context, undefined);
90
- }
91
-
92
- if (opts.event !== undefined) {
93
- this.event = Utils.defaultIfNullOrEmpty(opts.event, undefined);
94
- }
95
- else {
96
- this.event = {
97
- header: {
98
- namespace: Utils.defaultIfNullOrEmpty(opts.namespace, 'Alexa'),
99
- name: Utils.defaultIfNullOrEmpty(opts.name, 'Response'),
100
- messageId: Utils.defaultIfNullOrEmpty(opts.messageId, uuidv4()),
101
- correlationToken: Utils.defaultIfNullOrEmpty(opts.correlationToken, undefined),
102
- payloadVersion: Utils.defaultIfNullOrEmpty(opts.payloadVersion, '3'),
103
- },
104
- endpoint: {
105
- scope: {
106
- type: 'BearerToken',
107
- token: Utils.defaultIfNullOrEmpty(opts.token, 'INVALID'),
108
- },
109
- endpointId: Utils.defaultIfNullOrEmpty(opts.endpointId, 'INVALID'),
110
- },
111
- payload: Utils.defaultIfNullOrEmpty(opts.payload, {}),
112
- };
113
-
114
- if (opts.changeCauseType) {
115
- this.event.payload.change = {
116
- cause: {
117
- type: opts.changeCauseType,
118
- },
119
- properties: [],
120
- };
121
- }
122
- }
123
-
124
- // No endpoint in an AcceptGrant or Discover request
125
- if (this.event.header.name === 'AcceptGrant.Response' || this.event.header.name === 'Discover.Response') {
126
- delete this.event.endpoint;
127
- }
128
-
129
- }
130
-
131
- addContext() {
132
- if (this.context === undefined) {
133
- this.context = { properties: [] };
134
- }
135
- }
136
-
137
- /**
138
- * Add a property to the context.
139
- * @param opts Contains options for the property.
140
- */
141
- addContextProperty(opts) {
142
- this.addContext();
143
-
144
- const property = {
145
- namespace: Utils.defaultIfNullOrEmpty(opts.namespace, 'Alexa.EndpointHealth'),
146
- instance: Utils.defaultIfNullOrEmpty(opts.instance, undefined),
147
- name: Utils.defaultIfNullOrEmpty(opts.name, 'connectivity'),
148
- value: Utils.defaultIfNullOrEmpty(opts.value, { value: 'OK' }),
149
- timeOfSample: Utils.defaultIfNullOrEmpty(opts.timeOfSample, new Date().toISOString()),
150
- uncertaintyInMilliseconds: Utils.defaultIfNullOrEmpty(opts.uncertaintyInMilliseconds, 0),
151
- }
152
-
153
- if (!property.instance) {
154
- delete property.instance;
155
- }
156
-
157
- this.context.properties.push(property);
158
- }
159
-
160
- /**
161
- * Add a property to the payload.
162
- * @param opts Contains options for the property.
163
- */
164
- addPayloadChangeProperty(opts) {
165
- if (opts === undefined) {
166
- opts = {};
167
- }
168
-
169
- const property = {
170
- namespace: Utils.defaultIfNullOrEmpty(opts.namespace, 'Alexa.EndpointHealth'),
171
- instance: Utils.defaultIfNullOrEmpty(opts.instance, undefined),
172
- name: Utils.defaultIfNullOrEmpty(opts.name, 'connectivity'),
173
- value: Utils.defaultIfNullOrEmpty(opts.value, { value: 'OK' }),
174
- timeOfSample: Utils.defaultIfNullOrEmpty(opts.timeOfSample, new Date().toISOString()),
175
- uncertaintyInMilliseconds: Utils.defaultIfNullOrEmpty(opts.uncertaintyInMilliseconds, 0),
176
- };
177
-
178
- if (!property.instance) {
179
- delete property.instance;
180
- }
181
-
182
- this.event.payload.change.properties.push(property);
183
- }
184
-
185
- alexaCapability() {
186
- return [{
187
- type: 'AlexaInterface',
188
- interface: 'Alexa',
189
- version: '3',
190
- }]
191
- }
192
-
193
- /**
194
- * Adds an endpoint to the payload.
195
- * @param opts Contains options for the endpoint.
196
- */
197
- addPayloadEndpoint(opts) {
198
- if (this.event.payload.endpoints === undefined) {
199
- this.event.payload.endpoints = [];
200
- }
201
-
202
- if (opts === undefined) {
203
- opts = {};
204
- }
205
-
206
- // construct the proper structure expected for the endpoint
207
- let endpoint = {
208
- endpointId: Utils.defaultIfNullOrEmpty(opts.endpointId, 'dummy-endpoint-001'),
209
- manufacturerName: Utils.defaultIfNullOrEmpty(opts.manufacturerName, 'ioBroker Group'),
210
- description: Utils.defaultIfNullOrEmpty(opts.description, 'Device controlled by ioBroker'),
211
- friendlyName: Utils.defaultIfNullOrEmpty(opts.friendlyName, 'ioBroker Stub Endpoint'),
212
- displayCategories: Utils.defaultIfNullOrEmpty(opts.displayCategories, ['OTHER']),
213
- capabilities: this.alexaCapability().concat(Utils.defaultIfNullOrEmpty(opts.capabilities, [])),
214
- };
215
-
216
- if (opts.hasOwnProperty('cookie')) {
217
- endpoint.cookie = Utils.defaultIfNullOrEmpty('cookie', {});
218
- }
219
-
220
- this.event.payload.endpoints.push(endpoint);
221
- }
222
-
223
- /**
224
- * Creates a capability for an endpoint within the payload.
225
- * @param opts Contains options for the endpoint capability.
226
- */
227
- asEndpointCapability(opts) {
228
- if (opts === undefined) {
229
- opts = {};
230
- }
231
-
232
- let response = {
233
- type: Utils.defaultIfNullOrEmpty(opts.type, 'AlexaInterface'),
234
- interface: Utils.defaultIfNullOrEmpty(opts.interface, 'Alexa'),
235
- version: Utils.defaultIfNullOrEmpty(opts.version, '3'),
236
- properties: Utils.defaultIfNullOrEmpty(opts.properties, {}),
237
- // not all capabilities have the following ones
238
- instance: Utils.defaultIfNullOrEmpty(opts.instance, undefined),
239
- configuration: Utils.defaultIfNullOrEmpty(opts.configuration, undefined),
240
- semantics: Utils.defaultIfNullOrEmpty(opts.semantics, undefined),
241
- capabilityResources: Utils.defaultIfNullOrEmpty(opts.capabilityResources, undefined),
242
- };
243
-
244
- for (const prop in ['instance', 'configuration', 'semantics', 'capabilityResources']) {
245
- if (!opts.hasOwnProperty(prop) || !response[prop]) {
246
- delete response[prop];
247
- }
248
- }
249
-
250
- return response;
251
- }
252
-
253
- /**
254
- * Get the composed Alexa Response.
255
- * @returns {AlexaResponse}
256
- */
257
- get() {
258
- return this;
259
- }
260
- }
261
-
262
- module.exports = AlexaResponse;
@@ -1,124 +0,0 @@
1
- const Utils = require('../../Helpers/Utils');
2
-
3
- class Base {
4
- constructor() {
5
- this._properties = this.initProperties();
6
- }
7
-
8
- get name() {
9
- return `${this.constructor.name}`;
10
- }
11
-
12
- get namespace() {
13
- return `Alexa.${this.constructor.name}`;
14
- }
15
-
16
- reportValue(value) {
17
- return value;
18
- }
19
-
20
- initProperties() {
21
- return [];
22
- }
23
-
24
- /**
25
- * Checks whether the capability instance matches, i.e. can handle the event Alexa sends to the skill
26
- * @param event Contains the Alexa event.
27
- * @returns {boolean}
28
- */
29
- matches(event) {
30
- return event?.directive?.header?.namespace === this.namespace && event?.directive?.header?.payloadVersion === this.version;
31
- }
32
-
33
- static get namespace() {
34
- return `Alexa.${Utils.className(this.toString())}`
35
- }
36
-
37
- /**
38
- * Checks whether the capability object matches, i.e., can handle the event Alexa sends to the skill
39
- * @param event Contains the Alexa event.
40
- * @returns {boolean}
41
- */
42
- static matches(event) {
43
- return event?.directive?.header?.namespace === this.namespace;
44
- }
45
-
46
- get properties() {
47
- return this._properties;
48
- }
49
-
50
- /**
51
- *
52
- * @param {*} event Contains the Alexa event.
53
- * @returns Property to handle on Alexa directive
54
- */
55
- property(event) {
56
- return this.properties.find(p => p.matches(event));
57
- }
58
-
59
- /**
60
- * Returns object containing all the properties of the smart device capability as it expected by Alexa during discovery
61
- * @returns {object}
62
- */
63
- get discoverableProperties() {
64
- return {
65
- supported: this.properties.map(p => { return { name: p.propertyName } }),
66
- proactivelyReported: this.proactivelyReported,
67
- retrievable: this.retrievable,
68
- };
69
- }
70
-
71
- /**
72
- * Returns whether the smart device proactively reports state changes
73
- * @returns {boolean}
74
- */
75
- get proactivelyReported() {
76
- return true;
77
- }
78
-
79
- /**
80
- * Returns whether the smart device handles Alexa ReportState directives
81
- * @returns {boolean}
82
- */
83
- get retrievable() {
84
- return true;
85
- }
86
-
87
- get version() {
88
- return '3';
89
- }
90
-
91
- /**
92
- * Returns response to Alexa Discovery directive
93
- * @returns {object}
94
- */
95
- get alexaResponse() {
96
- return {
97
- interface: this.namespace,
98
- version: this.version,
99
- properties: this.discoverableProperties,
100
- };
101
- }
102
-
103
- propertyName(event) {
104
- return this.property(event).propertyName;
105
- }
106
-
107
- /**
108
- * Extracts value to be set on the smart device sent in an Alexa directive
109
- * @returns {object}
110
- */
111
- alexaValue(event) {
112
- return this.property(event).alexaValue(event);
113
- }
114
-
115
- /**
116
- * Extracts endpoint id sent in an Alexa directive
117
- * @returns {string}
118
- */
119
- static endpointId(event) {
120
- return event.directive.endpoint.endpointId;
121
- }
122
- }
123
-
124
- module.exports = Base;
@@ -1,15 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class BrightnessController extends Base {
5
- initProperties() {
6
- this._brightness = new Properties.Brightness();
7
- return [this._brightness];
8
- }
9
-
10
- get brightness() {
11
- return this._brightness;
12
- }
13
- }
14
-
15
- module.exports = BrightnessController;
@@ -1,10 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class ColorController extends Base {
5
- initProperties() {
6
- return [new Properties.Color()];
7
- }
8
- }
9
-
10
- module.exports = ColorController;
@@ -1,15 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class ColorTemperatureController extends Base {
5
- initProperties() {
6
- this._colorTemperatureInKelvin = new Properties.ColorTemperatureInKelvin();
7
- return [this._colorTemperatureInKelvin];
8
- }
9
-
10
- get colorTemperatureInKelvin() {
11
- return this._colorTemperatureInKelvin;
12
- }
13
- }
14
-
15
- module.exports = ColorTemperatureController;
@@ -1,10 +0,0 @@
1
- const Base = require('./Base')
2
- const Properties = require('../Properties');
3
-
4
- class ContactSensor extends Base {
5
- initProperties() {
6
- return [new Properties.DetectionState()];
7
- }
8
- }
9
-
10
- module.exports = ContactSensor;
@@ -1,10 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class LockController extends Base {
5
- initProperties() {
6
- return [new Properties.LockState()];
7
- }
8
- }
9
-
10
- module.exports = LockController;
@@ -1,69 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class ModeController extends Base {
5
- initProperties() {
6
- this._property = new Properties.Mode()
7
- return [this._property];
8
- }
9
-
10
- /**
11
- * Returns response to Alexa Discovery directive
12
- * @returns {object}
13
- */
14
- get alexaResponse() {
15
- return {
16
- interface: this.namespace,
17
- instance: this.instance,
18
- version: this.version,
19
- properties: this.discoverableProperties,
20
- configuration: this.configurationAsDiscoveryResponse,
21
- semantics: this.semanticsAsDiscoveryResponse,
22
- capabilityResources: this.capabilityResourcesAsDiscoveryResponse
23
- };
24
- }
25
-
26
- get discoverableProperties() {
27
- return {
28
- supported: this.properties.map(p => { return { name: p.propertyName } }),
29
- proactivelyReported: this.proactivelyReported,
30
- retrievable: this.retrievable,
31
- nonControllable: false
32
- };
33
- }
34
-
35
- get capabilityResourcesAsDiscoveryResponse() {
36
- return { friendlyNames: this.friendlyNames }
37
- }
38
-
39
- get friendlyNames() {
40
- return [
41
- {
42
- '@type': 'asset',
43
- value: {
44
- assetId: 'Alexa.Setting.Mode'
45
- }
46
- }
47
- ]
48
- }
49
-
50
- get instance() {
51
- return `${this._property.instance}`
52
- }
53
-
54
- get configurationAsDiscoveryResponse() {
55
- return {
56
- ordered: false,
57
- supportedModes: this._property.supportedModes.flatMap(mode => mode.discoveryResponse)
58
- }
59
- }
60
-
61
- get semanticsAsDiscoveryResponse() {
62
- return {
63
- actionMappings: this._property.supportedModes.flatMap(mode => mode.actionMappings),
64
- stateMappings: this._property.supportedModes.flatMap(mode => mode.stateMappings)
65
- }
66
- }
67
- }
68
-
69
- module.exports = ModeController;
@@ -1,10 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class MotionSensor extends Base {
5
- initProperties() {
6
- return [new Properties.DetectionState()];
7
- }
8
- }
9
-
10
- module.exports = MotionSensor;
@@ -1,10 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class PercentageController extends Base {
5
- initProperties() {
6
- return [new Properties.Percentage()];
7
- }
8
- }
9
-
10
- module.exports = PercentageController;
@@ -1,15 +0,0 @@
1
- const Properties = require('./../Properties');
2
- const Base = require('./Base');
3
-
4
- class PowerController extends Base {
5
- initProperties() {
6
- this._powerState = new Properties.PowerState();
7
- return [this._powerState];
8
- }
9
-
10
- get powerState() {
11
- return this._powerState;
12
- }
13
- }
14
-
15
- module.exports = PowerController;
@@ -1,20 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class Speaker extends Base {
5
- initProperties() {
6
- this._volume = new Properties.Volume();
7
- this._muted = new Properties.Muted();
8
- return [this._volume, this._muted];
9
- }
10
-
11
- get volume() {
12
- return this._volume;
13
- }
14
-
15
- get muted() {
16
- return this._muted;
17
- }
18
- }
19
-
20
- module.exports = Speaker;
@@ -1,10 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class TemperatureSensor extends Base {
5
- initProperties() {
6
- return [new Properties.Temperature()];
7
- }
8
- }
9
-
10
- module.exports = TemperatureSensor;
@@ -1,34 +0,0 @@
1
- const Properties = require('../Properties');
2
- const Base = require('./Base');
3
-
4
- class ThermostatController extends Base {
5
- get version() {
6
- return '3.2';
7
- }
8
-
9
- initProperties() {
10
- this._thermostatMode = new Properties.ThermostatMode();
11
- return [new Properties.TargetSetpoint(), this._thermostatMode];
12
- }
13
-
14
- get thermostatMode() {
15
- return this._thermostatMode;
16
- }
17
-
18
- get alexaResponse() {
19
- return {
20
- interface: this.namespace,
21
- version: this.version,
22
- properties: this.discoverableProperties,
23
- configuration: this.configuration,
24
- };
25
- }
26
-
27
- get configuration() {
28
- return {
29
- supportedModes: this._thermostatMode.supportedModes,
30
- };
31
- }
32
- }
33
-
34
- module.exports = ThermostatController;
@@ -1,14 +0,0 @@
1
- const capabilities = {};
2
- const capabilitiesPath = require('path').join(__dirname);
3
- const excludedNames = ['index', 'Base'];
4
-
5
- require('fs')
6
- .readdirSync(capabilitiesPath)
7
- .forEach((file) => {
8
- const name = file.replace(/\.js$/, '');
9
- if (!excludedNames.includes(name)) {
10
- capabilities[name] = require(`./${file}`);
11
- }
12
- });
13
-
14
- module.exports = capabilities;
@@ -1,27 +0,0 @@
1
- const Logger = require('../../Helpers/Logger');
2
- const Utils = require('../../Helpers/Utils');
3
-
4
- class Base {
5
- constructor() {
6
- this.log = new Logger(this);
7
- }
8
-
9
- static get namespace() {
10
- return `Alexa.${Utils.className(this.toString())}`;
11
- }
12
-
13
- /**
14
- * Checks whether the directive matches, i.e., can handle the event Alexa sends to the skill
15
- * @param event Contains the Alexa event.
16
- * @returns {boolean}
17
- */
18
- static matches(event) {
19
- return event?.directive?.header?.namespace === this.namespace;
20
- }
21
-
22
- async handle(event, endpointManager) {
23
- return null;
24
- }
25
- }
26
-
27
- module.exports = Base;