iobroker.iot 4.2.7 → 4.2.9
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 +5 -3
- package/admin/assets/{index-PqQTFd0N.js → index-CzY6OS2n.js} +38 -38
- package/admin/index_m.html +1 -1
- package/build/lib/AlexaSmartHomeV3/Controls/Rgb.js +17 -17
- package/build/lib/AlexaSmartHomeV3/Controls/Rgb.js.map +1 -1
- package/build/lib/AlexaSmartHomeV3/DeviceManager.js +47 -2
- package/build/lib/AlexaSmartHomeV3/DeviceManager.js.map +1 -1
- package/build/lib/AlexaSmartHomeV3/Helpers/Utils.js +1 -1
- package/build/lib/AlexaSmartHomeV3/Helpers/Utils.js.map +1 -1
- package/build/main.js +1 -1
- package/build/main.js.map +1 -1
- package/io-package.json +15 -15
- package/package.json +1 -1
package/admin/index_m.html
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
/>
|
|
22
22
|
<script type="text/javascript" onerror="setTimeout(function(){window.location.reload()}, 5000)" src="./lib/js/socket.io.js"></script>
|
|
23
23
|
<title>IoT Settings</title>
|
|
24
|
-
<script type="module" crossorigin src="./assets/index-
|
|
24
|
+
<script type="module" crossorigin src="./assets/index-CzY6OS2n.js"></script>
|
|
25
25
|
<link rel="stylesheet" crossorigin href="./assets/index-Bd3GtHgn.css">
|
|
26
26
|
</head>
|
|
27
27
|
<body>
|
|
@@ -135,39 +135,39 @@ class Rgb extends AdjustableControl_1.default {
|
|
|
135
135
|
const red = parseInt(hex.substring(0, 2), 16);
|
|
136
136
|
const green = parseInt(hex.substring(2, 4), 16);
|
|
137
137
|
const blue = parseInt(hex.substring(4, 6), 16);
|
|
138
|
-
let white;
|
|
139
|
-
if (hex.length === 8) {
|
|
140
|
-
|
|
141
|
-
}
|
|
138
|
+
// let white: number | undefined;
|
|
139
|
+
// if (hex.length === 8) {
|
|
140
|
+
// white = parseInt(hex.substring(6, 8), 16);
|
|
141
|
+
// }
|
|
142
142
|
// Convert from 0-255 to 0-100
|
|
143
143
|
const red100 = (red / 255) * 100;
|
|
144
144
|
const green100 = (green / 255) * 100;
|
|
145
145
|
const blue100 = (blue / 255) * 100;
|
|
146
|
-
let white100;
|
|
147
|
-
if (white !== undefined) {
|
|
148
|
-
|
|
149
|
-
}
|
|
146
|
+
// let white100: number | undefined;
|
|
147
|
+
// if (white !== undefined) {
|
|
148
|
+
// white100 = (white / 255) * 100;
|
|
149
|
+
// }
|
|
150
150
|
// Convert from 0-100 to min-max of the state
|
|
151
151
|
const minMaxRed = (0, Utils_1.configuredRangeOrDefault)(this.states[map.red]);
|
|
152
152
|
const minMaxGreen = (0, Utils_1.configuredRangeOrDefault)(this.states[map.green]);
|
|
153
153
|
const minMaxBlue = (0, Utils_1.configuredRangeOrDefault)(this.states[map.blue]);
|
|
154
|
-
let minMaxWhite;
|
|
155
|
-
if (this.states[map.white]) {
|
|
156
|
-
|
|
157
|
-
}
|
|
154
|
+
// let minMaxWhite: { min: number | boolean; max: number | boolean } | undefined;
|
|
155
|
+
// if (this.states[map.white]) {
|
|
156
|
+
// minMaxWhite = configuredRangeOrDefault(this.states[map.white]!);
|
|
157
|
+
// }
|
|
158
158
|
const redValue = (0, Utils_1.denormalize_0_100)(red100, minMaxRed.min, minMaxRed.max);
|
|
159
159
|
const greenValue = (0, Utils_1.denormalize_0_100)(green100, minMaxGreen.min, minMaxGreen.max);
|
|
160
160
|
const blueValue = (0, Utils_1.denormalize_0_100)(blue100, minMaxBlue.min, minMaxBlue.max);
|
|
161
|
-
let whiteValue;
|
|
162
|
-
if (this.states[map.white]) {
|
|
163
|
-
|
|
164
|
-
}
|
|
161
|
+
// let whiteValue: number | undefined;
|
|
162
|
+
// if (this.states[map.white]) {
|
|
163
|
+
// whiteValue = denormalize_0_100(white100!, minMaxWhite!.min as number, minMaxWhite!.max as number);
|
|
164
|
+
// }
|
|
165
165
|
// set states
|
|
166
166
|
await Promise.all([
|
|
167
167
|
AdapterProvider_1.default.setState(this.states[map.red].id, redValue ?? 0),
|
|
168
168
|
AdapterProvider_1.default.setState(this.states[map.green].id, greenValue ?? 0),
|
|
169
169
|
AdapterProvider_1.default.setState(this.states[map.blue].id, blueValue ?? 0),
|
|
170
|
-
this.states[map.white] ?
|
|
170
|
+
// this.states[map.white] ? AdapterProvider.setState(this.states[map.white]!.id, whiteValue ?? 0) : null,
|
|
171
171
|
]);
|
|
172
172
|
property.currentValue = value;
|
|
173
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rgb.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Rgb.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AACjD,4CAAiH;AACjH,iFAAyD;AAEzD,4EAAoD;AAEpD,gFAAwD;AACxD,4GAAoF;AAEpF,gFAAwD;AAExD,sEAA8C;AAC9C,0FAAkE;AAElE,+DAA+D;AAC/D,EAAE;AACF,qFAAqF;AACrF,EAAE;AACF,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAElJ,MAAqB,GAAI,SAAQ,2BAAiB;IAC7B,qBAAqB,CAAmC;IACxD,WAAW,CAAyB;IACpC,2BAA2B,CAAyC;IACpE,SAAS,GAAW,CAAC,CAAC;IAEvC,YAAY,eAA0C;QAClD,KAAK,CAAC,eAAe,CAAC,CAAC;QAEvB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAE3B,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,sBAAY,CAAC,eAAe,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;QAEpF,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,2B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IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;gBAC7C,CAAC;gBACD,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;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;AA3UD,sBA2UC","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, ControlStateInitObject } 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 PowerState from '../Alexa/Properties/PowerState';\nimport type { AlexaV3Category, AlexaV3DirectiveValue, AlexaV3Request, IotExternalPatternControl } from '../types';\nimport Color from '../Alexa/Properties/Color';\nimport EndpointHealth from '../Alexa/Capabilities/EndpointHealth';\n\n// ### RGB(W) Light with different states for every color [rgb]\n//\n// R,G,B(,W) Light with different states for every color. The value is from 0 to 255.\n//\n// | R | Name | Role | Unit | Type | Wr | Ind | Multi | Regex |\n// |---|-----------------|-------------------------------|------|---------|----|-----|-------|---------------------------------------------------|\n// | * | RED | level.color.red | | number | W | | | `/^level\\.color\\.red$/` |\n// | * | GREEN | level.color.green | | number | W | | | `/^level\\.color\\.green$/` |\n// | * | BLUE | level.color.blue | | number | W | | | `/^level\\.color\\.blue$/` |\n// | | WHITE | level.color.white | | number | W | | | `/^level\\.color\\.white$/` |\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)?$|^state$/` |\n// | | ON_ACTUAL | sensor.light | | boolean | - | | | `/^(state|switch|sensor)\\.light|switch$/` |\n\nexport default class Rgb extends AdjustableControl {\n private readonly _brightnessCapability: BrightnessController | undefined;\n private readonly _brightness: Brightness | undefined;\n private readonly _colorTemperatureCapability: ColorTemperatureController | undefined;\n private readonly _offValue: number = 0;\n\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n\n const map = this.statesMap;\n\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 if (!this.states[map.on]) {\n this._offValue = denormalize_0_100(\n AdapterProvider.deviceOffLevel(),\n this._brightness!.valuesRangeMin as number,\n (this._brightness!.valuesRangeMin as number) || 100,\n ) as number;\n }\n this._supported.push(new Capabilities.PowerController(this.composeInitObjectPowerState()));\n }\n\n const health = this.connectivityInitObject();\n if (health) {\n this._supported.push(new EndpointHealth(health));\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.propertyName === Color.propertyName) {\n // read every time all colors\n const red = await AdapterProvider.getState(this.states[map.red]!.id);\n const green = await AdapterProvider.getState(this.states[map.green]!.id);\n const blue = await AdapterProvider.getState(this.states[map.blue]!.id);\n let white: ioBroker.StateValue | undefined;\n if (this.states[map.white]) {\n white = await AdapterProvider.getState(this.states[map.white]!.id);\n }\n const minMaxRed = configuredRangeOrDefault(this.states[map.red]!);\n const minMaxGreen = configuredRangeOrDefault(this.states[map.green]!);\n const minMaxBlue = configuredRangeOrDefault(this.states[map.blue]!);\n let minMaxWhite: { min: number | boolean; max: number | boolean } | undefined;\n if (this.states[map.white]) {\n minMaxWhite = configuredRangeOrDefault(this.states[map.white]!);\n }\n // normalize values to 0-255\n const redNorm = normalize_0_100(red as number, minMaxRed.min as number, minMaxRed.max as number, true);\n const greenNorm = normalize_0_100(\n green as number,\n minMaxGreen.min as number,\n minMaxGreen.max as number,\n true,\n );\n const blueNorm = normalize_0_100(blue as number, minMaxBlue.min as number, minMaxBlue.max as number, true);\n let whiteNorm: number | undefined;\n if (this.states[map.white]) {\n whiteNorm = normalize_0_100(\n white as number,\n minMaxWhite!.min as number,\n minMaxWhite!.max as number,\n true,\n );\n }\n const red255 = Math.round((redNorm as number) * 2.55);\n const green255 = Math.round((greenNorm as number) * 2.55);\n const blue255 = Math.round((blueNorm as number) * 2.55);\n let white255: number | undefined;\n if (this.states[map.white]) {\n white255 = Math.round((whiteNorm as number) * 2.55);\n }\n\n // Convert to HEX\n let hex = `#${red255.toString(16).padStart(2, '0')}${green255.toString(16).padStart(2, '0')}${blue255.toString(16).padStart(2, '0')}`;\n\n if (this.states[map.white]) {\n hex += white255!.toString(16).padStart(2, '0');\n }\n\n // store current value\n property.currentValue = hex.toLowerCase();\n return property.currentValue;\n }\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 as number) > this._offValue;\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[this.statesMap.on]) {\n await AdapterProvider.setState(property.setId, value ?? false);\n property.currentValue = value;\n } else {\n // this will be processed in Brightness property\n }\n } else if (property.propertyName === Color.propertyName) {\n // Split value into RGB(W)\n const hex = (value as string).replace('#', '');\n const red = parseInt(hex.substring(0, 2), 16);\n const green = parseInt(hex.substring(2, 4), 16);\n const blue = parseInt(hex.substring(4, 6), 16);\n let white: number | undefined;\n if (hex.length === 8) {\n white = parseInt(hex.substring(6, 8), 16);\n }\n // Convert from 0-255 to 0-100\n const red100 = (red / 255) * 100;\n const green100 = (green / 255) * 100;\n const blue100 = (blue / 255) * 100;\n let white100: number | undefined;\n if (white !== undefined) {\n white100 = (white / 255) * 100;\n }\n // Convert from 0-100 to min-max of the state\n const minMaxRed = configuredRangeOrDefault(this.states[map.red]!);\n const minMaxGreen = configuredRangeOrDefault(this.states[map.green]!);\n const minMaxBlue = configuredRangeOrDefault(this.states[map.blue]!);\n let minMaxWhite: { min: number | boolean; max: number | boolean } | undefined;\n if (this.states[map.white]) {\n minMaxWhite = configuredRangeOrDefault(this.states[map.white]!);\n }\n const redValue = denormalize_0_100(red100, minMaxRed.min as number, minMaxRed.max as number);\n const greenValue = denormalize_0_100(green100, minMaxGreen.min as number, minMaxGreen.max as number);\n const blueValue = denormalize_0_100(blue100, minMaxBlue.min as number, minMaxBlue.max as number);\n let whiteValue: number | undefined;\n if (this.states[map.white]) {\n whiteValue = denormalize_0_100(white100!, minMaxWhite!.min as number, minMaxWhite!.max as number);\n }\n // set states\n await Promise.all([\n AdapterProvider.setState(this.states[map.red]!.id, redValue ?? 0),\n AdapterProvider.setState(this.states[map.green]!.id, greenValue ?? 0),\n AdapterProvider.setState(this.states[map.blue]!.id, blueValue ?? 0),\n this.states[map.white] ? AdapterProvider.setState(this.states[map.white]!.id, whiteValue ?? 0) : null,\n ]);\n\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(): ControlStateInitObject {\n const map = this.statesMap;\n\n // Set default min max to 0 255 for colors\n ['red', 'green', 'blue', 'white'].forEach(color => {\n if (this.states[map[color]] && this.states[map[color]]!.common?.min === undefined) {\n this.states[map[color]]!.common ||= {};\n this.states[map[color]]!.common.min = 0;\n }\n if (this.states[map[color]] && this.states[map[color]]!.common?.max === undefined) {\n this.states[map[color]]!.common ||= {};\n this.states[map[color]]!.common.max = 255;\n }\n });\n\n if (this.states[map.white]) {\n return {\n rgbw: {\n red: this.states[map.red]!,\n green: this.states[map.green]!,\n blue: this.states[map.blue]!,\n white: this.states[map.white]!,\n },\n };\n }\n return {\n rgb: {\n red: this.states[map.red]!,\n green: this.states[map.green]!,\n blue: this.states[map.blue]!,\n },\n };\n }\n\n protected composeInitObjectPowerState(): ControlStateInitObject {\n const map = this.statesMap;\n return {\n setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness]!,\n getState:\n this.states[map.on] ||\n this.states[map.on_actual] ||\n this.states[map.dimmer] ||\n 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 multiPurposeProperty: !this.states[map.on], // Could handle brightness events\n handleSimilarEvents: true, // If brightness set to non-zero value and power is off, turn the lamp on\n };\n }\n\n protected composeInitObjectBrightness(): ControlStateInitObject {\n const map = this.statesMap;\n let onValue: number | 'stored' | 'omit' | undefined = undefined;\n const offValue = AdapterProvider.deviceOffLevel();\n if (this.smartName && typeof this.smartName === 'object') {\n const byOn = this.smartName.byON;\n if (byOn !== null && byOn !== undefined && !isNaN(byOn as unknown as number)) {\n onValue = parseFloat(byOn as any);\n if (onValue < offValue) {\n onValue = offValue;\n }\n } else if (byOn === 'stored' || byOn === 'omit') {\n onValue = byOn;\n }\n }\n\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 multiPurposeProperty: !this.states[map.on], // Could handle powerState events\n handleSimilarEvents: true, // If power set ON and brightness is 0, set to non-zero value\n offValue,\n onValue,\n };\n }\n\n protected composeInitObjectColorTemperature(): ControlStateInitObject {\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
|
+
{"version":3,"file":"Rgb.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Rgb.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AACjD,4CAAiH;AACjH,iFAAyD;AAEzD,4EAAoD;AAEpD,gFAAwD;AACxD,4GAAoF;AAEpF,gFAAwD;AAExD,sEAA8C;AAC9C,0FAAkE;AAElE,+DAA+D;AAC/D,EAAE;AACF,qFAAqF;AACrF,EAAE;AACF,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAClJ,kJAAkJ;AAElJ,MAAqB,GAAI,SAAQ,2BAAiB;IAC7B,qBAAqB,CAAmC;IACxD,WAAW,CAAyB;IACpC,2BAA2B,CAAyC;IACp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G,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;AA/UD,sBA+UC","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, ControlStateInitObject } 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 PowerState from '../Alexa/Properties/PowerState';\nimport type { AlexaV3Category, AlexaV3DirectiveValue, AlexaV3Request, IotExternalPatternControl } from '../types';\nimport Color from '../Alexa/Properties/Color';\nimport EndpointHealth from '../Alexa/Capabilities/EndpointHealth';\n\n// ### RGB(W) Light with different states for every color [rgb]\n//\n// R,G,B(,W) Light with different states for every color. The value is from 0 to 255.\n//\n// | R | Name | Role | Unit | Type | Wr | Ind | Multi | Regex |\n// |---|-----------------|-------------------------------|------|---------|----|-----|-------|---------------------------------------------------|\n// | * | RED | level.color.red | | number | W | | | `/^level\\.color\\.red$/` |\n// | * | GREEN | level.color.green | | number | W | | | `/^level\\.color\\.green$/` |\n// | * | BLUE | level.color.blue | | number | W | | | `/^level\\.color\\.blue$/` |\n// | | WHITE | level.color.white | | number | W | | | `/^level\\.color\\.white$/` |\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)?$|^state$/` |\n// | | ON_ACTUAL | sensor.light | | boolean | - | | | `/^(state|switch|sensor)\\.light|switch$/` |\n\nexport default class Rgb extends AdjustableControl {\n private readonly _brightnessCapability: BrightnessController | undefined;\n private readonly _brightness: Brightness | undefined;\n private readonly _colorTemperatureCapability: ColorTemperatureController | undefined;\n private readonly _offValue: number = 0;\n\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n\n const map = this.statesMap;\n\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 if (!this.states[map.on]) {\n this._offValue = denormalize_0_100(\n AdapterProvider.deviceOffLevel(),\n this._brightness!.valuesRangeMin as number,\n (this._brightness!.valuesRangeMin as number) || 100,\n ) as number;\n }\n this._supported.push(new Capabilities.PowerController(this.composeInitObjectPowerState()));\n }\n\n const health = this.connectivityInitObject();\n if (health) {\n this._supported.push(new EndpointHealth(health));\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.propertyName === Color.propertyName) {\n // read every time all colors\n const red = await AdapterProvider.getState(this.states[map.red]!.id);\n const green = await AdapterProvider.getState(this.states[map.green]!.id);\n const blue = await AdapterProvider.getState(this.states[map.blue]!.id);\n let white: ioBroker.StateValue | undefined;\n if (this.states[map.white]) {\n white = await AdapterProvider.getState(this.states[map.white]!.id);\n }\n const minMaxRed = configuredRangeOrDefault(this.states[map.red]!);\n const minMaxGreen = configuredRangeOrDefault(this.states[map.green]!);\n const minMaxBlue = configuredRangeOrDefault(this.states[map.blue]!);\n let minMaxWhite: { min: number | boolean; max: number | boolean } | undefined;\n if (this.states[map.white]) {\n minMaxWhite = configuredRangeOrDefault(this.states[map.white]!);\n }\n // normalize values to 0-255\n const redNorm = normalize_0_100(red as number, minMaxRed.min as number, minMaxRed.max as number, true);\n const greenNorm = normalize_0_100(\n green as number,\n minMaxGreen.min as number,\n minMaxGreen.max as number,\n true,\n );\n const blueNorm = normalize_0_100(blue as number, minMaxBlue.min as number, minMaxBlue.max as number, true);\n let whiteNorm: number | undefined;\n if (this.states[map.white]) {\n whiteNorm = normalize_0_100(\n white as number,\n minMaxWhite!.min as number,\n minMaxWhite!.max as number,\n true,\n );\n }\n const red255 = Math.round((redNorm as number) * 2.55);\n const green255 = Math.round((greenNorm as number) * 2.55);\n const blue255 = Math.round((blueNorm as number) * 2.55);\n let white255: number | undefined;\n if (this.states[map.white]) {\n white255 = Math.round((whiteNorm as number) * 2.55);\n }\n\n // Convert to HEX\n let hex = `#${red255.toString(16).padStart(2, '0')}${green255.toString(16).padStart(2, '0')}${blue255.toString(16).padStart(2, '0')}`;\n\n if (this.states[map.white]) {\n hex += white255!.toString(16).padStart(2, '0');\n }\n\n // store current value\n property.currentValue = hex.toLowerCase();\n return property.currentValue;\n }\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 as number) > this._offValue;\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[this.statesMap.on]) {\n await AdapterProvider.setState(property.setId, value ?? false);\n property.currentValue = value;\n } else {\n // this will be processed in Brightness property\n }\n } else if (property.propertyName === Color.propertyName) {\n // Split value into RGB(W)\n const hex = (value as string).replace('#', '');\n const red = parseInt(hex.substring(0, 2), 16);\n const green = parseInt(hex.substring(2, 4), 16);\n const blue = parseInt(hex.substring(4, 6), 16);\n // let white: number | undefined;\n // if (hex.length === 8) {\n // white = parseInt(hex.substring(6, 8), 16);\n // }\n\n // Convert from 0-255 to 0-100\n const red100 = (red / 255) * 100;\n const green100 = (green / 255) * 100;\n const blue100 = (blue / 255) * 100;\n // let white100: number | undefined;\n // if (white !== undefined) {\n // white100 = (white / 255) * 100;\n // }\n\n // Convert from 0-100 to min-max of the state\n const minMaxRed = configuredRangeOrDefault(this.states[map.red]!);\n const minMaxGreen = configuredRangeOrDefault(this.states[map.green]!);\n const minMaxBlue = configuredRangeOrDefault(this.states[map.blue]!);\n // let minMaxWhite: { min: number | boolean; max: number | boolean } | undefined;\n // if (this.states[map.white]) {\n // minMaxWhite = configuredRangeOrDefault(this.states[map.white]!);\n // }\n\n const redValue = denormalize_0_100(red100, minMaxRed.min as number, minMaxRed.max as number);\n const greenValue = denormalize_0_100(green100, minMaxGreen.min as number, minMaxGreen.max as number);\n const blueValue = denormalize_0_100(blue100, minMaxBlue.min as number, minMaxBlue.max as number);\n // let whiteValue: number | undefined;\n // if (this.states[map.white]) {\n // whiteValue = denormalize_0_100(white100!, minMaxWhite!.min as number, minMaxWhite!.max as number);\n // }\n\n // set states\n await Promise.all([\n AdapterProvider.setState(this.states[map.red]!.id, redValue ?? 0),\n AdapterProvider.setState(this.states[map.green]!.id, greenValue ?? 0),\n AdapterProvider.setState(this.states[map.blue]!.id, blueValue ?? 0),\n // this.states[map.white] ? AdapterProvider.setState(this.states[map.white]!.id, whiteValue ?? 0) : null,\n ]);\n\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(): ControlStateInitObject {\n const map = this.statesMap;\n\n // Set default min max to 0 255 for colors\n ['red', 'green', 'blue', 'white'].forEach(color => {\n if (this.states[map[color]] && this.states[map[color]]!.common?.min === undefined) {\n this.states[map[color]]!.common ||= {};\n this.states[map[color]]!.common.min = 0;\n }\n if (this.states[map[color]] && this.states[map[color]]!.common?.max === undefined) {\n this.states[map[color]]!.common ||= {};\n this.states[map[color]]!.common.max = 255;\n }\n });\n\n if (this.states[map.white]) {\n return {\n rgbw: {\n red: this.states[map.red]!,\n green: this.states[map.green]!,\n blue: this.states[map.blue]!,\n white: this.states[map.white]!,\n },\n };\n }\n return {\n rgb: {\n red: this.states[map.red]!,\n green: this.states[map.green]!,\n blue: this.states[map.blue]!,\n },\n };\n }\n\n protected composeInitObjectPowerState(): ControlStateInitObject {\n const map = this.statesMap;\n return {\n setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness]!,\n getState:\n this.states[map.on] ||\n this.states[map.on_actual] ||\n this.states[map.dimmer] ||\n 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 multiPurposeProperty: !this.states[map.on], // Could handle brightness events\n handleSimilarEvents: true, // If brightness set to non-zero value and power is off, turn the lamp on\n };\n }\n\n protected composeInitObjectBrightness(): ControlStateInitObject {\n const map = this.statesMap;\n let onValue: number | 'stored' | 'omit' | undefined = undefined;\n const offValue = AdapterProvider.deviceOffLevel();\n if (this.smartName && typeof this.smartName === 'object') {\n const byOn = this.smartName.byON;\n if (byOn !== null && byOn !== undefined && !isNaN(byOn as unknown as number)) {\n onValue = parseFloat(byOn as any);\n if (onValue < offValue) {\n onValue = offValue;\n }\n } else if (byOn === 'stored' || byOn === 'omit') {\n onValue = byOn;\n }\n }\n\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 multiPurposeProperty: !this.states[map.on], // Could handle powerState events\n handleSimilarEvents: true, // If power set ON and brightness is 0, set to non-zero value\n offValue,\n onValue,\n };\n }\n\n protected composeInitObjectColorTemperature(): ControlStateInitObject {\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"]}
|
|
@@ -51,6 +51,26 @@ const ChangeReport_1 = __importDefault(require("./Alexa/Directives/ChangeReport"
|
|
|
51
51
|
const Discovery_1 = __importDefault(require("./Alexa/Directives/Discovery"));
|
|
52
52
|
const ReportState_1 = __importDefault(require("./Alexa/Directives/ReportState"));
|
|
53
53
|
const node_crypto_1 = require("node:crypto");
|
|
54
|
+
const GroupWord = {
|
|
55
|
+
en: 'Group',
|
|
56
|
+
de: 'Gruppe',
|
|
57
|
+
it: 'Gruppo',
|
|
58
|
+
fr: 'Groupe',
|
|
59
|
+
ru: 'Группа',
|
|
60
|
+
es: 'Grupo',
|
|
61
|
+
pl: 'Grupa',
|
|
62
|
+
nl: 'Groep',
|
|
63
|
+
};
|
|
64
|
+
const DeviceWord = {
|
|
65
|
+
en: 'Device',
|
|
66
|
+
de: 'Gerät',
|
|
67
|
+
it: 'Dispositivo',
|
|
68
|
+
fr: 'Appareil',
|
|
69
|
+
ru: 'Устройство',
|
|
70
|
+
es: 'Dispositivo',
|
|
71
|
+
pl: 'Urządzenie',
|
|
72
|
+
nl: 'Dispositivo',
|
|
73
|
+
};
|
|
54
74
|
class DeviceManager {
|
|
55
75
|
lang = 'en';
|
|
56
76
|
devices = [];
|
|
@@ -153,6 +173,7 @@ class DeviceManager {
|
|
|
153
173
|
// as long as not all controls mapped to a device...
|
|
154
174
|
// detectedControls = detectedControls.filter(c => ['light', 'dimmer'].includes(c.type));
|
|
155
175
|
const createdGroups = [];
|
|
176
|
+
const usedFriendlyNames = [];
|
|
156
177
|
while (detectedControls.length) {
|
|
157
178
|
// take the next control
|
|
158
179
|
const control = detectedControls[0];
|
|
@@ -164,9 +185,21 @@ class DeviceManager {
|
|
|
164
185
|
item.room?.id === control.room.id &&
|
|
165
186
|
control.functionality &&
|
|
166
187
|
item.functionality?.id === control.functionality.id);
|
|
188
|
+
let friendlyName = Utils.friendlyNameByRoomAndFunctionName(control, this.lang);
|
|
189
|
+
// If a friendly name is already used, append Gruppe, Group, Gruppo, Groupe, etc.
|
|
190
|
+
if (usedFriendlyNames.includes(friendlyName)) {
|
|
191
|
+
let index = 0;
|
|
192
|
+
let newFriendlyName = '';
|
|
193
|
+
do {
|
|
194
|
+
newFriendlyName = `${friendlyName} ${GroupWord[this.lang] || GroupWord.en}${index ? ` ${index}` : ''}`;
|
|
195
|
+
index++;
|
|
196
|
+
} while (usedFriendlyNames.includes(newFriendlyName));
|
|
197
|
+
friendlyName = newFriendlyName;
|
|
198
|
+
}
|
|
199
|
+
usedFriendlyNames.push(friendlyName);
|
|
167
200
|
this.toDevice({
|
|
168
201
|
detectedControls: processedControls,
|
|
169
|
-
friendlyName
|
|
202
|
+
friendlyName,
|
|
170
203
|
autoDetected: true,
|
|
171
204
|
roomName: this.getName(control.room?.common?.name),
|
|
172
205
|
funcName: this.getName(control.functionality?.common?.name),
|
|
@@ -185,9 +218,21 @@ class DeviceManager {
|
|
|
185
218
|
if (!createdGroups.includes(groupName)) {
|
|
186
219
|
createdGroups.push(groupName);
|
|
187
220
|
processedControls = detectedControls.filter(item => item.groupNames?.includes(groupName));
|
|
221
|
+
let friendlyName = this.getName(groupName);
|
|
222
|
+
// If a friendly name is already used, append Device
|
|
223
|
+
if (usedFriendlyNames.includes(friendlyName)) {
|
|
224
|
+
let index = 0;
|
|
225
|
+
let newFriendlyName = '';
|
|
226
|
+
do {
|
|
227
|
+
newFriendlyName = `${friendlyName} ${DeviceWord[this.lang] || DeviceWord.en}${index ? ` ${index}` : ''}`;
|
|
228
|
+
index++;
|
|
229
|
+
} while (usedFriendlyNames.includes(newFriendlyName));
|
|
230
|
+
friendlyName = newFriendlyName;
|
|
231
|
+
}
|
|
232
|
+
usedFriendlyNames.push(friendlyName);
|
|
188
233
|
this.toDevice({
|
|
189
234
|
detectedControls: processedControls,
|
|
190
|
-
friendlyName
|
|
235
|
+
friendlyName,
|
|
191
236
|
autoDetected: false,
|
|
192
237
|
toggle: processedControls[0].object?.toggle ?? defaultToggle,
|
|
193
238
|
possibleTypes: processedControls[0].object?.possibleTypes || [],
|
|
@@ -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,gFAAwD;AACxD,0EAAkD;AAClD,kEAA0C;AAC1C,wEAAgD;AAChD,+GAAuF;AACvF,+GAAuF;AAEvF,mFAA2D;AAC3D,6EAAqD;AACrD,iFAAyD;AACzD,6CAAyC;AAGzC,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,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;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,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;AAxcD,gCAwcC","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';\nimport type { Types } from '@iobroker/type-detector';\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(options: {\n detectedControls: IotExternalPatternControl[];\n friendlyName: string;\n autoDetected: boolean;\n roomName?: string;\n funcName?: string;\n toggle?: boolean;\n possibleTypes: Types[];\n typeWasDetected: boolean;\n }): Device | undefined {\n const controls: Control[] = [];\n\n this.log.debug(`merging controls to a device with name ${options.friendlyName}`);\n\n options.detectedControls.forEach(item => {\n this.log.silly(`processing control: ${JSON.stringify(item)}`);\n const control = Controls.factory(item);\n\n if (control) {\n this.log.debug(`\"${item.type}\" added to \"${options.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) {\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: options.friendlyName,\n friendlyName: options.friendlyName,\n controls,\n autoDetected: options.autoDetected,\n roomName: options.roomName,\n funcName: options.funcName,\n toggle: options.toggle,\n possibleTypes: options.possibleTypes,\n typeWasDetected: options.typeWasDetected,\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 detectedControls: processedControls,\n friendlyName: Utils.friendlyNameByRoomAndFunctionName(control, this.lang),\n autoDetected: true,\n roomName: this.getName(control.room?.common?.name),\n funcName: this.getName(control.functionality?.common?.name),\n toggle: processedControls[0].object?.toggle ?? defaultToggle,\n possibleTypes: processedControls[0].object?.possibleTypes || [],\n typeWasDetected: processedControls[0].object?.typeWasDetected || false,\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 detectedControls: processedControls,\n friendlyName: this.getName(groupName),\n autoDetected: false,\n toggle: processedControls[0].object?.toggle ?? defaultToggle,\n possibleTypes: processedControls[0].object?.possibleTypes || [],\n typeWasDetected: processedControls[0].object?.typeWasDetected || false,\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) {\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 newSubscribed = Array.from(stateIds);\n const subscribe: string[] = [];\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 if (!subscribe.includes(id)) {\n subscribe.push(id);\n }\n }\n }\n\n this.subscribed.sort();\n\n // wait till all promises are settled\n if (subscribe.length) {\n await AdapterProvider.subscribe(subscribe);\n }\n\n // unsubscribe from unused states\n const unsubscribe: string[] = [];\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 if (!unsubscribe.includes(id)) {\n unsubscribe.push(id);\n }\n }\n }\n if (unsubscribe.length) {\n await AdapterProvider.unsubscribe(unsubscribe);\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"]}
|
|
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;AAGzC,MAAM,SAAS,GAA+B;IAC1C,EAAE,EAAE,OAAO;IACX,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,OAAO;IACX,EAAE,EAAE,OAAO;IACX,EAAE,EAAE,OAAO;CACd,CAAC;AACF,MAA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AAG,CAAC,KAAK,CAAC,YAAY,EAAE,+BAA+B,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;CACJ;AAneD,gCAmeC","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';\nimport type { Types } from '@iobroker/type-detector';\n\nconst GroupWord: { [lang: string]: string } = {\n en: 'Group',\n de: 'Gruppe',\n it: 'Gruppo',\n fr: 'Groupe',\n ru: 'Группа',\n es: 'Grupo',\n pl: 'Grupa',\n nl: 'Groep',\n};\nconst DeviceWord: { [lang: string]: string } = {\n en: 'Device',\n de: 'Gerät',\n it: 'Dispositivo',\n fr: 'Appareil',\n ru: 'Устройство',\n es: 'Dispositivo',\n pl: 'Urządzenie',\n nl: 'Dispositivo',\n};\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(options: {\n detectedControls: IotExternalPatternControl[];\n friendlyName: string;\n autoDetected: boolean;\n roomName?: string;\n funcName?: string;\n toggle?: boolean;\n possibleTypes: Types[];\n typeWasDetected: boolean;\n }): Device | undefined {\n const controls: Control[] = [];\n\n this.log.debug(`merging controls to a device with name ${options.friendlyName}`);\n\n options.detectedControls.forEach(item => {\n this.log.silly(`processing control: ${JSON.stringify(item)}`);\n const control = Controls.factory(item);\n\n if (control) {\n this.log.debug(`\"${item.type}\" added to \"${options.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) {\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: options.friendlyName,\n friendlyName: options.friendlyName,\n controls,\n autoDetected: options.autoDetected,\n roomName: options.roomName,\n funcName: options.funcName,\n toggle: options.toggle,\n possibleTypes: options.possibleTypes,\n typeWasDetected: options.typeWasDetected,\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 const usedFriendlyNames: 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 let friendlyName = Utils.friendlyNameByRoomAndFunctionName(control, this.lang);\n // If a friendly name is already used, append Gruppe, Group, Gruppo, Groupe, etc.\n if (usedFriendlyNames.includes(friendlyName)) {\n let index = 0;\n let newFriendlyName = '';\n do {\n newFriendlyName = `${friendlyName} ${GroupWord[this.lang] || GroupWord.en}${index ? ` ${index}` : ''}`;\n index++;\n } while (usedFriendlyNames.includes(newFriendlyName));\n friendlyName = newFriendlyName;\n }\n usedFriendlyNames.push(friendlyName);\n\n this.toDevice({\n detectedControls: processedControls,\n friendlyName,\n autoDetected: true,\n roomName: this.getName(control.room?.common?.name),\n funcName: this.getName(control.functionality?.common?.name),\n toggle: processedControls[0].object?.toggle ?? defaultToggle,\n possibleTypes: processedControls[0].object?.possibleTypes || [],\n typeWasDetected: processedControls[0].object?.typeWasDetected || false,\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 let friendlyName = this.getName(groupName);\n // If a friendly name is already used, append Device\n if (usedFriendlyNames.includes(friendlyName)) {\n let index = 0;\n let newFriendlyName = '';\n do {\n newFriendlyName = `${friendlyName} ${DeviceWord[this.lang] || DeviceWord.en}${index ? ` ${index}` : ''}`;\n index++;\n } while (usedFriendlyNames.includes(newFriendlyName));\n friendlyName = newFriendlyName;\n }\n usedFriendlyNames.push(friendlyName);\n\n this.toDevice({\n detectedControls: processedControls,\n friendlyName,\n autoDetected: false,\n toggle: processedControls[0].object?.toggle ?? defaultToggle,\n possibleTypes: processedControls[0].object?.possibleTypes || [],\n typeWasDetected: processedControls[0].object?.typeWasDetected || false,\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) {\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 newSubscribed = Array.from(stateIds);\n const subscribe: string[] = [];\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 if (!subscribe.includes(id)) {\n subscribe.push(id);\n }\n }\n }\n\n this.subscribed.sort();\n\n // wait till all promises are settled\n if (subscribe.length) {\n await AdapterProvider.subscribe(subscribe);\n }\n\n // unsubscribe from unused states\n const unsubscribe: string[] = [];\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 if (!unsubscribe.includes(id)) {\n unsubscribe.push(id);\n }\n }\n }\n if (unsubscribe.length) {\n await AdapterProvider.unsubscribe(unsubscribe);\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"]}
|
|
@@ -637,7 +637,7 @@ async function controls(adapter, lang) {
|
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
639
|
const name = smartName[lang] || smartName.en || smartName.de;
|
|
640
|
-
control.groupNames = name?.split(',').map(n => n.trim()) || [];
|
|
640
|
+
control.groupNames = (name?.split(',').map(n => n.trim()) || []).filter(n => n);
|
|
641
641
|
adapter.log.debug(`[ALEXA3] added ${id} with smartName as "${smartName.smartType}"`);
|
|
642
642
|
detectedControls.push(control);
|
|
643
643
|
}
|