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.
- package/README.md +24 -9
- package/admin/assets/index-Y479CE6x.js +681 -0
- package/admin/index_m.html +1 -1
- package/admin/rules/assets/{ActionVisu-D9x2f6zu.js → ActionVisu-DE8dgNVF.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react__loadShare__-Cg21Ef1U.js → ActionVisu__loadShare__react__loadShare__-BKaC-p5K.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react_mf_2_dom__loadShare__-B1zRWn0u.js → ActionVisu__loadShare__react_mf_2_dom__loadShare__-Bs1o8DtQ.js} +2 -2
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-DtUoI3FU.js +5 -0
- package/admin/rules/assets/bootstrap-Ba57tu25.js +1 -0
- package/admin/rules/assets/hostInit-hos3Txsy.js +1 -1
- package/admin/rules/assets/{index-Duo7mFlZ.js → index-CbxmbJvB.js} +2 -2
- package/admin/rules/assets/{index-CAAeiKCc.js → index-DjPMvPni.js} +2 -2
- package/admin/rules/assets/index-_Y2FN5EZ.js +1152 -0
- package/admin/rules/assets/{virtualExposes-BqVak7rX.js → virtualExposes-BNZJTatg.js} +2 -2
- package/admin/rules/customRuleBlocks.js +2 -2
- package/io-package.json +27 -27
- package/package.json +17 -14
- package/admin/assets/index-Df2NS929.js +0 -681
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-Cz053nO7.js +0 -10
- package/admin/rules/assets/bootstrap-BCFKIiwZ.js +0 -1
- package/admin/rules/assets/index-BwcOGyWI.js +0 -1152
- package/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js +0 -262
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +0 -124
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +0 -15
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +0 -15
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js +0 -69
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +0 -15
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +0 -20
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +0 -34
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +0 -27
- package/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js +0 -75
- package/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +0 -39
- package/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js +0 -50
- package/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +0 -13
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +0 -38
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +0 -55
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +0 -56
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +0 -11
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +0 -108
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +0 -40
- package/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js +0 -62
- package/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +0 -22
- package/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js +0 -40
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +0 -32
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +0 -17
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js +0 -25
- package/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +0 -28
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +0 -20
- package/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +0 -52
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +0 -19
- package/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +0 -22
- package/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +0 -28
- package/lib/AlexaSmartHomeV3/Controls/AirCondition.js +0 -144
- package/lib/AlexaSmartHomeV3/Controls/Blind.js +0 -12
- package/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +0 -17
- package/lib/AlexaSmartHomeV3/Controls/Control.js +0 -352
- package/lib/AlexaSmartHomeV3/Controls/Ct.js +0 -172
- package/lib/AlexaSmartHomeV3/Controls/Dimmer.js +0 -124
- package/lib/AlexaSmartHomeV3/Controls/Door.js +0 -9
- package/lib/AlexaSmartHomeV3/Controls/Gate.js +0 -42
- package/lib/AlexaSmartHomeV3/Controls/Hue.js +0 -207
- package/lib/AlexaSmartHomeV3/Controls/Light.js +0 -54
- package/lib/AlexaSmartHomeV3/Controls/Lock.js +0 -36
- package/lib/AlexaSmartHomeV3/Controls/Motion.js +0 -17
- package/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +0 -25
- package/lib/AlexaSmartHomeV3/Controls/Slider.js +0 -10
- package/lib/AlexaSmartHomeV3/Controls/Socket.js +0 -21
- package/lib/AlexaSmartHomeV3/Controls/Temperature.js +0 -22
- package/lib/AlexaSmartHomeV3/Controls/Thermostat.js +0 -86
- package/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +0 -28
- package/lib/AlexaSmartHomeV3/Controls/Volume.js +0 -109
- package/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +0 -9
- package/lib/AlexaSmartHomeV3/Controls/Window.js +0 -9
- package/lib/AlexaSmartHomeV3/Controls/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Device.js +0 -84
- package/lib/AlexaSmartHomeV3/DeviceManager.js +0 -415
- package/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +0 -8
- package/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +0 -5
- package/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +0 -5
- package/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js +0 -46
- package/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +0 -70
- package/lib/AlexaSmartHomeV3/Helpers/IotProxy.js +0 -44
- package/lib/AlexaSmartHomeV3/Helpers/Logger.js +0 -95
- package/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +0 -82
- package/lib/AlexaSmartHomeV3/Helpers/Utils.js +0 -583
- package/lib/Utils.js +0 -608
- package/lib/adminCommonSocket.js +0 -781
- package/lib/alexaCustom.js +0 -622
- package/lib/alexaSmartHomeV2.js +0 -2792
- package/lib/alexaSmartHomeV3.js +0 -117
- package/lib/alisa.js +0 -2412
- package/lib/devices.js +0 -20
- package/lib/functions.js +0 -21
- package/lib/googleHome.js +0 -3323
- package/lib/notifications.js +0 -37
- package/lib/remote.js +0 -1363
- package/lib/rooms.js +0 -45
- package/lib/texts.js +0 -79
- package/lib/translate.js +0 -19
- package/lib/visuApp.js +0 -157
- package/main.js +0 -1444
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const Utils = require('../../Helpers/Utils');
|
|
2
|
-
const AlexaResponse = require('../AlexaResponse');
|
|
3
|
-
const Base = require('./Base');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* When the state of an endpoint changes for any reason, we report that change to Alexa in an Alexa.ChangeReport event.
|
|
7
|
-
* Alexa can then provide the status change to the customer.
|
|
8
|
-
* In the change report, we specify the state of any changed properties in the payload object.
|
|
9
|
-
* For example, if a customer manually turns on a light, we send a change report event that indicates the powerState property
|
|
10
|
-
* of the Alexa.PowerController interface has changed its value to ON.
|
|
11
|
-
*
|
|
12
|
-
* If the properties of an interface are reported as proactivelyReported during discovery,
|
|
13
|
-
* we must send Alexa an Alexa.ChangeReport event whenever a property value changes.
|
|
14
|
-
* If a state change happens because of a directive from Alexa, we send both a directive response and a change report event.
|
|
15
|
-
* @class
|
|
16
|
-
*/
|
|
17
|
-
class ChangeReport extends Base {
|
|
18
|
-
static matches(event) {
|
|
19
|
-
return event?.directive?.header?.name === Utils.className(this.toString());
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static get(endpointId, propertyName, isPhysicalInteraction) {
|
|
23
|
-
return {
|
|
24
|
-
directive: {
|
|
25
|
-
header: {
|
|
26
|
-
name: Utils.className(this.toString()),
|
|
27
|
-
propertyName: propertyName,
|
|
28
|
-
physicalInteraction: isPhysicalInteraction,
|
|
29
|
-
},
|
|
30
|
-
endpoint: {
|
|
31
|
-
endpointId,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async handle(event, endpointManager) {
|
|
38
|
-
this.log.debug(`handling ChangeReport`);
|
|
39
|
-
this.log.silly(`${JSON.stringify(event)}`);
|
|
40
|
-
|
|
41
|
-
const endpointId = event.directive?.endpoint?.endpointId;
|
|
42
|
-
const propertyName = event.directive?.header?.propertyName;
|
|
43
|
-
const changeCauseType = event.directive?.header?.physicalInteraction ? 'PHYSICAL_INTERACTION' : 'VOICE_INTERACTION';
|
|
44
|
-
|
|
45
|
-
let response = new AlexaResponse({
|
|
46
|
-
namespace: 'Alexa',
|
|
47
|
-
name: 'ChangeReport',
|
|
48
|
-
endpointId,
|
|
49
|
-
changeCauseType,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
response.addContext();
|
|
53
|
-
|
|
54
|
-
const endpoint = endpointManager.endpointById(endpointId);
|
|
55
|
-
|
|
56
|
-
if (endpoint) {
|
|
57
|
-
const properties = await endpoint.reportState();
|
|
58
|
-
for (const property of properties) {
|
|
59
|
-
if (propertyName === property.name) {
|
|
60
|
-
response.addPayloadChangeProperty(property);
|
|
61
|
-
} else {
|
|
62
|
-
response.addContextProperty(property);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
response = AlexaResponse.nonExistingEndpoint(endpointId);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
this.log.debug(`${JSON.stringify(response.get())}`);
|
|
70
|
-
|
|
71
|
-
return response.get();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
module.exports = ChangeReport;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const AlexaResponse = require('../AlexaResponse');
|
|
2
|
-
const Base = require('./Base');
|
|
3
|
-
|
|
4
|
-
class Discovery extends Base {
|
|
5
|
-
async handle(event, endpointManager) {
|
|
6
|
-
this.log.debug(`handling Discovery`);
|
|
7
|
-
this.log.silly(`${JSON.stringify(event)}`);
|
|
8
|
-
|
|
9
|
-
const endpoints = endpointManager.endpoints;
|
|
10
|
-
|
|
11
|
-
const response = new AlexaResponse({
|
|
12
|
-
namespace: Discovery.namespace,
|
|
13
|
-
name: 'Discover.Response',
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
let count = 0;
|
|
17
|
-
|
|
18
|
-
endpoints.forEach(endpoint => {
|
|
19
|
-
count++;
|
|
20
|
-
if (count > 300) {
|
|
21
|
-
this.log.warn(`Too many devices. Alexa supports up to 300 devices. ${endpoint.friendlyName} will not be discovered.`);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
response.addPayloadEndpoint({
|
|
25
|
-
endpointId: endpoint.id,
|
|
26
|
-
description: endpoint.description,
|
|
27
|
-
friendlyName: endpoint.friendlyName,
|
|
28
|
-
displayCategories: endpoint.displayCategories,
|
|
29
|
-
capabilities: endpoint.capabilities.map(capability => response.asEndpointCapability(capability.alexaResponse)),
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
this.log.silly(`${JSON.stringify(response.get())}`);
|
|
34
|
-
|
|
35
|
-
return response.get();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = Discovery;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const Utils = require('../../Helpers/Utils');
|
|
2
|
-
const AlexaResponse = require('../AlexaResponse');
|
|
3
|
-
const Base = require('./Base');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* When Alexa sends an Alexa.ReportState directive to request the state of an endpoint, the skill sends an Alexa.StateReport response.
|
|
7
|
-
* This response contains the current state of all the properties that are retrievable.
|
|
8
|
-
* The following information in the Alexa.StateReport response:
|
|
9
|
-
* - the state of all the retrievable properties in the context object
|
|
10
|
-
* - endpoint for the report is identified in the endpoint object
|
|
11
|
-
* - the payload is set to an empty object
|
|
12
|
-
* - correlationToken set to the value from the Alexa.ReportState request
|
|
13
|
-
* @class
|
|
14
|
-
*/
|
|
15
|
-
class ReportState extends Base {
|
|
16
|
-
static matches(event) {
|
|
17
|
-
return event?.directive?.header?.name === Utils.className(this.toString());
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async handle(event, endpointManager) {
|
|
21
|
-
|
|
22
|
-
this.log.debug(`handling ReportState`);
|
|
23
|
-
this.log.silly(`${JSON.stringify(event)}`);
|
|
24
|
-
|
|
25
|
-
const endpointId = event.directive?.endpoint?.endpointId;
|
|
26
|
-
|
|
27
|
-
let response = new AlexaResponse({
|
|
28
|
-
namespace: 'Alexa',
|
|
29
|
-
name: 'StateReport',
|
|
30
|
-
correlationToken: event.directive?.header?.correlationToken,
|
|
31
|
-
token: event.directive?.endpoint?.scope?.token,
|
|
32
|
-
endpointId,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const endpoint = endpointManager.endpointById(endpointId);
|
|
36
|
-
|
|
37
|
-
if (endpoint) {
|
|
38
|
-
const properties = await endpoint.reportState();
|
|
39
|
-
properties.forEach(property => response.addContextProperty(property));
|
|
40
|
-
} else {
|
|
41
|
-
response = AlexaResponse.nonExistingEndpoint(endpointId);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
this.log.silly(`${JSON.stringify(response.get())}`);
|
|
45
|
-
|
|
46
|
-
return response.get();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
module.exports = ReportState;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const directives = {};
|
|
2
|
-
const directivesPath = require('path').join(__dirname);
|
|
3
|
-
|
|
4
|
-
require('fs')
|
|
5
|
-
.readdirSync(directivesPath)
|
|
6
|
-
.forEach((file) => {
|
|
7
|
-
const name = file.replace(/\.js$/, '');
|
|
8
|
-
if (name !== 'index' && name !== 'Base') {
|
|
9
|
-
directives[name] = require(`./${file}`);
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
module.exports = directives;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const Utils = require("../../Helpers/Utils");
|
|
2
|
-
|
|
3
|
-
class Base {
|
|
4
|
-
constructor(mode) {
|
|
5
|
-
this._mode = mode;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
static get value() {
|
|
9
|
-
return Utils.className(this.toString());
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get value() {
|
|
13
|
-
return `${this._mode}.${this.constructor.name}`
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get friendlyNames() {
|
|
17
|
-
return []
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get discoveryResponse() {
|
|
21
|
-
return {
|
|
22
|
-
value: this.value,
|
|
23
|
-
modeResources: {
|
|
24
|
-
friendlyNames: this.friendlyNames
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get actionMappings() {
|
|
30
|
-
return []
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
get stateMappings() {
|
|
34
|
-
return []
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = Base;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const Base = require("./Base");
|
|
2
|
-
|
|
3
|
-
class Closed extends Base {
|
|
4
|
-
get friendlyNames() {
|
|
5
|
-
return [
|
|
6
|
-
{
|
|
7
|
-
'@type': 'asset',
|
|
8
|
-
'value': {
|
|
9
|
-
assetId: 'Alexa.Value.Close'
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
'@type': 'text',
|
|
14
|
-
value: {
|
|
15
|
-
text: 'Closed',
|
|
16
|
-
locale: 'en-US'
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
'@type': 'text',
|
|
21
|
-
value: {
|
|
22
|
-
text: 'Geschloßen',
|
|
23
|
-
locale: 'de-DE'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get actionMappings() {
|
|
30
|
-
return [
|
|
31
|
-
{
|
|
32
|
-
'@type': 'ActionsToDirective',
|
|
33
|
-
actions: ['Alexa.Actions.Close'],
|
|
34
|
-
directive: {
|
|
35
|
-
name: 'SetMode',
|
|
36
|
-
payload: {
|
|
37
|
-
mode: this.value
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get stateMappings() {
|
|
45
|
-
return [
|
|
46
|
-
{
|
|
47
|
-
'@type': 'StatesToValue',
|
|
48
|
-
states: ['Alexa.States.Closed'],
|
|
49
|
-
value: this.value
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = Closed;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const Base = require("./Base");
|
|
2
|
-
|
|
3
|
-
class Open extends Base {
|
|
4
|
-
get friendlyNames() {
|
|
5
|
-
return [
|
|
6
|
-
{
|
|
7
|
-
'@type': 'asset',
|
|
8
|
-
value: {
|
|
9
|
-
assetId: 'Alexa.Value.Open'
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
'@type': 'text',
|
|
14
|
-
value: {
|
|
15
|
-
text: 'Open',
|
|
16
|
-
locale: 'en-US'
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
'@type': 'text',
|
|
21
|
-
value: {
|
|
22
|
-
text: 'Geöffnet',
|
|
23
|
-
locale: 'de-DE'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get actionMappings() {
|
|
31
|
-
return [
|
|
32
|
-
{
|
|
33
|
-
'@type': 'ActionsToDirective',
|
|
34
|
-
actions: ['Alexa.Actions.Open'],
|
|
35
|
-
directive: {
|
|
36
|
-
name: 'SetMode',
|
|
37
|
-
payload: {
|
|
38
|
-
mode: this.value
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get stateMappings() {
|
|
46
|
-
return [
|
|
47
|
-
{
|
|
48
|
-
'@type': 'StatesToValue',
|
|
49
|
-
states: ['Alexa.States.Open'],
|
|
50
|
-
value: this.value
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
module.exports = Open;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const modes = {};
|
|
2
|
-
const modesPath = require('path').join(__dirname);
|
|
3
|
-
const excludedNames = ['index', 'Base'];
|
|
4
|
-
|
|
5
|
-
require('fs')
|
|
6
|
-
.readdirSync(modesPath)
|
|
7
|
-
.forEach((file) => {
|
|
8
|
-
const name = file.replace(/\.js$/, '');
|
|
9
|
-
if (!excludedNames.includes(name)) {
|
|
10
|
-
modes[name] = require(`./${file}`);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
module.exports = modes;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const Utils = require('../../Helpers/Utils');
|
|
2
|
-
const Base = require('./Base');
|
|
3
|
-
|
|
4
|
-
class AdjustableProperty extends Base {
|
|
5
|
-
|
|
6
|
-
static directive(event) {
|
|
7
|
-
return event.directive.header.name === 'Adjust' + Utils.className(this.toString()) ? AdjustableProperty.ADJUST : AdjustableProperty.SET;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = AdjustableProperty;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const Utils = require('../../Helpers/Utils');
|
|
2
|
-
|
|
3
|
-
class Base {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {Object} opts - The object to initialize the corresponding ioBroker state.
|
|
7
|
-
* @param {Object} opts.setState - The iobroker state to write values to.
|
|
8
|
-
* @param {Object} [opts.getState] - The iobroker state to read values from.
|
|
9
|
-
* @param {function} [opts.alexaSetter] - The function to apply to an Alexa value to transform it to the iobroker's one
|
|
10
|
-
* @param {function} [opts.alexaGetter] - The function to apply to an iobroker value to transform it to the Alexa's one
|
|
11
|
-
*/
|
|
12
|
-
init(opts) {
|
|
13
|
-
this._setState = opts.setState;
|
|
14
|
-
this._setId = opts.setState.id;
|
|
15
|
-
this._getId = opts.getState?.id || this._setId;
|
|
16
|
-
this._valuesRange = Utils.configuredRangeOrDefault(this._setState);
|
|
17
|
-
|
|
18
|
-
if (opts.alexaSetter) {
|
|
19
|
-
this._alexaSetter = opts.alexaSetter;
|
|
20
|
-
}
|
|
21
|
-
if (opts.alexaGetter) {
|
|
22
|
-
this._alexaGetter = opts.alexaGetter;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get propertyName() {
|
|
27
|
-
return Utils.firstLower(`${this.constructor.name}`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static get propertyName() {
|
|
31
|
-
return Utils.firstLower(Utils.className(this.toString()));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get valuesRangeMin() {
|
|
35
|
-
return this._valuesRange.min
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get valuesRangeMax() {
|
|
39
|
-
return this._valuesRange.max;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get setId() {
|
|
43
|
-
return this._setId;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get getId() {
|
|
47
|
-
return this._getId;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* returns last known iobroker value
|
|
51
|
-
*/
|
|
52
|
-
get currentValue() {
|
|
53
|
-
return this._currentValue;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
set currentValue(value) {
|
|
57
|
-
this._currentValue = value;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @param {any} alexaValue
|
|
62
|
-
*/
|
|
63
|
-
value(alexaValue) {
|
|
64
|
-
return this._alexaSetter ? this._alexaSetter(alexaValue) : alexaValue;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @param {any} value
|
|
69
|
-
*/
|
|
70
|
-
alexaValue(value) {
|
|
71
|
-
return this._alexaGetter ? this._alexaGetter(value) : value;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Checks whether a directive refers to the property
|
|
76
|
-
* @param event Contains the Alexa event.
|
|
77
|
-
* @returns {boolean}
|
|
78
|
-
*/
|
|
79
|
-
static matches(event) {
|
|
80
|
-
return event?.directive?.header?.namespace === `Alexa.${Utils.className(this.toString())}Controller`;
|
|
81
|
-
// return event?.directive?.header?.name === this.propertyName;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
matches(event) {
|
|
85
|
-
return event?.directive?.header?.name === this.propertyName;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Extracts value to be set on the smart device sent in an Alexa directive
|
|
90
|
-
* @returns {object}
|
|
91
|
-
*/
|
|
92
|
-
alexaDirectiveValue(event) {
|
|
93
|
-
return event.directive.payload[this.propertyName];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
reportValue(value) {
|
|
97
|
-
return value;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
static get ADJUST() { return 'ADJUST'; }
|
|
101
|
-
|
|
102
|
-
static get SET() { return 'SET'; }
|
|
103
|
-
|
|
104
|
-
static get CELSIUS_SCALE() { return 'CELSIUS'; }
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
module.exports = Base;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const AdjustableProperty = require('./AdjustableProperty');
|
|
2
|
-
|
|
3
|
-
class Brightness extends AdjustableProperty {
|
|
4
|
-
|
|
5
|
-
matches(event) {
|
|
6
|
-
return Brightness.matches(event);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
alexaDirectiveValue(event) {
|
|
10
|
-
return Brightness.directive(event) === Brightness.SET ? super.alexaDirectiveValue(event) : event.directive.payload['brightnessDelta'];
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
module.exports = Brightness;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const Base = require('./Base');
|
|
2
|
-
|
|
3
|
-
class Color extends Base {
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.hal = {
|
|
8
|
-
hue: 0,
|
|
9
|
-
saturation: 0,
|
|
10
|
-
brightness: 0,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
init(opts) {
|
|
15
|
-
this.hal = opts.hal;
|
|
16
|
-
this._setId = opts.hal.hue;
|
|
17
|
-
this._getId = opts.hal.hue;
|
|
18
|
-
|
|
19
|
-
if (opts.alexaSetter) {
|
|
20
|
-
this._alexaSetter = opts.alexaSetter;
|
|
21
|
-
}
|
|
22
|
-
if (opts.alexaGetter) {
|
|
23
|
-
this._alexaGetter = opts.alexaGetter;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
matches(event) {
|
|
28
|
-
return Color.matches(event) && event?.directive?.header?.name === 'SetColor';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
set hal(value) {
|
|
32
|
-
this._hal = value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get hal() {
|
|
36
|
-
return this._hal;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = Color;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const AdjustableProperty = require('./AdjustableProperty');
|
|
2
|
-
|
|
3
|
-
class ColorTemperatureInKelvin extends AdjustableProperty {
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this._colorTemperatureTable = [2200, 2700, 4000, 5500, 7000];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static matches(event) {
|
|
11
|
-
return event?.directive?.header?.namespace === 'Alexa.ColorTemperatureController';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static directive(event) {
|
|
15
|
-
return [
|
|
16
|
-
ColorTemperatureInKelvin.INCREASE_COLOR_TEMPERATURE,
|
|
17
|
-
ColorTemperatureInKelvin.DECREASE_COLOR_TEMPERATURE]
|
|
18
|
-
.includes(event?.directive?.header?.name) ? AdjustableProperty.ADJUST : AdjustableProperty.SET;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
matches(event) {
|
|
22
|
-
return ColorTemperatureInKelvin.matches(event)
|
|
23
|
-
&& [
|
|
24
|
-
ColorTemperatureInKelvin.SET_COLOR_TEMPERATURE,
|
|
25
|
-
ColorTemperatureInKelvin.INCREASE_COLOR_TEMPERATURE,
|
|
26
|
-
ColorTemperatureInKelvin.DECREASE_COLOR_TEMPERATURE
|
|
27
|
-
].includes(event?.directive?.header?.name);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get colorTemperatureTable() {
|
|
31
|
-
return this._colorTemperatureTable;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
alexaDirectiveValue(event) {
|
|
35
|
-
if (ColorTemperatureInKelvin.SET_COLOR_TEMPERATURE === event?.directive?.header?.name) {
|
|
36
|
-
return event.directive.payload[this.propertyName];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (ColorTemperatureInKelvin.INCREASE_COLOR_TEMPERATURE === event?.directive?.header?.name) {
|
|
40
|
-
return 1;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (ColorTemperatureInKelvin.DECREASE_COLOR_TEMPERATURE === event?.directive?.header?.name) {
|
|
44
|
-
return -1;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static get SET_COLOR_TEMPERATURE() {
|
|
49
|
-
return 'SetColorTemperature';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static get INCREASE_COLOR_TEMPERATURE() {
|
|
53
|
-
return 'IncreaseColorTemperature';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static get DECREASE_COLOR_TEMPERATURE() {
|
|
57
|
-
return 'DecreaseColorTemperature';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
module.exports = ColorTemperatureInKelvin;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const Base = require('./Base');
|
|
2
|
-
|
|
3
|
-
class DetectionState extends Base {
|
|
4
|
-
static matches(event) {
|
|
5
|
-
return event?.directive?.header?.namespace === 'Alexa.MotionSensor' ||
|
|
6
|
-
event?.directive?.header?.namespace === 'Alexa.ContactSensor';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
matches(event) {
|
|
10
|
-
return DetectionState.matches(event);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static get DETECTED() {
|
|
14
|
-
return 'DETECTED';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static get NOT_DETECTED() {
|
|
18
|
-
return 'NOT_DETECTED';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = DetectionState;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const Base = require('./Base');
|
|
2
|
-
|
|
3
|
-
class LockState extends Base {
|
|
4
|
-
static matches(event) {
|
|
5
|
-
return event?.directive?.header?.namespace === 'Alexa.LockController';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
matches(event) {
|
|
9
|
-
return LockState.matches(event);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
alexaDirectiveValue(event) {
|
|
13
|
-
return event.directive.header.name;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static get LOCK() {
|
|
17
|
-
return 'Lock';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static get LOCKED() {
|
|
21
|
-
return 'LOCKED';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static get UNLOCK() {
|
|
25
|
-
return 'Unlock';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static get UNLOCKED() {
|
|
29
|
-
return 'UNLOCKED';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The lock can't transition to `locked` or `unlocked` because the locking mechanism is jammed.
|
|
34
|
-
*/
|
|
35
|
-
static get JAMMED() {
|
|
36
|
-
return 'JAMMED';
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = LockState;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const Base = require('./Base');
|
|
2
|
-
|
|
3
|
-
class Mode extends Base {
|
|
4
|
-
|
|
5
|
-
init(opts) {
|
|
6
|
-
super.init(opts);
|
|
7
|
-
this._supportedModes = opts.supportedModes;
|
|
8
|
-
this._instance = opts.instance;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
matches(event) {
|
|
12
|
-
return Mode.matches(event)
|
|
13
|
-
// non-adjustable mode controller
|
|
14
|
-
&& 'SetMode' === event?.directive?.header?.name
|
|
15
|
-
&& this.instance === event?.directive?.header?.instance
|
|
16
|
-
&& this.supportedModes.map(mode => mode.value).includes(event?.directive?.payload?.mode);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
alexaDirectiveValue(event) {
|
|
20
|
-
return event.directive.payload.mode;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get supportedModes() {
|
|
24
|
-
return this._supportedModes;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get instance() {
|
|
28
|
-
return this._instance;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = Mode;
|