iobroker.iot 4.1.2 → 4.1.3

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 (40) hide show
  1. package/README.md +5 -3
  2. package/admin/assets/{index-6Itc0U48.js → index-CyfkYMpa.js} +85 -85
  3. package/admin/index_m.html +1 -1
  4. package/admin/rules/assets/{index-208Qrr3S.js → index-DBQ_ihVx.js} +83 -83
  5. package/admin/rules/customRuleBlocks.js +2 -2
  6. package/build/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js +7 -0
  7. package/build/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js.map +1 -1
  8. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +3 -1
  9. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js.map +1 -1
  10. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/SceneController.js +38 -0
  11. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/SceneController.js.map +1 -0
  12. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +2 -0
  13. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js.map +1 -1
  14. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js.map +1 -1
  15. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +67 -14
  16. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js.map +1 -1
  17. package/build/lib/AlexaSmartHomeV3/Controls/Button.js +74 -0
  18. package/build/lib/AlexaSmartHomeV3/Controls/Button.js.map +1 -0
  19. package/build/lib/AlexaSmartHomeV3/Controls/Control.js +2 -0
  20. package/build/lib/AlexaSmartHomeV3/Controls/Control.js.map +1 -1
  21. package/build/lib/AlexaSmartHomeV3/Controls/Ct.js +1 -7
  22. package/build/lib/AlexaSmartHomeV3/Controls/Ct.js.map +1 -1
  23. package/build/lib/AlexaSmartHomeV3/Controls/Hue.js +8 -5
  24. package/build/lib/AlexaSmartHomeV3/Controls/Hue.js.map +1 -1
  25. package/build/lib/AlexaSmartHomeV3/Controls/Light.js.map +1 -1
  26. package/build/lib/AlexaSmartHomeV3/Controls/RgbSingle.js +200 -0
  27. package/build/lib/AlexaSmartHomeV3/Controls/RgbSingle.js.map +1 -0
  28. package/build/lib/AlexaSmartHomeV3/Controls/RgbwSingle.js +210 -0
  29. package/build/lib/AlexaSmartHomeV3/Controls/RgbwSingle.js.map +1 -0
  30. package/build/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js.map +1 -1
  31. package/build/lib/AlexaSmartHomeV3/Controls/index.js +15 -3
  32. package/build/lib/AlexaSmartHomeV3/Controls/index.js.map +1 -1
  33. package/build/lib/AlexaSmartHomeV3/DeviceManager.js +9 -2
  34. package/build/lib/AlexaSmartHomeV3/DeviceManager.js.map +1 -1
  35. package/build/lib/AlexaSmartHomeV3/Helpers/Utils.js +287 -0
  36. package/build/lib/AlexaSmartHomeV3/Helpers/Utils.js.map +1 -1
  37. package/build/lib/alexaCustom.js +1 -1
  38. package/build/lib/alexaCustom.js.map +1 -1
  39. package/io-package.json +14 -14
  40. package/package.json +4 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RgbSingle.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/RgbSingle.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AACjD,4CAAiH;AACjH,iFAAyD;AAEzD,4EAAoD;AAEpD,gFAAwD;AACxD,4GAAoF;AAGpF,gFAAwD;AAQxD,sEAA8C;AAE9C,mCAAmC;AACnC,EAAE;AACF,sFAAsF;AACtF,EAAE;AACF,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAElJ,MAAqB,SAAU,SAAQ,2BAAiB;IACnC,qBAAqB,CAAmC;IACxD,WAAW,CAAyB;IACpC,2BAA2B,CA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C;oBACpB,qBAAqB;oBACrB,MAAM,OAAO,GAAG,IAAA,uBAAe,EAC1B,IAAI,CAAC,YAAuB,IAAI,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAC9D,IAAI,CAAC,qBAAqB,CAC7B,CAAC;oBACF,IAAI,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;oBAC5D,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;oBAC9B,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;gBAC7C,CAAC;gBAED,OAAO,UAAoB,CAAC;YAChC,CAAC;YACD,WAAW,EAAE,UAAU,KAAsC;gBACzD,OAAO,KAAe,CAAC;YAC3B,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AA9OD,4BA8OC","sourcesContent":["import Capabilities from '../Alexa/Capabilities';\nimport { configuredRangeOrDefault, denormalize_0_100, normalize_0_100, closestFromList } from '../Helpers/Utils';\nimport AdapterProvider from '../Helpers/AdapterProvider';\nimport type { Base as PropertiesBase } from '../Alexa/Properties/Base';\nimport AdjustableControl from './AdjustableControl';\nimport type BrightnessController from '../Alexa/Capabilities/BrightnessController';\nimport Brightness from '../Alexa/Properties/Brightness';\nimport ColorTemperatureInKelvin from '../Alexa/Properties/ColorTemperatureInKelvin';\nimport type ColorTemperatureController from '../Alexa/Capabilities/ColorTemperatureController';\nimport type PowerController from '../Alexa/Capabilities/PowerController';\nimport PowerState from '../Alexa/Properties/PowerState';\nimport type {\n AlexaV3Category,\n AlexaV3DirectiveValue,\n AlexaV3Request,\n IotExternalDetectorState,\n IotExternalPatternControl,\n} from '../types';\nimport Color from '../Alexa/Properties/Color';\n\n// ### RGB Light Single [rgbSingle]\n//\n// RGB light with one state of color. Could be HEX #RRGGBB, or rgb(0-255,0-255,0-255).\n//\n// | R | Name | Role | Unit | Type | Wr | Ind | Multi | Regex |\n// |---|-----------------|-------------------------------|------|---------|----|-----|-------|---------------------------------------------------|\n// | * | RGB | level.color.rgb | | string | W | | | `/^level\\.color\\.rgb$/` |\n// | | DIMMER | level.dimmer | % | number | W | | | `/^level\\.dimmer$/` |\n// | | BRIGHTNESS | | % | number | W | | | `/^level\\.brightness$/` |\n// | | TEMPERATURE | level.color.temperature | °K | number | W | | | `/^level\\.color\\.temperature$/` |\n// | | ON | switch.light | | boolean | W | | | `/^switch(\\.light)?$/` |\n// | | ON_ACTUAL | sensor.light | | boolean | - | | | `/^(state|switch|sensor)\\.light|switch$/` |\n\nexport default class RgbSingle extends AdjustableControl {\n private readonly _brightnessCapability: BrightnessController | undefined;\n private readonly _brightness: Brightness | undefined;\n private readonly _colorTemperatureCapability: ColorTemperatureController | undefined;\n private readonly _powerControllerCapability: PowerController | undefined;\n private readonly _powerState: PowerState | undefined;\n\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n\n const map = this.statesMap;\n this._supported = [new Capabilities.ColorController(this.composeInitObjectColor())];\n\n if (this.states[map.temperature]) {\n this._colorTemperatureCapability = new Capabilities.ColorTemperatureController(\n this.composeInitObjectColorTemperature(),\n );\n this._supported.push(this._colorTemperatureCapability);\n }\n\n // if the state DIMMER or BRIGHTNESS configured\n if (this.states[map.dimmer] || this.states[map.brightness]) {\n this._brightnessCapability = new Capabilities.BrightnessController(this.composeInitObjectBrightness());\n this._brightness = this._brightnessCapability.brightness;\n this._supported.push(this._brightnessCapability);\n }\n\n // if the state ON, DIMMER or BRIGHTNESS configured\n if (this.states[map.on] || this._brightness) {\n this._powerControllerCapability = new Capabilities.PowerController(this.composeInitObjectPowerState());\n this._powerState = this._powerControllerCapability.powerState;\n this._supported.push(this._powerControllerCapability);\n }\n }\n\n get categories(): AlexaV3Category[] {\n return ['LIGHT'];\n }\n\n adjustableProperties(): (typeof PropertiesBase)[] {\n return [ColorTemperatureInKelvin];\n }\n\n protected async getOrRetrieveCurrentValue(property: PropertiesBase): Promise<ioBroker.StateValue> {\n const map = this.statesMap;\n\n if (property.currentValue === undefined) {\n property.currentValue = await AdapterProvider.getState(property.getId);\n // convert the non-zero brightness to power = true\n if (property.propertyName === PowerState.propertyName && !this.states[map.on]) {\n property.currentValue = property.currentValue !== 0;\n }\n }\n\n if (property.currentValue === undefined) {\n throw new Error(`unable to retrieve ${property.getId}`);\n }\n\n return property.currentValue;\n }\n\n async setState(property: PropertiesBase, value: ioBroker.StateValue): Promise<void> {\n const map = this.statesMap;\n\n if (property.propertyName === PowerState.propertyName) {\n if (this.states[map.on]) {\n await AdapterProvider.setState(property.setId, value);\n property.currentValue = value;\n } else {\n if (!this._brightness) {\n throw new Error('No brightness property configured');\n }\n if (!this._powerState) {\n throw new Error('No powerState property configured');\n }\n\n if (value) {\n // set brightness\n // set byOn to the configured value or range.max otherwise\n const range = configuredRangeOrDefault(this.states[map.dimmer] || this.states[map.brightness]!);\n const smartName = (this.states[map.dimmer] || this.states[map.brightness])?.smartName;\n let byOn: number | string | undefined | null;\n if (smartName && typeof smartName === 'object') {\n byOn = smartName.byON;\n } else {\n byOn = undefined;\n }\n if (byOn === undefined || byOn === null || isNaN(byOn as unknown as number)) {\n byOn = range.max as number | string | undefined | null;\n } else {\n byOn = parseFloat(byOn);\n }\n await AdapterProvider.setState(this._brightness.setId, byOn ?? 100);\n this._brightness.currentValue = byOn;\n this._powerState.currentValue = true;\n } else {\n // set brightness to 0 on power OFF\n await AdapterProvider.setState(this._brightness.setId, 0);\n this._brightness.currentValue = 0;\n this._powerState.currentValue = false;\n }\n }\n } else if (property.propertyName === Color.propertyName) {\n // For Color property, convert HAL format to RGB hex string\n await AdapterProvider.setState(this.states[map.rgb]!.id, value);\n property.currentValue = value;\n } else if (\n property.propertyName === Brightness.propertyName ||\n property.propertyName === ColorTemperatureInKelvin.propertyName\n ) {\n await AdapterProvider.setState(property.setId, value);\n property.currentValue = value;\n }\n }\n\n async adjustValue(event: AlexaV3Request, property: PropertiesBase): Promise<AlexaV3DirectiveValue> {\n // extract Alexa delta value from event\n const delta = property.alexaDirectiveValue(event);\n\n // convert delta to iobroker value\n const value = property.value(delta);\n\n // set iobroker state\n await this.setState(property, value ?? 0);\n\n return value as AlexaV3DirectiveValue;\n }\n\n protected composeInitObjectColor(): {\n setState?: IotExternalDetectorState;\n getState?: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n rgb?:\n | IotExternalDetectorState\n | {\n red: IotExternalDetectorState;\n green: IotExternalDetectorState;\n blue: IotExternalDetectorState;\n };\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.rgb]!,\n getState: this.states[map.rgb]!,\n rgb: this.states[map.rgb]!,\n };\n }\n\n protected composeInitObjectPowerState(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness]!,\n getState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness]!,\n alexaSetter: function (this: PropertiesBase, alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue {\n return alexaValue === PowerState.ON;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value ? PowerState.ON : PowerState.OFF;\n },\n };\n }\n\n protected composeInitObjectBrightness(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.dimmer] || this.states[map.brightness]!,\n getState: this.states[map.dimmer] || this.states[map.brightness]!,\n alexaSetter: function (this: PropertiesBase, alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue {\n return (\n denormalize_0_100(\n alexaValue as number,\n this.valuesRangeMin as number,\n this.valuesRangeMax as number,\n ) ?? 0\n );\n },\n alexaGetter: function (\n this: PropertiesBase,\n value: ioBroker.StateValue | undefined,\n ): AlexaV3DirectiveValue {\n return normalize_0_100(value as number, this.valuesRangeMin as number, this.valuesRangeMax as number);\n },\n };\n }\n\n protected composeInitObjectColorTemperature(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.temperature]!,\n getState: this.states[map.temperature]!,\n alexaSetter: function (\n this: ColorTemperatureInKelvin,\n alexaValue: AlexaV3DirectiveValue,\n ): ioBroker.StateValue {\n if (alexaValue === 1) {\n // increase directive\n const closest = closestFromList(\n (this.currentValue as number) || this.colorTemperatureTable[0],\n this.colorTemperatureTable,\n );\n let index = this.colorTemperatureTable.indexOf(closest) + 1;\n index = index >= this.colorTemperatureTable.length ? this.colorTemperatureTable.length - 1 : index;\n return this.colorTemperatureTable[index];\n }\n if (alexaValue === -1) {\n // decrease directive\n const closest = closestFromList(\n (this.currentValue as number) || this.colorTemperatureTable[0],\n this.colorTemperatureTable,\n );\n let index = this.colorTemperatureTable.indexOf(closest) - 1;\n index = index < 0 ? 0 : index;\n return this.colorTemperatureTable[index];\n }\n\n return alexaValue as number;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value as number;\n },\n };\n }\n}\n"]}
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Capabilities_1 = __importDefault(require("../Alexa/Capabilities"));
7
+ const Utils_1 = require("../Helpers/Utils");
8
+ const AdapterProvider_1 = __importDefault(require("../Helpers/AdapterProvider"));
9
+ const AdjustableControl_1 = __importDefault(require("./AdjustableControl"));
10
+ const Brightness_1 = __importDefault(require("../Alexa/Properties/Brightness"));
11
+ const Color_1 = __importDefault(require("../Alexa/Properties/Color"));
12
+ const ColorTemperatureInKelvin_1 = __importDefault(require("../Alexa/Properties/ColorTemperatureInKelvin"));
13
+ const PowerState_1 = __importDefault(require("../Alexa/Properties/PowerState"));
14
+ // ### RGBW Light Single [rgbwSingle]
15
+ //
16
+ // RGBW light one state of color. Could be HEX #RRGGBBWW, or rgba(0-255,0-255,0-255,0-1).
17
+ //
18
+ // | R | Name | Role | Unit | Type | Wr | Ind | Multi | Regex |
19
+ // |---|-----------------|-------------------------------|------|---------|----|-----|-------|---------------------------------------------------|
20
+ // | * | RGBW | level.color.rgbw | | string | W | | | `/^level\.color\.rgbw$/` |
21
+ // | | DIMMER | level.dimmer | % | number | W | | | `/^level\.dimmer$/` |
22
+ // | | BRIGHTNESS | | % | number | W | | | `/^level\.brightness$/` |
23
+ // | | TEMPERATURE | level.color.temperature | °K | number | W | | | `/^level\.color\.temperature$/` |
24
+ // | | ON | switch.light | | boolean | W | | | `/^switch(\.light)?$/` |
25
+ // | | ON_ACTUAL | sensor.light | | boolean | - | | | `/^(state|switch|sensor)\.light|switch$/` |
26
+ class RgbwSingle extends AdjustableControl_1.default {
27
+ _brightnessCapability;
28
+ _brightness;
29
+ _colorTemperatureCapability;
30
+ _powerControllerCapability;
31
+ _powerState;
32
+ constructor(detectedControl) {
33
+ super(detectedControl);
34
+ const map = this.statesMap;
35
+ this._supported = [new Capabilities_1.default.ColorController(this.composeInitObjectColor())];
36
+ if (this.states[map.temperature]) {
37
+ this._colorTemperatureCapability = new Capabilities_1.default.ColorTemperatureController(this.composeInitObjectColorTemperature());
38
+ this._supported.push(this._colorTemperatureCapability);
39
+ }
40
+ // if the state DIMMER or BRIGHTNESS configured
41
+ if (this.states[map.dimmer] || this.states[map.brightness]) {
42
+ this._brightnessCapability = new Capabilities_1.default.BrightnessController(this.composeInitObjectBrightness());
43
+ this._brightness = this._brightnessCapability.brightness;
44
+ this._supported.push(this._brightnessCapability);
45
+ }
46
+ // if the state ON, DIMMER or BRIGHTNESS configured
47
+ if (this.states[map.on] || this._brightness) {
48
+ this._powerControllerCapability = new Capabilities_1.default.PowerController(this.composeInitObjectPowerState());
49
+ this._powerState = this._powerControllerCapability.powerState;
50
+ this._supported.push(this._powerControllerCapability);
51
+ }
52
+ }
53
+ get categories() {
54
+ return ['LIGHT'];
55
+ }
56
+ adjustableProperties() {
57
+ return [ColorTemperatureInKelvin_1.default];
58
+ }
59
+ async getOrRetrieveCurrentValue(property) {
60
+ const map = this.statesMap;
61
+ if (property.currentValue === undefined) {
62
+ property.currentValue = await AdapterProvider_1.default.getState(property.getId);
63
+ // convert the non-zero brightness to power = true
64
+ if (property.propertyName === PowerState_1.default.propertyName && !this.states[map.on]) {
65
+ property.currentValue = property.currentValue !== 0;
66
+ }
67
+ }
68
+ if (property.currentValue === undefined) {
69
+ throw new Error(`unable to retrieve ${property.getId}`);
70
+ }
71
+ return property.currentValue;
72
+ }
73
+ async setState(property, value) {
74
+ const map = this.statesMap;
75
+ if (property.propertyName === PowerState_1.default.propertyName) {
76
+ if (this.states[map.on]) {
77
+ await AdapterProvider_1.default.setState(property.setId, value);
78
+ property.currentValue = value;
79
+ }
80
+ else {
81
+ if (!this._brightness) {
82
+ throw new Error('No brightness property configured');
83
+ }
84
+ if (!this._powerState) {
85
+ throw new Error('No powerState property configured');
86
+ }
87
+ if (value) {
88
+ // set brightness
89
+ // set byOn to the configured value or range.max otherwise
90
+ const range = (0, Utils_1.configuredRangeOrDefault)(this.states[map.dimmer] || this.states[map.brightness]);
91
+ const smartName = (this.states[map.dimmer] || this.states[map.brightness])?.smartName;
92
+ let byOn;
93
+ if (smartName && typeof smartName === 'object') {
94
+ byOn = smartName.byON;
95
+ }
96
+ else {
97
+ byOn = undefined;
98
+ }
99
+ if (byOn === undefined || byOn === null || isNaN(byOn)) {
100
+ byOn = range.max;
101
+ }
102
+ else {
103
+ byOn = parseFloat(byOn);
104
+ }
105
+ await AdapterProvider_1.default.setState(this._brightness.setId, byOn ?? 100);
106
+ this._brightness.currentValue = byOn;
107
+ this._powerState.currentValue = true;
108
+ }
109
+ else {
110
+ // set brightness to 0 on power OFF
111
+ await AdapterProvider_1.default.setState(this._brightness.setId, 0);
112
+ this._brightness.currentValue = 0;
113
+ this._powerState.currentValue = false;
114
+ }
115
+ }
116
+ }
117
+ else if (property.propertyName === Brightness_1.default.propertyName ||
118
+ property.propertyName === Color_1.default.propertyName ||
119
+ property.propertyName === ColorTemperatureInKelvin_1.default.propertyName) {
120
+ await AdapterProvider_1.default.setState(property.setId, value);
121
+ property.currentValue = value;
122
+ }
123
+ }
124
+ async adjustValue(event, property) {
125
+ // extract Alexa delta value from event
126
+ const delta = property.alexaDirectiveValue(event);
127
+ // convert delta to iobroker value
128
+ const value = property.value(delta);
129
+ // set iobroker state
130
+ await this.setState(property, value ?? 0);
131
+ return value;
132
+ }
133
+ composeInitObjectColor() {
134
+ const map = this.statesMap;
135
+ return {
136
+ setState: this.states[map.rgbw],
137
+ getState: this.states[map.rgbw],
138
+ alexaSetter: function (alexaValue) {
139
+ // Convert {
140
+ // "hue": 350.5,
141
+ // "saturation": 0.7138,
142
+ // "brightness": 0.6524
143
+ // } to RGB hex #RRGGBBWW
144
+ if (typeof alexaValue === 'object' && alexaValue !== null) {
145
+ return (0, Utils_1.hal2rgbw)(alexaValue);
146
+ }
147
+ return null;
148
+ },
149
+ alexaGetter: function (value) {
150
+ return (0, Utils_1.rgbw2hal)((0, Utils_1.rgbwToHex)(value));
151
+ },
152
+ rgbw: this.states[map.rgbw],
153
+ };
154
+ }
155
+ composeInitObjectPowerState() {
156
+ const map = this.statesMap;
157
+ return {
158
+ setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
159
+ getState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
160
+ alexaSetter: function (alexaValue) {
161
+ return alexaValue === PowerState_1.default.ON;
162
+ },
163
+ alexaGetter: function (value) {
164
+ return value ? PowerState_1.default.ON : PowerState_1.default.OFF;
165
+ },
166
+ };
167
+ }
168
+ composeInitObjectBrightness() {
169
+ const map = this.statesMap;
170
+ return {
171
+ setState: this.states[map.dimmer] || this.states[map.brightness],
172
+ getState: this.states[map.dimmer] || this.states[map.brightness],
173
+ alexaSetter: function (alexaValue) {
174
+ return ((0, Utils_1.denormalize_0_100)(alexaValue, this.valuesRangeMin, this.valuesRangeMax) ?? 0);
175
+ },
176
+ alexaGetter: function (value) {
177
+ return (0, Utils_1.normalize_0_100)(value, this.valuesRangeMin, this.valuesRangeMax);
178
+ },
179
+ };
180
+ }
181
+ composeInitObjectColorTemperature() {
182
+ const map = this.statesMap;
183
+ return {
184
+ setState: this.states[map.temperature],
185
+ getState: this.states[map.temperature],
186
+ alexaSetter: function (alexaValue) {
187
+ if (alexaValue === 1) {
188
+ // increase directive
189
+ const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
190
+ let index = this.colorTemperatureTable.indexOf(closest) + 1;
191
+ index = index >= this.colorTemperatureTable.length ? this.colorTemperatureTable.length - 1 : index;
192
+ return this.colorTemperatureTable[index];
193
+ }
194
+ if (alexaValue === -1) {
195
+ // decrease directive
196
+ const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
197
+ let index = this.colorTemperatureTable.indexOf(closest) - 1;
198
+ index = index < 0 ? 0 : index;
199
+ return this.colorTemperatureTable[index];
200
+ }
201
+ return alexaValue;
202
+ },
203
+ alexaGetter: function (value) {
204
+ return value;
205
+ },
206
+ };
207
+ }
208
+ }
209
+ exports.default = RgbwSingle;
210
+ //# sourceMappingURL=RgbwSingle.js.map
@@ -0,0 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B,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AA5PD,6BA4PC","sourcesContent":["import Capabilities from '../Alexa/Capabilities';\nimport {\n configuredRangeOrDefault,\n denormalize_0_100,\n normalize_0_100,\n closestFromList,\n rgbwToHex,\n rgbw2hal,\n hal2rgbw,\n} from '../Helpers/Utils';\nimport AdapterProvider from '../Helpers/AdapterProvider';\nimport AdjustableControl from './AdjustableControl';\nimport type { Base as PropertiesBase } from '../Alexa/Properties/Base';\nimport type BrightnessController from '../Alexa/Capabilities/BrightnessController';\nimport Brightness from '../Alexa/Properties/Brightness';\nimport Color from '../Alexa/Properties/Color';\nimport ColorTemperatureInKelvin from '../Alexa/Properties/ColorTemperatureInKelvin';\nimport type ColorTemperatureController from '../Alexa/Capabilities/ColorTemperatureController';\nimport type PowerController from '../Alexa/Capabilities/PowerController';\nimport PowerState from '../Alexa/Properties/PowerState';\nimport type {\n AlexaV3Category,\n AlexaV3DirectiveValue,\n AlexaV3Request,\n IotExternalDetectorState,\n IotExternalPatternControl,\n} from '../types';\n\n// ### RGBW Light Single [rgbwSingle]\n//\n// RGBW light one state of color. Could be HEX #RRGGBBWW, or rgba(0-255,0-255,0-255,0-1).\n//\n// | R | Name | Role | Unit | Type | Wr | Ind | Multi | Regex |\n// |---|-----------------|-------------------------------|------|---------|----|-----|-------|---------------------------------------------------|\n// | * | RGBW | level.color.rgbw | | string | W | | | `/^level\\.color\\.rgbw$/` |\n// | | DIMMER | level.dimmer | % | number | W | | | `/^level\\.dimmer$/` |\n// | | BRIGHTNESS | | % | number | W | | | `/^level\\.brightness$/` |\n// | | TEMPERATURE | level.color.temperature | °K | number | W | | | `/^level\\.color\\.temperature$/` |\n// | | ON | switch.light | | boolean | W | | | `/^switch(\\.light)?$/` |\n// | | ON_ACTUAL | sensor.light | | boolean | - | | | `/^(state|switch|sensor)\\.light|switch$/` |\n\nexport default class RgbwSingle extends AdjustableControl {\n private readonly _brightnessCapability: BrightnessController | undefined;\n private readonly _brightness: Brightness | undefined;\n private readonly _colorTemperatureCapability: ColorTemperatureController | undefined;\n private readonly _powerControllerCapability: PowerController | undefined;\n private readonly _powerState: PowerState | undefined;\n\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n\n const map = this.statesMap;\n this._supported = [new Capabilities.ColorController(this.composeInitObjectColor())];\n\n if (this.states[map.temperature]) {\n this._colorTemperatureCapability = new Capabilities.ColorTemperatureController(\n this.composeInitObjectColorTemperature(),\n );\n this._supported.push(this._colorTemperatureCapability);\n }\n\n // if the state DIMMER or BRIGHTNESS configured\n if (this.states[map.dimmer] || this.states[map.brightness]) {\n this._brightnessCapability = new Capabilities.BrightnessController(this.composeInitObjectBrightness());\n this._brightness = this._brightnessCapability.brightness;\n this._supported.push(this._brightnessCapability);\n }\n\n // if the state ON, DIMMER or BRIGHTNESS configured\n if (this.states[map.on] || this._brightness) {\n this._powerControllerCapability = new Capabilities.PowerController(this.composeInitObjectPowerState());\n this._powerState = this._powerControllerCapability.powerState;\n this._supported.push(this._powerControllerCapability);\n }\n }\n\n get categories(): AlexaV3Category[] {\n return ['LIGHT'];\n }\n\n adjustableProperties(): (typeof PropertiesBase)[] {\n return [ColorTemperatureInKelvin];\n }\n\n protected async getOrRetrieveCurrentValue(property: PropertiesBase): Promise<ioBroker.StateValue> {\n const map = this.statesMap;\n\n if (property.currentValue === undefined) {\n property.currentValue = await AdapterProvider.getState(property.getId);\n // convert the non-zero brightness to power = true\n if (property.propertyName === PowerState.propertyName && !this.states[map.on]) {\n property.currentValue = property.currentValue !== 0;\n }\n }\n\n if (property.currentValue === undefined) {\n throw new Error(`unable to retrieve ${property.getId}`);\n }\n\n return property.currentValue;\n }\n\n async setState(property: PropertiesBase, value: ioBroker.StateValue): Promise<void> {\n const map = this.statesMap;\n\n if (property.propertyName === PowerState.propertyName) {\n if (this.states[map.on]) {\n await AdapterProvider.setState(property.setId, value);\n property.currentValue = value;\n } else {\n if (!this._brightness) {\n throw new Error('No brightness property configured');\n }\n if (!this._powerState) {\n throw new Error('No powerState property configured');\n }\n\n if (value) {\n // set brightness\n // set byOn to the configured value or range.max otherwise\n const range = configuredRangeOrDefault(this.states[map.dimmer] || this.states[map.brightness]!);\n const smartName = (this.states[map.dimmer] || this.states[map.brightness])?.smartName;\n let byOn: number | string | undefined | null;\n if (smartName && typeof smartName === 'object') {\n byOn = smartName.byON;\n } else {\n byOn = undefined;\n }\n if (byOn === undefined || byOn === null || isNaN(byOn as unknown as number)) {\n byOn = range.max as number | string | undefined | null;\n } else {\n byOn = parseFloat(byOn);\n }\n await AdapterProvider.setState(this._brightness.setId, byOn ?? 100);\n this._brightness.currentValue = byOn;\n this._powerState.currentValue = true;\n } else {\n // set brightness to 0 on power OFF\n await AdapterProvider.setState(this._brightness.setId, 0);\n this._brightness.currentValue = 0;\n this._powerState.currentValue = false;\n }\n }\n } else if (\n property.propertyName === Brightness.propertyName ||\n property.propertyName === Color.propertyName ||\n property.propertyName === ColorTemperatureInKelvin.propertyName\n ) {\n await AdapterProvider.setState(property.setId, value);\n property.currentValue = value;\n }\n }\n\n async adjustValue(event: AlexaV3Request, property: PropertiesBase): Promise<AlexaV3DirectiveValue> {\n // extract Alexa delta value from event\n const delta = property.alexaDirectiveValue(event);\n\n // convert delta to iobroker value\n const value = property.value(delta);\n\n // set iobroker state\n await this.setState(property, value ?? 0);\n\n return value as AlexaV3DirectiveValue;\n }\n\n protected composeInitObjectColor(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n rgbw:\n | IotExternalDetectorState\n | {\n red: IotExternalDetectorState;\n green: IotExternalDetectorState;\n blue: IotExternalDetectorState;\n white: IotExternalDetectorState;\n };\n } {\n const map = this.statesMap;\n\n return {\n setState: this.states[map.rgbw]!,\n getState: this.states[map.rgbw]!,\n alexaSetter: function (this: PropertiesBase, alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue {\n // Convert {\n // \"hue\": 350.5,\n // \"saturation\": 0.7138,\n // \"brightness\": 0.6524\n // } to RGB hex #RRGGBBWW\n if (typeof alexaValue === 'object' && alexaValue !== null) {\n return hal2rgbw(alexaValue as { hue: number; saturation: number; brightness: number });\n }\n\n return null;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return rgbw2hal(rgbwToHex(value as string));\n },\n rgbw: this.states[map.rgbw]!,\n };\n }\n\n protected composeInitObjectPowerState(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness]!,\n getState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness]!,\n alexaSetter: function (this: PropertiesBase, alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue {\n return alexaValue === PowerState.ON;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value ? PowerState.ON : PowerState.OFF;\n },\n };\n }\n\n protected composeInitObjectBrightness(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.dimmer] || this.states[map.brightness]!,\n getState: this.states[map.dimmer] || this.states[map.brightness]!,\n alexaSetter: function (this: PropertiesBase, alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue {\n return (\n denormalize_0_100(\n alexaValue as number,\n this.valuesRangeMin as number,\n this.valuesRangeMax as number,\n ) ?? 0\n );\n },\n alexaGetter: function (\n this: PropertiesBase,\n value: ioBroker.StateValue | undefined,\n ): AlexaV3DirectiveValue {\n return normalize_0_100(value as number, this.valuesRangeMin as number, this.valuesRangeMax as number);\n },\n };\n }\n\n protected composeInitObjectColorTemperature(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.temperature]!,\n getState: this.states[map.temperature]!,\n alexaSetter: function (\n this: ColorTemperatureInKelvin,\n alexaValue: AlexaV3DirectiveValue,\n ): ioBroker.StateValue {\n if (alexaValue === 1) {\n // increase directive\n const closest = closestFromList(\n (this.currentValue as number) || this.colorTemperatureTable[0],\n this.colorTemperatureTable,\n );\n let index = this.colorTemperatureTable.indexOf(closest) + 1;\n index = index >= this.colorTemperatureTable.length ? this.colorTemperatureTable.length - 1 : index;\n return this.colorTemperatureTable[index];\n }\n if (alexaValue === -1) {\n // decrease directive\n const closest = closestFromList(\n (this.currentValue as number) || this.colorTemperatureTable[0],\n this.colorTemperatureTable,\n );\n let index = this.colorTemperatureTable.indexOf(closest) - 1;\n index = index < 0 ? 0 : index;\n return this.colorTemperatureTable[index];\n }\n\n return alexaValue as number;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value as number;\n },\n };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"VacuumCleaner.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.ts"],"names":[],"mappings":";;;;;AACA,yEAAiD;AACjD,wDAAgC;AAEhC,MAAqB,aAAc,SAAQ,iBAAO;IAC9C,YAAY,eAA0C;QAClD,KAAK,CAAC,eAAe,CAAC,CAAC;QAEvB,MAAM,eAAe,GAAG,IAAI,sBAAY,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QACtF,IAAI,CAAC,UAAU,GAAG,CAAC,eAAe,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,UAAU;QACV,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,SAAS;QAIT,OAAO;YACH,GAAG,EAAE,OAAO;YACZ,MAAM,EAAE,SAAS;SACpB,CAAC;IACN,CAAC;CACJ;AArBD,gCAqBC","sourcesContent":["import type { AlexaV3Category, IotExternalPatternControl } from '../types';\nimport Capabilities from '../Alexa/Capabilities';\nimport Control from './Control';\n\nexport default class VacuumCleaner extends Control {\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n\n const powerController = new Capabilities.PowerController(this.powerStateInitObject());\n this._supported = [powerController];\n }\n\n get categories(): AlexaV3Category[] {\n return ['VACUUM_CLEANER'];\n }\n\n get statesMap(): {\n set: string;\n actual?: string;\n } {\n return {\n set: 'POWER',\n actual: undefined,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"VacuumCleaner.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.ts"],"names":[],"mappings":";;;;;AACA,yEAAiD;AACjD,wDAAoD;AAEpD,MAAqB,aAAc,SAAQ,iBAAO;IAC9C,YAAY,eAA0C;QAClD,KAAK,CAAC,eAAe,CAAC,CAAC;QAEvB,MAAM,eAAe,GAAG,IAAI,sBAAY,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QACtF,IAAI,CAAC,UAAU,GAAG,CAAC,eAAe,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,UAAU;QACV,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,SAAS;QAIT,OAAO;YACH,GAAG,EAAE,OAAO;YACZ,MAAM,EAAE,SAAS;SACpB,CAAC;IACN,CAAC;CACJ;AArBD,gCAqBC","sourcesContent":["import type { AlexaV3Category, IotExternalPatternControl } from '../types';\nimport Capabilities from '../Alexa/Capabilities';\nimport Control, { type StateName } from './Control';\n\nexport default class VacuumCleaner extends Control {\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n\n const powerController = new Capabilities.PowerController(this.powerStateInitObject());\n this._supported = [powerController];\n }\n\n get categories(): AlexaV3Category[] {\n return ['VACUUM_CLEANER'];\n }\n\n get statesMap(): {\n set: StateName;\n actual?: StateName;\n } {\n return {\n set: 'POWER',\n actual: undefined,\n };\n }\n}\n"]}
@@ -16,7 +16,10 @@ const Hue_1 = __importDefault(require("./Hue"));
16
16
  const Light_1 = __importDefault(require("./Light"));
17
17
  const Lock_1 = __importDefault(require("./Lock"));
18
18
  const Motion_1 = __importDefault(require("./Motion"));
19
+ const RgbSingle_1 = __importDefault(require("./RgbSingle"));
20
+ const RgbwSingle_1 = __importDefault(require("./RgbwSingle"));
19
21
  const ReadOnlyDetector_1 = __importDefault(require("./ReadOnlyDetector"));
22
+ const Button_1 = __importDefault(require("./Button"));
20
23
  const Slider_1 = __importDefault(require("./Slider"));
21
24
  const Socket_1 = __importDefault(require("./Socket"));
22
25
  const Temperature_1 = __importDefault(require("./Temperature"));
@@ -66,9 +69,15 @@ exports.default = {
66
69
  if (item.type === Motion_1.default.type) {
67
70
  return new Motion_1.default(item);
68
71
  }
69
- // if (item.type === ReadOnlyDetector.type) {
70
- // return new ReadOnlyDetector(item);
71
- // }
72
+ if (item.type === RgbSingle_1.default.type) {
73
+ return new RgbSingle_1.default(item);
74
+ }
75
+ if (item.type === RgbwSingle_1.default.type) {
76
+ return new RgbwSingle_1.default(item);
77
+ }
78
+ if (item.type === Button_1.default.type) {
79
+ return new Button_1.default(item);
80
+ }
72
81
  if (item.type === Slider_1.default.type) {
73
82
  return new Slider_1.default(item);
74
83
  }
@@ -109,6 +118,9 @@ exports.default = {
109
118
  Lock: Lock_1.default,
110
119
  Motion: Motion_1.default,
111
120
  ReadOnlyDetector: ReadOnlyDetector_1.default,
121
+ RgbSingle: RgbSingle_1.default,
122
+ RgbwSingle: RgbwSingle_1.default,
123
+ Scene: Button_1.default,
112
124
  Slider: Slider_1.default,
113
125
  Socket: Socket_1.default,
114
126
  Temperature: Temperature_1.default,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/index.ts"],"names":[],"mappings":";;;;;AAAA,4EAAoD;AACpD,gGAAwE;AACxE,kEAA0C;AAC1C,oDAA4B;AAC5B,oEAA4C;AAE5C,8CAAsB;AACtB,sDAA8B;AAC9B,kDAA0B;AAC1B,kDAA0B;AAC1B,gDAAwB;AACxB,oDAA4B;AAC5B,kDAA0B;AAC1B,sDAA8B;AAC9B,0EAAkD;AAClD,sDAA8B;AAC9B,sDAA8B;AAC9B,gEAAwC;AACxC,8DAAsC;AACtC,oEAA4C;AAC5C,sDAA8B;AAC9B,gEAAwC;AACxC,sDAA8B;AAG9B,kBAAe;IACX,OAAO,EAAE,CAAC,IAA+B,EAAkB,EAAE;QACzD,8CAA8C;QAC9C,0CAA0C;QAC1C,IAAI;QACJ,IAAI,IAAI,CAAC,IAAI,KAAK,qCAA2B,CAAC,IAAI,EAAE,CAAC;YACjD,OAAO,IAAI,qCAA2B,CAAC,IAAI,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAY,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,IAAI,sBAAY,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,eAAK,CAAC,IAAI,EAAE,CAAC;YAC3B,OAAO,IAAI,eAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,uBAAa,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAI,uBAAa,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,YAAE,CAAC,IAAI,EAAE,CAAC;YACxB,OAAO,IAAI,YA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qBAAW;IACX,UAAU,EAAV,oBAAU;IACV,aAAa,EAAb,uBAAa;IACb,MAAM,EAAN,gBAAM;IACN,WAAW,EAAX,qBAAW;IACX,MAAM,EAAN,gBAAM;CACT,CAAC","sourcesContent":["import AdjustableControl from './AdjustableControl';\nimport AdjustablePercentageControl from './AdjustablePercentageControl';\nimport AirCondition from './AirCondition';\nimport Blind from './Blind';\nimport ContactSensor from './ContactSensor';\nimport type Control from './Control';\nimport Ct from './Ct';\nimport Dimmer from './Dimmer';\nimport Door from './Door';\nimport Gate from './Gate';\nimport Hue from './Hue';\nimport Light from './Light';\nimport Lock from './Lock';\nimport Motion from './Motion';\nimport ReadOnlyDetector from './ReadOnlyDetector';\nimport Slider from './Slider';\nimport Socket from './Socket';\nimport Temperature from './Temperature';\nimport Thermostat from './Thermostat';\nimport VacuumCleaner from './VacuumCleaner';\nimport Volume from './Volume';\nimport VolumeGroup from './VolumeGroup';\nimport Window from './Window';\nimport type { IotExternalPatternControl } from '../types';\n\nexport default {\n factory: (item: IotExternalPatternControl): Control | null => {\n // if (item.type === AdjustableControl.type) {\n // return new AdjustableControl(item);\n // }\n if (item.type === AdjustablePercentageControl.type) {\n return new AdjustablePercentageControl(item);\n }\n if (item.type === AirCondition.type) {\n return new AirCondition(item);\n }\n if (item.type === Blind.type) {\n return new Blind(item);\n }\n if (item.type === ContactSensor.type) {\n return new ContactSensor(item);\n }\n if (item.type === Ct.type) {\n return new Ct(item);\n }\n if (item.type === Dimmer.type) {\n return new Dimmer(item);\n }\n if (item.type === Door.type) {\n return new Door(item);\n }\n if (item.type === Gate.type) {\n return new Gate(item);\n }\n if (item.type === Hue.type) {\n return new Hue(item);\n }\n if (item.type === Light.type) {\n return new Light(item);\n }\n if (item.type === Lock.type) {\n return new Lock(item);\n }\n if (item.type === Motion.type) {\n return new Motion(item);\n }\n // if (item.type === ReadOnlyDetector.type) {\n // return new ReadOnlyDetector(item);\n // }\n if (item.type === Slider.type) {\n return new Slider(item);\n }\n if (item.type === Socket.type) {\n return new Socket(item);\n }\n if (item.type === Temperature.type) {\n return new Temperature(item);\n }\n if (item.type === Thermostat.type) {\n return new Thermostat(item);\n }\n if (item.type === VacuumCleaner.type) {\n return new VacuumCleaner(item);\n }\n if (item.type === Volume.type) {\n return new Volume(item);\n }\n if (item.type === VolumeGroup.type) {\n return new VolumeGroup(item);\n }\n if (item.type === Window.type) {\n return new Window(item);\n }\n return null;\n },\n AdjustableControl,\n AdjustablePercentageControl,\n AirCondition,\n Blind,\n ContactSensor,\n Ct,\n Dimmer,\n Door,\n Gate,\n Hue,\n Light,\n Lock,\n Motion,\n ReadOnlyDetector,\n Slider,\n Socket,\n Temperature,\n Thermostat,\n VacuumCleaner,\n Volume,\n VolumeGroup,\n Window,\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/index.ts"],"names":[],"mappings":";;;;;AAAA,4EAAoD;AACpD,gGAAwE;AACxE,kEAA0C;AAC1C,oDAA4B;AAC5B,oEAA4C;AAE5C,8CAAsB;AACtB,sDAA8B;AAC9B,kDAA0B;AAC1B,kDAA0B;AAC1B,gDAAwB;AACxB,oDAA4B;AAC5B,kDAA0B;AAC1B,sDAA8B;AAC9B,4DAAoC;AACpC,8DAAsC;AACtC,0EAAkD;AAClD,sDAA8B;AAC9B,sDAA8B;AAC9B,sDAA8B;AAC9B,gEAAwC;AACxC,8DAAsC;AACtC,oEAA4C;AAC5C,sDAA8B;AAC9B,gEAAwC;AACxC,sDAA8B;AAG9B,kBAAe;IACX,OAAO,EAAE,CAAC,IAA+B,EAAkB,EAAE;QACzD,8CAA8C;QAC9C,0CAA0C;QAC1C,IAAI;QACJ,IAAI,IAAI,CAAC,IAAI,KAAK,qCAA2B,CAAC,IAAI,EAAE,CAAC;YACjD,OAAO,IAAI,qCAA2B,CAAC,IAAI,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAY,CAAC,IAAI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,gBAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAW,CAAC,IAAI,EAAE,CAAC;YACjC,OAAO,IAAI,qBAAW,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAM,CAAC,IAAI,EAAE,CAAC;YAC5B,OAAO,IAAI,gBAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,iBAAiB,EAAjB,2BAAiB;IACjB,2BAA2B,EAA3B,qCAA2B;IAC3B,YAAY,EAAZ,sBAAY;IACZ,KAAK,EAAL,eAAK;IACL,aAAa,EAAb,uBAAa;IACb,EAAE,EAAF,YAAE;IACF,MAAM,EAAN,gBAAM;IACN,IAAI,EAAJ,cAAI;IACJ,IAAI,EAAJ,cAAI;IACJ,GAAG,EAAH,aAAG;IACH,KAAK,EAAL,eAAK;IACL,IAAI,EAAJ,cAAI;IACJ,MAAM,EAAN,gBAAM;IACN,gBAAgB,EAAhB,0BAAgB;IAChB,SAAS,EAAT,mBAAS;IACT,UAAU,EAAV,oBAAU;IACV,KAAK,EAAE,gBAAM;IACb,MAAM,EAAN,gBAAM;IACN,MAAM,EAAN,gBAAM;IACN,WAAW,EAAX,qBAAW;IACX,UAAU,EAAV,oBAAU;IACV,aAAa,EAAb,uBAAa;IACb,MAAM,EAAN,gBAAM;IACN,WAAW,EAAX,qBAAW;IACX,MAAM,EAAN,gBAAM;CACT,CAAC","sourcesContent":["import AdjustableControl from './AdjustableControl';\nimport AdjustablePercentageControl from './AdjustablePercentageControl';\nimport AirCondition from './AirCondition';\nimport Blind from './Blind';\nimport ContactSensor from './ContactSensor';\nimport type Control from './Control';\nimport Ct from './Ct';\nimport Dimmer from './Dimmer';\nimport Door from './Door';\nimport Gate from './Gate';\nimport Hue from './Hue';\nimport Light from './Light';\nimport Lock from './Lock';\nimport Motion from './Motion';\nimport RgbSingle from './RgbSingle';\nimport RgbwSingle from './RgbwSingle';\nimport ReadOnlyDetector from './ReadOnlyDetector';\nimport Button from './Button';\nimport Slider from './Slider';\nimport Socket from './Socket';\nimport Temperature from './Temperature';\nimport Thermostat from './Thermostat';\nimport VacuumCleaner from './VacuumCleaner';\nimport Volume from './Volume';\nimport VolumeGroup from './VolumeGroup';\nimport Window from './Window';\nimport type { IotExternalPatternControl } from '../types';\n\nexport default {\n factory: (item: IotExternalPatternControl): Control | null => {\n // if (item.type === AdjustableControl.type) {\n // return new AdjustableControl(item);\n // }\n if (item.type === AdjustablePercentageControl.type) {\n return new AdjustablePercentageControl(item);\n }\n if (item.type === AirCondition.type) {\n return new AirCondition(item);\n }\n if (item.type === Blind.type) {\n return new Blind(item);\n }\n if (item.type === ContactSensor.type) {\n return new ContactSensor(item);\n }\n if (item.type === Ct.type) {\n return new Ct(item);\n }\n if (item.type === Dimmer.type) {\n return new Dimmer(item);\n }\n if (item.type === Door.type) {\n return new Door(item);\n }\n if (item.type === Gate.type) {\n return new Gate(item);\n }\n if (item.type === Hue.type) {\n return new Hue(item);\n }\n if (item.type === Light.type) {\n return new Light(item);\n }\n if (item.type === Lock.type) {\n return new Lock(item);\n }\n if (item.type === Motion.type) {\n return new Motion(item);\n }\n if (item.type === RgbSingle.type) {\n return new RgbSingle(item);\n }\n if (item.type === RgbwSingle.type) {\n return new RgbwSingle(item);\n }\n if (item.type === Button.type) {\n return new Button(item);\n }\n if (item.type === Slider.type) {\n return new Slider(item);\n }\n if (item.type === Socket.type) {\n return new Socket(item);\n }\n if (item.type === Temperature.type) {\n return new Temperature(item);\n }\n if (item.type === Thermostat.type) {\n return new Thermostat(item);\n }\n if (item.type === VacuumCleaner.type) {\n return new VacuumCleaner(item);\n }\n if (item.type === Volume.type) {\n return new Volume(item);\n }\n if (item.type === VolumeGroup.type) {\n return new VolumeGroup(item);\n }\n if (item.type === Window.type) {\n return new Window(item);\n }\n return null;\n },\n AdjustableControl,\n AdjustablePercentageControl,\n AirCondition,\n Blind,\n ContactSensor,\n Ct,\n Dimmer,\n Door,\n Gate,\n Hue,\n Light,\n Lock,\n Motion,\n ReadOnlyDetector,\n RgbSingle,\n RgbwSingle,\n Scene: Button,\n Slider,\n Socket,\n Temperature,\n Thermostat,\n VacuumCleaner,\n Volume,\n VolumeGroup,\n Window,\n};\n"]}
@@ -100,11 +100,11 @@ class DeviceManager {
100
100
  this.log.silly(`processing control: ${JSON.stringify(item)}`);
101
101
  const control = Controls_1.default.factory(item);
102
102
  if (control) {
103
- this.log.debug(`${item.type} added to ${friendlyName}`);
103
+ this.log.debug(`"${item.type}" added to "${friendlyName}"`);
104
104
  controls.push(control);
105
105
  }
106
106
  else {
107
- this.log.debug(`control of type ${item.type} not supported yet. Skipped.`);
107
+ this.log.debug(`control of type "${item.type}" not supported yet. Skipped.`);
108
108
  }
109
109
  });
110
110
  if (controls.length === 0) {
@@ -244,6 +244,9 @@ class DeviceManager {
244
244
  }
245
245
  catch (e) {
246
246
  this.log.error(`failed to collect devices: ${e}`);
247
+ if (e.stack) {
248
+ this.log.error(e.stack);
249
+ }
247
250
  }
248
251
  this.collecting = false;
249
252
  // if during the collection a new collection was triggered, start collecting again
@@ -347,6 +350,10 @@ class DeviceManager {
347
350
  this.log.silly(`ignoring state change event for ${id} due to state.ack == ${state?.ack}`);
348
351
  return;
349
352
  }
353
+ if (id.startsWith(`${AdapterProvider_1.default.get().namespace}.`)) {
354
+ // nop, this is just to inform Alexa app about changes
355
+ return;
356
+ }
350
357
  let notFound = true;
351
358
  for (const device of this.devices) {
352
359
  const property = device.controls
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceManager.js","sourceRoot":"","sources":["../../../src/lib/AlexaSmartHomeV3/DeviceManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,uDAAyC;AACzC,oEAA4C;AAC5C,0DAAkC;AAElC,8DAAsC;AACtC,g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GAAG,CAAC,eAAe,EAAE,CAAC;gCAC9B,MAAM,IAAI,CAAC,uBAAuB,CAC9B,MAAM,CAAC,EAAE,EACT,GAAG,EAAE;oCACD,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;oCACrC,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gCACxC,CAAC,EACD,uBAAa,CAAC,mBAAmB,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,CACpF,CAAC;4BACN,CAAC;wBACL,CAAC;6BAAM,CAAC;4BACJ,IAAI,CAAC,GAAG,CAAC,KAAK,CACV,mCAAmC,EAAE,4BAA4B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAClG,CAAC;wBACN,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED,kEAAkE;gBAClE,MAAM;YACV,CAAC;QACL,CAAC;QAED,2BAA2B;QAC3B,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,+BAA+B,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;CACJ;AA/bD,gCA+bC","sourcesContent":["import Device from './Device';\nimport * as Utils from './Helpers/Utils';\nimport Directives from './Alexa/Directives';\nimport Controls from './Controls';\nimport type Control from './Controls/Control';\nimport Logger from './Helpers/Logger';\nimport AdapterProvider from './Helpers/AdapterProvider';\nimport AlexaResponse from './Alexa/AlexaResponse';\nimport IotProxy from './Helpers/IotProxy';\nimport RateLimiter from './Helpers/RateLimiter';\nimport OverallDailyRateLimitExceeded from './Exceptions/OverallDailyRateLimitExceeded';\nimport HourlyDeviceRateLimitExceeded from './Exceptions/HourlyDeviceRateLimitExceeded';\nimport type { AlexaV3EndpointID, AlexaV3Request, IotExternalPatternControl } from './types';\nimport ChangeReport from './Alexa/Directives/ChangeReport';\nimport Discovery from './Alexa/Directives/Discovery';\nimport ReportState from './Alexa/Directives/ReportState';\nimport { randomUUID } from 'node:crypto';\n\nexport default class DeviceManager {\n private lang: ioBroker.Languages = 'en';\n private devices: Device[] = [];\n private subscribed: string[] = [];\n private log: Logger;\n private eventsPausedTill = 0; // timestamp\n\n private collecting = false;\n private recollect = false;\n\n /** Creates a Device Manager */\n constructor() {\n this.log = new Logger(this);\n }\n\n async informAboutStatesChange(): Promise<void> {\n await AdapterProvider.get().setStateAsync('smart.updates3', true, true);\n }\n\n get language(): ioBroker.Languages {\n return this.lang;\n }\n\n set language(value: ioBroker.Languages) {\n this.lang = value;\n }\n\n matchDirective(event: AlexaV3Request): ChangeReport | Discovery | ReportState | null {\n if (ChangeReport.matches(event)) {\n return new ChangeReport();\n }\n if (Discovery.matches(event)) {\n return new Discovery();\n }\n if (ReportState.matches(event)) {\n return new ReportState();\n }\n\n return null;\n }\n\n get endpoints(): Device[] {\n return this.devices;\n }\n\n endpointById(id: AlexaV3EndpointID): Device | undefined {\n return this.devices.find(device => device.id === id);\n }\n\n addDevice(device: Device): void {\n this.devices.push(device);\n }\n\n toDevice(\n detectedControls: IotExternalPatternControl[],\n friendlyName: string,\n autoDetected: boolean,\n roomName: string | undefined,\n funcName: string | undefined,\n toggle?: boolean,\n ): Device | undefined {\n const controls: Control[] = [];\n\n this.log.debug(`merging controls to a device with name ${friendlyName}`);\n\n detectedControls.forEach(item => {\n this.log.silly(`processing control: ${JSON.stringify(item)}`);\n const control = Controls.factory(item);\n if (control) {\n this.log.debug(`${item.type} added to ${friendlyName}`);\n controls.push(control);\n } else {\n this.log.debug(`control of type ${item.type} not supported yet. Skipped.`);\n }\n });\n\n if (controls.length === 0) {\n // the controls are not supported yet...\n return;\n }\n\n // create and add a new device to the collected devices\n this.addDevice(\n new Device({\n id: friendlyName,\n friendlyName,\n controls,\n autoDetected,\n roomName,\n funcName,\n toggle,\n }),\n );\n }\n\n getName(name: ioBroker.StringOrTranslated | undefined): string {\n if (!name) {\n return '';\n }\n if (typeof name === 'object') {\n return name[this.lang] || name.en || '';\n }\n return name;\n }\n\n async collectEndpoints(): Promise<void> {\n if (this.collecting) {\n this.log.debug(`collecting devices already in progress. Skipping...`);\n this.recollect = true;\n return;\n }\n this.collecting = true;\n this.log.debug(`(re)collecting devices...`);\n try {\n // const discoveryNeeded = this.devices.length > 0;\n\n this.devices = [];\n const defaultToggle = AdapterProvider.get().config.defaultToggle || false;\n\n // collect all iobroker controls in terms of iobroker type detector (https://github.com/ioBroker/ioBroker.type-detector)\n let detectedControls = await Utils.controls(AdapterProvider.get(), this.lang);\n\n this.log.debug(`type detector found ${detectedControls.length} controls`);\n\n // Normally, every control is a smart device. But due to the iobroker concept of 'rooms and functions'\n // multiple controls might be merged to a single device.\n\n // as long as not all controls mapped to a device...\n\n // detectedControls = detectedControls.filter(c => ['light', 'dimmer'].includes(c.type));\n const createdGroups: string[] = [];\n\n while (detectedControls.length) {\n // take the next control\n const control = detectedControls[0];\n let processedControls: IotExternalPatternControl[] = [];\n\n if (control.room?.common?.name) {\n if (control.functionality?.common?.name) {\n // controls in the same room with the same functionality\n processedControls = detectedControls.filter(\n item =>\n control.room &&\n item.room?.id === control.room.id &&\n control.functionality &&\n item.functionality?.id === control.functionality.id,\n );\n this.toDevice(\n processedControls,\n Utils.friendlyNameByRoomAndFunctionName(control, this.lang),\n true,\n this.getName(control.room?.common?.name),\n this.getName(control.functionality?.common?.name),\n processedControls[0].object?.toggle ?? defaultToggle,\n );\n } else {\n this.log.debug(\n `Control of type [${control.type}] assigned to room [${this.getName(control.room.common.name)}] has no function. Skipped.`,\n );\n }\n } else if (control.groupNames) {\n // no room, but smart name (not only one)\n control.groupNames.forEach(groupName => {\n if (!createdGroups.includes(groupName)) {\n createdGroups.push(groupName);\n processedControls = detectedControls.filter(item => item.groupNames?.includes(groupName));\n this.toDevice(\n processedControls,\n this.getName(groupName),\n false,\n undefined,\n undefined,\n processedControls[0].object?.toggle ?? defaultToggle,\n );\n }\n });\n } else {\n // neither room nor smart name\n this.log.debug(`Control of type [${control.type}] has neither room no smart name. Skipped.`);\n }\n\n if (processedControls.length === 0) {\n processedControls = [control];\n }\n\n // remove processed controls\n const objectIds = processedControls.map(item => item.object?.id);\n detectedControls = detectedControls.filter(item => item.object && !objectIds.includes(item.object.id));\n }\n\n // done\n this.log.debug(`finished collecting devices. there is/are ${this.devices.length} device(s) in total`);\n for (const device of this.devices) {\n this.log.debug(`${device.toString()}`);\n }\n\n // a new discovery process is needed in case we had already devices and device collection was\n // triggered again by, e.g., a change in room/function enums\n // if (discoveryNeeded) {\n // this.log.info(`Please delete all managed by ioBroker devices in your Alexa app and then start discovery`);\n // }\n\n // collect all relevant states to subscribe to updates\n const stateIds = new Set(\n this.devices\n .flatMap(d => d.controls)\n .flatMap(item => item.supported)\n .flatMap(item => item.properties)\n .map(item => item.getId)\n .filter(id => id),\n );\n this.log.debug(`registering for updates of total ${stateIds.size} states`);\n const promises = [];\n const newSubscribed = Array.from(stateIds);\n // subscribe to updates\n for (const id of newSubscribed) {\n this.log.silly(`subscribing to updates of ${id}`);\n if (!this.subscribed.includes(id)) {\n this.subscribed.push(id);\n promises.push(AdapterProvider.subscribe(id));\n }\n }\n\n this.subscribed.sort();\n\n // wait till all promises are settled\n const results = await Promise.allSettled(promises);\n\n // unsubscribe from unused states\n for (let i = this.subscribed.length - 1; i >= 0; i--) {\n const id = this.subscribed[i];\n if (!newSubscribed.includes(id)) {\n this.log.silly(`unsubscribing from updates of ${id}`);\n this.subscribed.splice(i, 1);\n await AdapterProvider.unsubscribe(id);\n }\n }\n\n const failedReasons = results.filter(item => item.status !== 'fulfilled').flatMap(item => item.reason);\n if (failedReasons.length) {\n this.log.debug(`failed to subscribe for updates of ${failedReasons.length} states`);\n try {\n for (const reason of failedReasons) {\n this.log.silly(\n `failed subscribing: ${typeof reason === 'string' ? reason : JSON.stringify(reason)}`,\n );\n }\n } catch {\n // nop\n }\n }\n } catch (e) {\n this.log.error(`failed to collect devices: ${e}`);\n }\n\n this.collecting = false;\n\n // if during the collection a new collection was triggered, start collecting again\n if (this.recollect) {\n this.recollect = false;\n setTimeout(() => this.collectEndpoints(), 1000);\n }\n }\n\n async destroy(): Promise<void> {\n const promises = [];\n for (const id of this.subscribed) {\n this.log.silly(`unsubscribing from updates of ${id}`);\n promises.push(AdapterProvider.subscribe(id));\n }\n await Promise.allSettled(promises);\n\n this.subscribed = [];\n }\n\n publishStateChange(stateChange: AlexaResponse): void {\n if (this.eventsPausedTill < Date.now()) {\n this.log.silly(`publishing ${JSON.stringify(stateChange)}`);\n IotProxy.publishStateChange(stateChange);\n }\n }\n\n pauseEvents(): void {\n this.eventsPausedTill = Date.now() + 30 * 60 * 1000; // 30 minutes\n }\n\n async executeWithinRateLimits(\n endpointId: AlexaV3EndpointID,\n awaitable: () => Promise<AlexaResponse>,\n errorResponse: AlexaResponse,\n ): Promise<AlexaResponse> {\n try {\n await RateLimiter.incrementAndGet(endpointId);\n return await awaitable();\n } catch (error) {\n if (error instanceof OverallDailyRateLimitExceeded || error instanceof HourlyDeviceRateLimitExceeded) {\n this.log.warn(error.message);\n } else {\n this.log.error(error.message);\n }\n\n return errorResponse;\n }\n }\n\n async handleAlexaEvent(event: AlexaV3Request): Promise<AlexaResponse> {\n this.log.debug(`incoming Alexa event`);\n this.log.silly(`${JSON.stringify(event)}`);\n if (!event?.directive?.header) {\n throw new Error('Alexa event header is missing');\n }\n\n let response: AlexaResponse;\n const directive = this.matchDirective(event);\n if (directive) {\n response = await directive.handle(event, this);\n } else {\n const endpointId = event?.directive?.endpoint?.endpointId;\n const device = endpointId ? this.endpointById(endpointId) : undefined;\n\n if (device) {\n if (device.supports(event)) {\n response = await this.executeWithinRateLimits(\n endpointId!,\n async () => {\n response = await device.handle(event);\n if (!AlexaResponse.isErrorResponse(response)) {\n // report state change via voice interaction\n const propertyName = response.context?.properties[0].name;\n const responseEvent = ChangeReport.get(\n device.id,\n propertyName || '',\n false,\n event.directive.header.messageId,\n );\n const directive = this.matchDirective(responseEvent);\n if (directive) {\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n const stateChange = await directive.handle(responseEvent, this);\n // get device state (not just one control)\n const deviceState = await device.reportState();\n if (JSON.stringify(device.lastReportedState) !== JSON.stringify(deviceState)) {\n device.lastReportedState = deviceState;\n // fire state change report to Alexa\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n if (process.env.TESTS_EXECUTION) {\n this.publishStateChange(stateChange);\n }\n await this.informAboutStatesChange();\n } else {\n this.log.debug(\n `ignoring state change event for ${endpointId} due to the same_ value [${JSON.stringify(deviceState)}]`,\n );\n }\n }\n }\n return response;\n },\n AlexaResponse.throttlingException(event.directive.header.messageId).get(),\n );\n } else {\n response = AlexaResponse.directiveNotSupportedByDevice(\n device.friendlyName,\n event.directive.header.namespace,\n event.directive.header.messageId,\n event.directive.header.payloadVersion,\n ).get();\n }\n } else {\n response = AlexaResponse.endpointUnreachable(event.directive.header.messageId).get();\n }\n }\n\n this.log.silly(`response: ${JSON.stringify(response)}`);\n return response;\n }\n\n async handleStateUpdate(id: string, state: ioBroker.State | null | undefined): Promise<void> {\n // ignore updates not confirmed by a corresponding device\n if (!state?.ack) {\n this.log.silly(`ignoring state change event for ${id} due to state.ack == ${state?.ack}`);\n return;\n }\n\n let notFound = true;\n\n for (const device of this.devices) {\n const property = device.controls\n .flatMap(item => item.supported)\n .flatMap(item => item.properties)\n .find(item => item.getId === id);\n\n if (property) {\n notFound = false;\n if (property.currentValue === state.val) {\n this.log.debug(`ignoring state change event for ${id} due to the same value [${state.val}]`);\n } else {\n property.currentValue = state.val;\n\n const responseEvent = Directives.ChangeReport.get(\n device.id,\n property.propertyName,\n true,\n randomUUID(),\n );\n const directive = this.matchDirective(responseEvent);\n if (directive) {\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n const stateChange = await directive.handle(responseEvent, this);\n\n // get device state (not just one control)\n const deviceState = await device.reportState();\n\n if (JSON.stringify(device.lastReportedState) !== JSON.stringify(deviceState)) {\n device.lastReportedState = deviceState;\n await this.informAboutStatesChange();\n // fire state change report to Alexa\n\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n if (process.env.TESTS_EXECUTION) {\n await this.executeWithinRateLimits(\n device.id,\n () => {\n this.publishStateChange(stateChange);\n return Promise.resolve(stateChange);\n },\n AlexaResponse.throttlingException(responseEvent.directive.header.messageId).get(),\n );\n }\n } else {\n this.log.debug(\n `ignoring state change event for ${id} due to the same_ value [${JSON.stringify(deviceState)}]`,\n );\n }\n }\n }\n\n // should be the only device having the id => stop processing here\n break;\n }\n }\n\n // this should never happen\n if (notFound) {\n this.log.debug(`state id ${id} doesn't belong to any device`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"DeviceManager.js","sourceRoot":"","sources":["../../../src/lib/AlexaSmartHomeV3/DeviceManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,uDAAyC;AACzC,oEAA4C;AAC5C,0DAAkC;AAElC,8DAAsC;AACtC,gFAAwD;AACxD,0EAAkD;AAClD,kEAA0C;AAC1C,wEAAgD;AAChD,+GAAuF;AACvF,+GAAuF;AAEvF,mFAA2D;AAC3D,6EAAqD;AACrD,iFAAyD;AACzD,6CAAyC;AAEzC,MAAqB,aAAa;IACtB,IAAI,GAAuB,IAAI,CAAC;IAChC,OAAO,GAAa,EAAE,CAAC;IACvB,UAAU,GAAa,EAAE,CAAC;IAC1B,GAAG,CAAS;IACZ,gBAAgB,GAAG,CAAC,CAAC,CAAC,YAAY;IAElC,UAAU,GAAG,KAAK,CAAC;IACnB,SAAS,GAAG,KAAK,CAAC;IAE1B,+BAA+B;IAC/B;QACI,IAAI,CAAC,GAAG,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,uBAAuB;QACzB,MAAM,yBAAe,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5E,CAAC;IAED,IAA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C;6BAAM,CAAC;4BACJ,IAAI,CAAC,GAAG,CAAC,KAAK,CACV,mCAAmC,EAAE,4BAA4B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAClG,CAAC;wBACN,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED,kEAAkE;gBAClE,MAAM;YACV,CAAC;QACL,CAAC;QAED,2BAA2B;QAC3B,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,+BAA+B,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;CACJ;AAtcD,gCAscC","sourcesContent":["import Device from './Device';\nimport * as Utils from './Helpers/Utils';\nimport Directives from './Alexa/Directives';\nimport Controls from './Controls';\nimport type Control from './Controls/Control';\nimport Logger from './Helpers/Logger';\nimport AdapterProvider from './Helpers/AdapterProvider';\nimport AlexaResponse from './Alexa/AlexaResponse';\nimport IotProxy from './Helpers/IotProxy';\nimport RateLimiter from './Helpers/RateLimiter';\nimport OverallDailyRateLimitExceeded from './Exceptions/OverallDailyRateLimitExceeded';\nimport HourlyDeviceRateLimitExceeded from './Exceptions/HourlyDeviceRateLimitExceeded';\nimport type { AlexaV3EndpointID, AlexaV3Request, IotExternalPatternControl } from './types';\nimport ChangeReport from './Alexa/Directives/ChangeReport';\nimport Discovery from './Alexa/Directives/Discovery';\nimport ReportState from './Alexa/Directives/ReportState';\nimport { randomUUID } from 'node:crypto';\n\nexport default class DeviceManager {\n private lang: ioBroker.Languages = 'en';\n private devices: Device[] = [];\n private subscribed: string[] = [];\n private log: Logger;\n private eventsPausedTill = 0; // timestamp\n\n private collecting = false;\n private recollect = false;\n\n /** Creates a Device Manager */\n constructor() {\n this.log = new Logger(this);\n }\n\n async informAboutStatesChange(): Promise<void> {\n await AdapterProvider.get().setStateAsync('smart.updates3', true, true);\n }\n\n get language(): ioBroker.Languages {\n return this.lang;\n }\n\n set language(value: ioBroker.Languages) {\n this.lang = value;\n }\n\n matchDirective(event: AlexaV3Request): ChangeReport | Discovery | ReportState | null {\n if (ChangeReport.matches(event)) {\n return new ChangeReport();\n }\n if (Discovery.matches(event)) {\n return new Discovery();\n }\n if (ReportState.matches(event)) {\n return new ReportState();\n }\n\n return null;\n }\n\n get endpoints(): Device[] {\n return this.devices;\n }\n\n endpointById(id: AlexaV3EndpointID): Device | undefined {\n return this.devices.find(device => device.id === id);\n }\n\n addDevice(device: Device): void {\n this.devices.push(device);\n }\n\n toDevice(\n detectedControls: IotExternalPatternControl[],\n friendlyName: string,\n autoDetected: boolean,\n roomName: string | undefined,\n funcName: string | undefined,\n toggle?: boolean,\n ): Device | undefined {\n const controls: Control[] = [];\n\n this.log.debug(`merging controls to a device with name ${friendlyName}`);\n\n detectedControls.forEach(item => {\n this.log.silly(`processing control: ${JSON.stringify(item)}`);\n const control = Controls.factory(item);\n if (control) {\n this.log.debug(`\"${item.type}\" added to \"${friendlyName}\"`);\n controls.push(control);\n } else {\n this.log.debug(`control of type \"${item.type}\" not supported yet. Skipped.`);\n }\n });\n\n if (controls.length === 0) {\n // the controls are not supported yet...\n return;\n }\n\n // create and add a new device to the collected devices\n this.addDevice(\n new Device({\n id: friendlyName,\n friendlyName,\n controls,\n autoDetected,\n roomName,\n funcName,\n toggle,\n }),\n );\n }\n\n getName(name: ioBroker.StringOrTranslated | undefined): string {\n if (!name) {\n return '';\n }\n if (typeof name === 'object') {\n return name[this.lang] || name.en || '';\n }\n return name;\n }\n\n async collectEndpoints(): Promise<void> {\n if (this.collecting) {\n this.log.debug(`collecting devices already in progress. Skipping...`);\n this.recollect = true;\n return;\n }\n this.collecting = true;\n this.log.debug(`(re)collecting devices...`);\n try {\n // const discoveryNeeded = this.devices.length > 0;\n\n this.devices = [];\n const defaultToggle = AdapterProvider.get().config.defaultToggle || false;\n\n // collect all iobroker controls in terms of iobroker type detector (https://github.com/ioBroker/ioBroker.type-detector)\n let detectedControls = await Utils.controls(AdapterProvider.get(), this.lang);\n\n this.log.debug(`type detector found ${detectedControls.length} controls`);\n\n // Normally, every control is a smart device. But due to the iobroker concept of 'rooms and functions'\n // multiple controls might be merged to a single device.\n\n // as long as not all controls mapped to a device...\n\n // detectedControls = detectedControls.filter(c => ['light', 'dimmer'].includes(c.type));\n const createdGroups: string[] = [];\n\n while (detectedControls.length) {\n // take the next control\n const control = detectedControls[0];\n let processedControls: IotExternalPatternControl[] = [];\n\n if (control.room?.common?.name) {\n if (control.functionality?.common?.name) {\n // controls in the same room with the same functionality\n processedControls = detectedControls.filter(\n item =>\n control.room &&\n item.room?.id === control.room.id &&\n control.functionality &&\n item.functionality?.id === control.functionality.id,\n );\n this.toDevice(\n processedControls,\n Utils.friendlyNameByRoomAndFunctionName(control, this.lang),\n true,\n this.getName(control.room?.common?.name),\n this.getName(control.functionality?.common?.name),\n processedControls[0].object?.toggle ?? defaultToggle,\n );\n } else {\n this.log.debug(\n `Control of type [${control.type}] assigned to room [${this.getName(control.room.common.name)}] has no function. Skipped.`,\n );\n }\n } else if (control.groupNames) {\n // no room, but smart name (not only one)\n control.groupNames.forEach(groupName => {\n if (!createdGroups.includes(groupName)) {\n createdGroups.push(groupName);\n processedControls = detectedControls.filter(item => item.groupNames?.includes(groupName));\n this.toDevice(\n processedControls,\n this.getName(groupName),\n false,\n undefined,\n undefined,\n processedControls[0].object?.toggle ?? defaultToggle,\n );\n }\n });\n } else {\n // neither room nor smart name\n this.log.debug(`Control of type [${control.type}] has neither room no smart name. Skipped.`);\n }\n\n if (processedControls.length === 0) {\n processedControls = [control];\n }\n\n // remove processed controls\n const objectIds = processedControls.map(item => item.object?.id);\n detectedControls = detectedControls.filter(item => item.object && !objectIds.includes(item.object.id));\n }\n\n // done\n this.log.debug(`finished collecting devices. there is/are ${this.devices.length} device(s) in total`);\n for (const device of this.devices) {\n this.log.debug(`${device.toString()}`);\n }\n\n // a new discovery process is needed in case we had already devices and device collection was\n // triggered again by, e.g., a change in room/function enums\n // if (discoveryNeeded) {\n // this.log.info(`Please delete all managed by ioBroker devices in your Alexa app and then start discovery`);\n // }\n\n // collect all relevant states to subscribe to updates\n const stateIds = new Set(\n this.devices\n .flatMap(d => d.controls)\n .flatMap(item => item.supported)\n .flatMap(item => item.properties)\n .map(item => item.getId)\n .filter(id => id),\n );\n this.log.debug(`registering for updates of total ${stateIds.size} states`);\n const promises = [];\n const newSubscribed = Array.from(stateIds);\n // subscribe to updates\n for (const id of newSubscribed) {\n this.log.silly(`subscribing to updates of ${id}`);\n if (!this.subscribed.includes(id)) {\n this.subscribed.push(id);\n promises.push(AdapterProvider.subscribe(id));\n }\n }\n\n this.subscribed.sort();\n\n // wait till all promises are settled\n const results = await Promise.allSettled(promises);\n\n // unsubscribe from unused states\n for (let i = this.subscribed.length - 1; i >= 0; i--) {\n const id = this.subscribed[i];\n if (!newSubscribed.includes(id)) {\n this.log.silly(`unsubscribing from updates of ${id}`);\n this.subscribed.splice(i, 1);\n await AdapterProvider.unsubscribe(id);\n }\n }\n\n const failedReasons = results.filter(item => item.status !== 'fulfilled').flatMap(item => item.reason);\n if (failedReasons.length) {\n this.log.debug(`failed to subscribe for updates of ${failedReasons.length} states`);\n try {\n for (const reason of failedReasons) {\n this.log.silly(\n `failed subscribing: ${typeof reason === 'string' ? reason : JSON.stringify(reason)}`,\n );\n }\n } catch {\n // nop\n }\n }\n } catch (e) {\n this.log.error(`failed to collect devices: ${e}`);\n if (e.stack) {\n this.log.error(e.stack);\n }\n }\n\n this.collecting = false;\n\n // if during the collection a new collection was triggered, start collecting again\n if (this.recollect) {\n this.recollect = false;\n setTimeout(() => this.collectEndpoints(), 1000);\n }\n }\n\n async destroy(): Promise<void> {\n const promises = [];\n for (const id of this.subscribed) {\n this.log.silly(`unsubscribing from updates of ${id}`);\n promises.push(AdapterProvider.subscribe(id));\n }\n await Promise.allSettled(promises);\n\n this.subscribed = [];\n }\n\n publishStateChange(stateChange: AlexaResponse): void {\n if (this.eventsPausedTill < Date.now()) {\n this.log.silly(`publishing ${JSON.stringify(stateChange)}`);\n IotProxy.publishStateChange(stateChange);\n }\n }\n\n pauseEvents(): void {\n this.eventsPausedTill = Date.now() + 30 * 60 * 1000; // 30 minutes\n }\n\n async executeWithinRateLimits(\n endpointId: AlexaV3EndpointID,\n awaitable: () => Promise<AlexaResponse>,\n errorResponse: AlexaResponse,\n ): Promise<AlexaResponse> {\n try {\n await RateLimiter.incrementAndGet(endpointId);\n return await awaitable();\n } catch (error) {\n if (error instanceof OverallDailyRateLimitExceeded || error instanceof HourlyDeviceRateLimitExceeded) {\n this.log.warn(error.message);\n } else {\n this.log.error(error.message);\n }\n\n return errorResponse;\n }\n }\n\n async handleAlexaEvent(event: AlexaV3Request): Promise<AlexaResponse> {\n this.log.debug(`incoming Alexa event`);\n this.log.silly(`${JSON.stringify(event)}`);\n if (!event?.directive?.header) {\n throw new Error('Alexa event header is missing');\n }\n\n let response: AlexaResponse;\n const directive = this.matchDirective(event);\n if (directive) {\n response = await directive.handle(event, this);\n } else {\n const endpointId = event?.directive?.endpoint?.endpointId;\n const device = endpointId ? this.endpointById(endpointId) : undefined;\n\n if (device) {\n if (device.supports(event)) {\n response = await this.executeWithinRateLimits(\n endpointId!,\n async () => {\n response = await device.handle(event);\n if (!AlexaResponse.isErrorResponse(response)) {\n // report state change via voice interaction\n const propertyName = response.context?.properties[0].name;\n const responseEvent = ChangeReport.get(\n device.id,\n propertyName || '',\n false,\n event.directive.header.messageId,\n );\n const directive = this.matchDirective(responseEvent);\n if (directive) {\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n const stateChange = await directive.handle(responseEvent, this);\n // get device state (not just one control)\n const deviceState = await device.reportState();\n if (JSON.stringify(device.lastReportedState) !== JSON.stringify(deviceState)) {\n device.lastReportedState = deviceState;\n // fire state change report to Alexa\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n if (process.env.TESTS_EXECUTION) {\n this.publishStateChange(stateChange);\n }\n await this.informAboutStatesChange();\n } else {\n this.log.debug(\n `ignoring state change event for ${endpointId} due to the same_ value [${JSON.stringify(deviceState)}]`,\n );\n }\n }\n }\n return response;\n },\n AlexaResponse.throttlingException(event.directive.header.messageId).get(),\n );\n } else {\n response = AlexaResponse.directiveNotSupportedByDevice(\n device.friendlyName,\n event.directive.header.namespace,\n event.directive.header.messageId,\n event.directive.header.payloadVersion,\n ).get();\n }\n } else {\n response = AlexaResponse.endpointUnreachable(event.directive.header.messageId).get();\n }\n }\n\n this.log.silly(`response: ${JSON.stringify(response)}`);\n return response;\n }\n\n async handleStateUpdate(id: string, state: ioBroker.State | null | undefined): Promise<void> {\n // ignore updates not confirmed by a corresponding device\n if (!state?.ack) {\n this.log.silly(`ignoring state change event for ${id} due to state.ack == ${state?.ack}`);\n return;\n }\n if (id.startsWith(`${AdapterProvider.get().namespace}.`)) {\n // nop, this is just to inform Alexa app about changes\n return;\n }\n\n let notFound = true;\n\n for (const device of this.devices) {\n const property = device.controls\n .flatMap(item => item.supported)\n .flatMap(item => item.properties)\n .find(item => item.getId === id);\n\n if (property) {\n notFound = false;\n if (property.currentValue === state.val) {\n this.log.debug(`ignoring state change event for ${id} due to the same value [${state.val}]`);\n } else {\n property.currentValue = state.val;\n\n const responseEvent = Directives.ChangeReport.get(\n device.id,\n property.propertyName,\n true,\n randomUUID(),\n );\n const directive = this.matchDirective(responseEvent);\n if (directive) {\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n const stateChange = await directive.handle(responseEvent, this);\n\n // get device state (not just one control)\n const deviceState = await device.reportState();\n\n if (JSON.stringify(device.lastReportedState) !== JSON.stringify(deviceState)) {\n device.lastReportedState = deviceState;\n await this.informAboutStatesChange();\n // fire state change report to Alexa\n\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n if (process.env.TESTS_EXECUTION) {\n await this.executeWithinRateLimits(\n device.id,\n () => {\n this.publishStateChange(stateChange);\n return Promise.resolve(stateChange);\n },\n AlexaResponse.throttlingException(responseEvent.directive.header.messageId).get(),\n );\n }\n } else {\n this.log.debug(\n `ignoring state change event for ${id} due to the same_ value [${JSON.stringify(deviceState)}]`,\n );\n }\n }\n }\n\n // should be the only device having the id => stop processing here\n break;\n }\n }\n\n // this should never happen\n if (notFound) {\n this.log.debug(`state id ${id} doesn't belong to any device`);\n }\n }\n}\n"]}