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,42 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const Modes = require('../Alexa/ModeValues');
|
|
3
|
-
const Control = require('./Control');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @class
|
|
7
|
-
*/
|
|
8
|
-
class Gate extends Control {
|
|
9
|
-
get categories() {
|
|
10
|
-
return ['GARAGE_DOOR'];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
initCapabilities() {
|
|
14
|
-
let result = [new Capabilities.ModeController()];
|
|
15
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
16
|
-
property.init(this.modeInitObject());
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
modeInitObject() {
|
|
22
|
-
const map = this.statesMap;
|
|
23
|
-
const mode = 'Gate.Position';
|
|
24
|
-
return {
|
|
25
|
-
setState: this.states[map.set],
|
|
26
|
-
getState: this.states[map.set],
|
|
27
|
-
alexaSetter: function (alexaValue) {
|
|
28
|
-
return alexaValue === `${mode}.${Modes.Open.value}`;
|
|
29
|
-
},
|
|
30
|
-
alexaGetter: function (value) {
|
|
31
|
-
return value ? `${mode}.${Modes.Open.value}` : `${mode}.${Modes.Closed.value}`;
|
|
32
|
-
},
|
|
33
|
-
instance: mode,
|
|
34
|
-
supportedModes: [
|
|
35
|
-
new Modes.Open(mode),
|
|
36
|
-
new Modes.Closed(mode)
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = Gate;
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const Utils = require('../Helpers/Utils');
|
|
3
|
-
const Properties = require('../Alexa/Properties');
|
|
4
|
-
const AdapterProvider = require('../Helpers/AdapterProvider');
|
|
5
|
-
const AdjustableControl = require('./AdjustableControl');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @class
|
|
9
|
-
*/
|
|
10
|
-
class Hue extends AdjustableControl {
|
|
11
|
-
get categories() {
|
|
12
|
-
return ['LIGHT'];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
adjustableProperties() {
|
|
16
|
-
return [Properties.ColorTemperatureInKelvin];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
initCapabilities() {
|
|
20
|
-
const map = this.statesMap;
|
|
21
|
-
const result = [new Capabilities.ColorController()];
|
|
22
|
-
|
|
23
|
-
// if the state DIMMER or BRIGHTNESS configured
|
|
24
|
-
if (this.states[map.dimmer] || this.states[map.brightness]) {
|
|
25
|
-
this._brightnessCapability = new Capabilities.BrightnessController();
|
|
26
|
-
this._brightness = this._brightnessCapability.brightness;
|
|
27
|
-
result.push(this._brightnessCapability);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// if the state TEMPERATURE configured
|
|
31
|
-
if (this.states[map.temperature]) {
|
|
32
|
-
this._colorTemperatureCapability = new Capabilities.ColorTemperatureController();
|
|
33
|
-
result.push(this._colorTemperatureCapability);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// if the state ON, DIMMER or BRIGHTNESS configured
|
|
37
|
-
if (this.states[map.on] || this._brightness) {
|
|
38
|
-
this._powerControllerCapability = new Capabilities.PowerController();
|
|
39
|
-
this._powerState = this._powerControllerCapability.powerState;
|
|
40
|
-
result.push(this._powerControllerCapability);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
44
|
-
property.init(this.composeInitObject(property))
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async getOrRetrieveCurrentValue(property) {
|
|
51
|
-
const map = this.statesMap;
|
|
52
|
-
|
|
53
|
-
if (property.currentValue === undefined) {
|
|
54
|
-
property.currentValue = await AdapterProvider.getState(property.getId);
|
|
55
|
-
// convert the non-zero brightness to power = true
|
|
56
|
-
if (property.propertyName === Properties.PowerState.propertyName && !this.states[map.on]) {
|
|
57
|
-
property.currentValue = property.currentValue !== 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (property.propertyName === Properties.Color.propertyName) {
|
|
61
|
-
property.currentValue = {
|
|
62
|
-
hue: property.currentValue,
|
|
63
|
-
saturation: property.hal.saturation,
|
|
64
|
-
brightness: property.hal.brightness
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (property.currentValue === undefined) {
|
|
70
|
-
throw new Error(`unable to retrieve ${property.getId}`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return property.currentValue;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async setState(property, value) {
|
|
77
|
-
const map = this.statesMap;
|
|
78
|
-
|
|
79
|
-
if (property.propertyName === Properties.PowerState.propertyName) {
|
|
80
|
-
if (this.states[map.on]) {
|
|
81
|
-
await AdapterProvider.setState(property.setId, value);
|
|
82
|
-
property.currentValue = value;
|
|
83
|
-
} else {
|
|
84
|
-
if (value) { // set brightness
|
|
85
|
-
// set byOn to the configured value or range.max otherwise
|
|
86
|
-
const range = Utils.configuredRangeOrDefault(this.states[map.dimmer] || this.states[map.brightness]);
|
|
87
|
-
let byOn = (this.states[map.dimmer] || this.states[map.brightness])?.smartName?.byON;
|
|
88
|
-
byOn = isNaN(byOn) ? range.max : parseInt(byOn);
|
|
89
|
-
await AdapterProvider.setState(this._brightness.setId, byOn);
|
|
90
|
-
this._brightness.currentValue = byOn;
|
|
91
|
-
this._powerState.currentValue = true;
|
|
92
|
-
} else { // set brightness to 0 on power OFF
|
|
93
|
-
await AdapterProvider.setState(this._brightness.setId, 0);
|
|
94
|
-
this._brightness.currentValue = 0;
|
|
95
|
-
this._powerState.currentValue = false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
} else
|
|
99
|
-
if (property.propertyName === Properties.Brightness.propertyName
|
|
100
|
-
|| property.propertyName === Properties.ColorTemperatureInKelvin.propertyName) {
|
|
101
|
-
await AdapterProvider.setState(property.setId, value);
|
|
102
|
-
property.currentValue = value;
|
|
103
|
-
} else
|
|
104
|
-
if (property.propertyName === Properties.Color.propertyName) {
|
|
105
|
-
await AdapterProvider.setState(property.hal.hue, value.hue);
|
|
106
|
-
if (property.hal.saturation) {
|
|
107
|
-
await AdapterProvider.setState(property.hal.saturation, value.saturation);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// do not set brightness
|
|
111
|
-
|
|
112
|
-
// https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-colorcontroller.html
|
|
113
|
-
// Important: For the best user experience, when you make a color change, maintain the current brightness setting of the endpoint.
|
|
114
|
-
// For example, if a light bulb is currently set to white at 0.5 brightness, and a user requests a color change to red,
|
|
115
|
-
// the SetColor directive specifies hue = 0, saturation = 1, and brightness = 1. Here, set the hue to 0, the saturation to 1,
|
|
116
|
-
// and ignore the brightness value of 1 in the directive. Instead, maintain the current brightness value of 0.5.
|
|
117
|
-
|
|
118
|
-
property.currentValue = value;
|
|
119
|
-
} else
|
|
120
|
-
if (property.propertyName === Properties.ColorTemperatureInKelvin.propertyName) {
|
|
121
|
-
// TODO: Check with gh_got
|
|
122
|
-
await AdapterProvider.setState(property.setId, value.colorTemperatureInKelvin);
|
|
123
|
-
property.currentValue = value;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async adjustValue(event, property) {
|
|
128
|
-
// extract Alexa delta value from event
|
|
129
|
-
const delta = property.alexaDirectiveValue(event);
|
|
130
|
-
|
|
131
|
-
// convert delta to iobroker value
|
|
132
|
-
const value = property.value(delta);
|
|
133
|
-
|
|
134
|
-
// set iobroker state
|
|
135
|
-
await this.setState(property, value);
|
|
136
|
-
|
|
137
|
-
return value;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
composeInitObject(property) {
|
|
141
|
-
const map = this.statesMap;
|
|
142
|
-
|
|
143
|
-
if (property.propertyName === Properties.PowerState.propertyName) {
|
|
144
|
-
return {
|
|
145
|
-
setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
|
|
146
|
-
getState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
|
|
147
|
-
alexaSetter: function (alexaValue) {
|
|
148
|
-
return alexaValue === Properties.PowerState.ON;
|
|
149
|
-
},
|
|
150
|
-
alexaGetter: function (value) {
|
|
151
|
-
return value ? Properties.PowerState.ON : Properties.PowerState.OFF;
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (property.propertyName === Properties.Brightness.propertyName) {
|
|
157
|
-
return {
|
|
158
|
-
setState: this.states[map.dimmer] || this.states[map.brightness],
|
|
159
|
-
getState: this.states[map.dimmer] || this.states[map.brightness],
|
|
160
|
-
alexaSetter: function (alexaValue) {
|
|
161
|
-
return Utils.denormalize_0_100(alexaValue, this.valuesRangeMin, this.valuesRangeMax);
|
|
162
|
-
},
|
|
163
|
-
alexaGetter: function (value) {
|
|
164
|
-
return Utils.normalize_0_100(value, this.valuesRangeMin, this.valuesRangeMax);
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (property.propertyName === Properties.Color.propertyName) {
|
|
170
|
-
return {
|
|
171
|
-
hal: {
|
|
172
|
-
hue: this.states[map.hue].id,
|
|
173
|
-
saturation: this.states[map.saturation]?.id,
|
|
174
|
-
brightness: (this.states[map.dimmer] || this.states[map.brightness])?.id
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (property.propertyName === Properties.ColorTemperatureInKelvin.propertyName) {
|
|
180
|
-
return {
|
|
181
|
-
setState: this.states[map.temperature],
|
|
182
|
-
getState: this.states[map.temperature],
|
|
183
|
-
alexaSetter: function (alexaValue) {
|
|
184
|
-
if (alexaValue === 1) { // increase directive
|
|
185
|
-
const closest = Utils.closestFromList(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
|
|
186
|
-
let index = this.colorTemperatureTable.indexOf(closest) + 1;
|
|
187
|
-
index = index >= this.colorTemperatureTable.length ? this.colorTemperatureTable.length - 1 : index;
|
|
188
|
-
return this.colorTemperatureTable[index];
|
|
189
|
-
}
|
|
190
|
-
if (alexaValue === -1) { // decrease directive
|
|
191
|
-
const closest = Utils.closestFromList(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
|
|
192
|
-
let index = this.colorTemperatureTable.indexOf(closest) - 1;
|
|
193
|
-
index = index < 0 ? 0 : index;
|
|
194
|
-
return this.colorTemperatureTable[index];
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return alexaValue;
|
|
198
|
-
},
|
|
199
|
-
alexaGetter: function (value) {
|
|
200
|
-
return value;
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
module.exports = Hue;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const Control = require('./Control');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
class Light extends Control {
|
|
8
|
-
get categories() {
|
|
9
|
-
return ['LIGHT'];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
initCapabilities() {
|
|
13
|
-
let result = [new Capabilities.PowerController()];
|
|
14
|
-
|
|
15
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
16
|
-
property.init(this.powerStateInitObject())
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
initEnforcedCapabilities() {
|
|
23
|
-
let result = [new Capabilities.BrightnessController()];
|
|
24
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
25
|
-
property.init(this.brightnessInitObject());
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get statesMap() {
|
|
32
|
-
return {
|
|
33
|
-
'set': 'SET',
|
|
34
|
-
'actual': 'ON_ACTUAL',
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
brightnessInitObject() {
|
|
39
|
-
const map = this.statesMap;
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
setState: this.states[map.set],
|
|
43
|
-
getState: this.states[map.actual],
|
|
44
|
-
alexaSetter: function (alexaValue) {
|
|
45
|
-
return alexaValue > 0;
|
|
46
|
-
},
|
|
47
|
-
alexaGetter: function (value) {
|
|
48
|
-
return value ? 100 : 0;
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
module.exports = Light;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const Properties = require('../Alexa/Properties');
|
|
3
|
-
const Control = require('./Control');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @class
|
|
7
|
-
*/
|
|
8
|
-
class Lock extends Control {
|
|
9
|
-
get categories() {
|
|
10
|
-
return ['SMARTLOCK'];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
initCapabilities() {
|
|
14
|
-
let result = [new Capabilities.LockController()];
|
|
15
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
16
|
-
property.init(this.lockStateInitObject());
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
lockStateInitObject() {
|
|
22
|
-
const map = this.statesMap;
|
|
23
|
-
return {
|
|
24
|
-
setState: this.states[map.set],
|
|
25
|
-
getState: this.states[map.actual],
|
|
26
|
-
alexaSetter: function (alexaValue) {
|
|
27
|
-
return alexaValue === Properties.LockState.UNLOCK;
|
|
28
|
-
},
|
|
29
|
-
alexaGetter: function (value) {
|
|
30
|
-
return value ? Properties.LockState.UNLOCKED : Properties.LockState.LOCKED;
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
module.exports = Lock;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const ReadOnlyDetector = require('./ReadOnlyDetector');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
class Motion extends ReadOnlyDetector {
|
|
8
|
-
get capability() {
|
|
9
|
-
return new Capabilities.MotionSensor();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get categories() {
|
|
13
|
-
return ['MOTION_SENSOR'];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = Motion;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const AlexaResponse = require('../Alexa/AlexaResponse');
|
|
2
|
-
const Control = require('./Control');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
class ReadOnlyDetector extends Control {
|
|
8
|
-
get capability() {
|
|
9
|
-
return undefined;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
initCapabilities() {
|
|
13
|
-
let result = [this.capability];
|
|
14
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
15
|
-
property.init(this.detectedStateInitObject())
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
async handle(event) {
|
|
20
|
-
this.log.error(`Setting value is not supported by ${this.name} control`);
|
|
21
|
-
return Promise.reject(AlexaResponse.directiveNotSupportedByControl(this.name, event?.directive?.header?.namespace, event?.directive?.header?.payloadVersion).get());
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = ReadOnlyDetector;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const Control = require('./Control');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
class Socket extends Control {
|
|
8
|
-
get categories() {
|
|
9
|
-
return ['SMARTPLUG'];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
initCapabilities() {
|
|
13
|
-
let result = [new Capabilities.PowerController()];
|
|
14
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
15
|
-
property.init(this.powerStateInitObject());
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = Socket;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const Control = require('./Control');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
class Temperature extends Control {
|
|
8
|
-
get categories() {
|
|
9
|
-
return ['TEMPERATURE_SENSOR'];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
initCapabilities() {
|
|
13
|
-
let result = [new Capabilities.TemperatureSensor()];
|
|
14
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
15
|
-
property.init(this.blankInitObject())
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = Temperature;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const AdjustableControl = require('./AdjustableControl');
|
|
3
|
-
const Utils = require('../Helpers/Utils');
|
|
4
|
-
const Properties = require('../Alexa/Properties');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @class
|
|
8
|
-
*/
|
|
9
|
-
class Thermostat extends AdjustableControl {
|
|
10
|
-
get categories() {
|
|
11
|
-
return ['THERMOSTAT', 'TEMPERATURE_SENSOR']
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
adjustableProperties() {
|
|
15
|
-
return [Properties.TargetSetpoint];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
initCapabilities() {
|
|
19
|
-
let result = [new Capabilities.TemperatureSensor(), new Capabilities.ThermostatController()];
|
|
20
|
-
const map = this.statesMap;
|
|
21
|
-
// if the state POWER is present, then we can switch it ON/OFF
|
|
22
|
-
if (this.states[map.power]) {
|
|
23
|
-
result.push(new Capabilities.PowerController());
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
27
|
-
property.init(this.composeInitObject(property));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
composeInitObject(property) {
|
|
34
|
-
const map = this.statesMap;
|
|
35
|
-
|
|
36
|
-
if (property.propertyName === Properties.PowerState.propertyName) {
|
|
37
|
-
return {
|
|
38
|
-
setState: this.states[map.power] || this.states[map.set],
|
|
39
|
-
getState: this.states[map.power] || this.states[map.set],
|
|
40
|
-
alexaSetter: function (alexaValue) {
|
|
41
|
-
return alexaValue === Properties.PowerState.ON;
|
|
42
|
-
},
|
|
43
|
-
alexaGetter: function (value) {
|
|
44
|
-
return value ? Properties.PowerState.ON : Properties.PowerState.OFF;
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (property.propertyName === Properties.Temperature.propertyName) {
|
|
50
|
-
return {
|
|
51
|
-
setState: this.states[map.set],
|
|
52
|
-
getState: this.states[map.actual] || this.states[map.set],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (property.propertyName === Properties.TargetSetpoint.propertyName) {
|
|
57
|
-
return {
|
|
58
|
-
setState: this.states[map.set],
|
|
59
|
-
getState: this.states[map.actual] || this.states[map.set],
|
|
60
|
-
alexaSetter: function (alexaValue) {
|
|
61
|
-
return Utils.ensureValueInRange(alexaValue, this.valuesRangeMin, this.valuesRangeMax);
|
|
62
|
-
},
|
|
63
|
-
alexaGetter: function (value) {
|
|
64
|
-
return value;
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (property.propertyName === Properties.ThermostatMode.propertyName) {
|
|
70
|
-
const initObject = {
|
|
71
|
-
setState: this.states[map.mode] || { id: undefined },
|
|
72
|
-
getState: this.states[map.mode] || { id: undefined },
|
|
73
|
-
alexaSetter: function (alexaValue) {
|
|
74
|
-
return 0;
|
|
75
|
-
},
|
|
76
|
-
alexaGetter: function (value) {
|
|
77
|
-
return Properties.ThermostatMode.AUTO;
|
|
78
|
-
},
|
|
79
|
-
supportedModes: [Properties.ThermostatMode.AUTO]
|
|
80
|
-
};
|
|
81
|
-
return initObject;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = Thermostat;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const Control = require('./Control');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
class VacuumCleaner extends Control {
|
|
8
|
-
get categories() {
|
|
9
|
-
return ['VACUUM_CLEANER'];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
initCapabilities() {
|
|
13
|
-
let result = [new Capabilities.PowerController()];
|
|
14
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
15
|
-
property.init(this.powerStateInitObject());
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get statesMap() {
|
|
21
|
-
return {
|
|
22
|
-
'set': 'POWER',
|
|
23
|
-
'actual': undefined
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = VacuumCleaner;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
const Capabilities = require('../Alexa/Capabilities');
|
|
2
|
-
const Properties = require('../Alexa/Properties');
|
|
3
|
-
const AdapterProvider = require('../Helpers/AdapterProvider');
|
|
4
|
-
const Utils = require('../Helpers/Utils');
|
|
5
|
-
const AdjustableControl = require('./AdjustableControl');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @class
|
|
9
|
-
*/
|
|
10
|
-
class Volume extends AdjustableControl {
|
|
11
|
-
get categories() {
|
|
12
|
-
return ['SPEAKER'];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
adjustableProperties() {
|
|
16
|
-
return [Properties.Volume];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
initCapabilities() {
|
|
20
|
-
this._speaker = new Capabilities.Speaker();
|
|
21
|
-
let result = [this._speaker];
|
|
22
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
23
|
-
property.init(this.composeInitObject(property))
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async setState(property, value) {
|
|
30
|
-
// set the property itself
|
|
31
|
-
await AdapterProvider.setState(property.setId, value);
|
|
32
|
-
property.currentValue = value;
|
|
33
|
-
|
|
34
|
-
if (property.propertyName === Properties.Muted.propertyName) {
|
|
35
|
-
// set volume
|
|
36
|
-
if (value) { // set volume to 0 on MUTED true
|
|
37
|
-
await AdapterProvider.setState(this._speaker.volume.setId, 0);
|
|
38
|
-
this._lastVolume = this._speaker.volume.currentValue
|
|
39
|
-
this._speaker.volume.currentValue = 0;
|
|
40
|
-
} else { // set volume to the last known, configured or 20 otherwise on MUTED false
|
|
41
|
-
if (!this._lastVolume) {
|
|
42
|
-
this._lastVolume = this.states[this.statesMap.set].smartName?.byON;
|
|
43
|
-
this._lastVolume = isNaN(this._lastVolume) ?
|
|
44
|
-
Utils.denormalize_0_100(20, this._speaker.volume.valuesRangeMin, this._speaker.volume.valuesRangeMax) : parseInt(this._lastVolume);
|
|
45
|
-
}
|
|
46
|
-
await AdapterProvider.setState(this._speaker.volume.setId, this._lastVolume);
|
|
47
|
-
this._speaker.volume.currentValue = this._lastVolume;
|
|
48
|
-
}
|
|
49
|
-
} else { // set muted
|
|
50
|
-
const muted = value === 0;
|
|
51
|
-
// only on different IDs for volume and muted
|
|
52
|
-
if (this._speaker.volume.setId !== this._speaker.muted.setId) {
|
|
53
|
-
await AdapterProvider.setState(this._speaker.muted.setId, muted);
|
|
54
|
-
}
|
|
55
|
-
this._speaker.muted.currentValue = muted;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async getOrRetrieveCurrentValue(property) {
|
|
60
|
-
if (property.currentValue === undefined) {
|
|
61
|
-
property.currentValue = await AdapterProvider.getState(property.getId);
|
|
62
|
-
|
|
63
|
-
// convert non zero volumes to muted = false
|
|
64
|
-
if (property.propertyName === this._speaker.muted.propertyName && property.getId === this._speaker.volume.getId) {
|
|
65
|
-
property.currentValue = property.currentValue === 0;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (property.currentValue === undefined) {
|
|
70
|
-
throw new Error(`unable to retrieve ${property.getId}`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return property.currentValue;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
composeInitObject(property) {
|
|
77
|
-
|
|
78
|
-
const map = this.statesMap;
|
|
79
|
-
|
|
80
|
-
if (property.propertyName === Properties.Volume.propertyName) {
|
|
81
|
-
return {
|
|
82
|
-
setState: this.states[map.set],
|
|
83
|
-
getState: this.states[map.actual] || this.states[map.set],
|
|
84
|
-
alexaSetter: function (alexaValue) {
|
|
85
|
-
return Utils.denormalize_0_100(alexaValue, this.valuesRangeMin, this.valuesRangeMax);
|
|
86
|
-
},
|
|
87
|
-
alexaGetter: function (value) {
|
|
88
|
-
return Utils.normalize_0_100(value, this.valuesRangeMin, this.valuesRangeMax);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (property.propertyName === Properties.Muted.propertyName) {
|
|
94
|
-
return {
|
|
95
|
-
setState: this.states[map.mute] || this.states[map.set],
|
|
96
|
-
getState: this.states[map.mute] || this.states[map.set],
|
|
97
|
-
alexaSetter: function (alexaValue) {
|
|
98
|
-
return alexaValue;
|
|
99
|
-
},
|
|
100
|
-
alexaGetter: function (value) {
|
|
101
|
-
return value;
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
module.exports = Volume;
|