@fastybird/smart-panel-backend 0.1.0-alpha.5 → 0.1.0-alpha.7
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/dist/app.module.js +5 -0
- package/dist/app.module.js.map +1 -1
- package/dist/migrations/1000000000000-InitialSetup.js +23 -13
- package/dist/migrations/1000000000000-InitialSetup.js.map +1 -1
- package/dist/migrations/1000000000001-AddSceneIcon.d.ts +6 -0
- package/dist/migrations/1000000000001-AddSceneIcon.js +22 -0
- package/dist/migrations/1000000000001-AddSceneIcon.js.map +1 -0
- package/dist/modules/auth/auth.module.js +1 -1
- package/dist/modules/auth/auth.module.js.map +1 -1
- package/dist/modules/dashboard/dashboard.module.js +1 -1
- package/dist/modules/dashboard/dashboard.module.js.map +1 -1
- package/dist/modules/devices/services/devices-type-mapper.service.d.ts +1 -1
- package/dist/modules/devices/services/devices.service.d.ts +1 -0
- package/dist/modules/devices/services/devices.service.js +22 -23
- package/dist/modules/devices/services/devices.service.js.map +1 -1
- package/dist/modules/scenes/dto/create-scene.dto.d.ts +1 -0
- package/dist/modules/scenes/dto/create-scene.dto.js +13 -0
- package/dist/modules/scenes/dto/create-scene.dto.js.map +1 -1
- package/dist/modules/scenes/dto/update-scene.dto.d.ts +1 -0
- package/dist/modules/scenes/dto/update-scene.dto.js +13 -0
- package/dist/modules/scenes/dto/update-scene.dto.js.map +1 -1
- package/dist/modules/scenes/entities/scenes.entity.d.ts +1 -0
- package/dist/modules/scenes/entities/scenes.entity.js +13 -0
- package/dist/modules/scenes/entities/scenes.entity.js.map +1 -1
- package/dist/modules/storage/models/config.model.js +2 -4
- package/dist/modules/storage/models/config.model.js.map +1 -1
- package/dist/modules/storage/storage.constants.d.ts +2 -0
- package/dist/modules/storage/storage.constants.js +3 -1
- package/dist/modules/storage/storage.constants.js.map +1 -1
- package/dist/modules/storage/storage.module.js +1 -3
- package/dist/modules/storage/storage.module.js.map +1 -1
- package/dist/modules/system/commands/update-panel.command.js +7 -12
- package/dist/modules/system/commands/update-panel.command.js.map +1 -1
- package/dist/modules/system/services/update.service.d.ts +2 -0
- package/dist/modules/system/services/update.service.js +37 -17
- package/dist/modules/system/services/update.service.js.map +1 -1
- package/dist/plugins/data-sources-device-channel/data-sources-device-channel.plugin.js +1 -1
- package/dist/plugins/data-sources-device-channel/data-sources-device-channel.plugin.js.map +1 -1
- package/dist/plugins/data-sources-weather/data-sources-weather.plugin.js +1 -1
- package/dist/plugins/data-sources-weather/data-sources-weather.plugin.js.map +1 -1
- package/dist/plugins/devices-home-assistant/devices-home-assistant.openapi.d.ts +2 -2
- package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js +3 -1
- package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js.map +1 -1
- package/dist/plugins/devices-home-assistant/dto/helper-mapping-preview.dto.d.ts +1 -0
- package/dist/plugins/devices-home-assistant/dto/helper-mapping-preview.dto.js +14 -0
- package/dist/plugins/devices-home-assistant/dto/helper-mapping-preview.dto.js.map +1 -1
- package/dist/plugins/devices-home-assistant/models/config.model.d.ts +1 -0
- package/dist/plugins/devices-home-assistant/models/config.model.js +12 -0
- package/dist/plugins/devices-home-assistant/models/config.model.js.map +1 -1
- package/dist/plugins/devices-home-assistant/platforms/home-assistant.device.platform.d.ts +3 -1
- package/dist/plugins/devices-home-assistant/platforms/home-assistant.device.platform.js +14 -2
- package/dist/plugins/devices-home-assistant/platforms/home-assistant.device.platform.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/device-adoption.service.js +2 -2
- package/dist/plugins/devices-home-assistant/services/device-adoption.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/ha-supervisor.service.d.ts +10 -0
- package/dist/plugins/devices-home-assistant/services/ha-supervisor.service.js +47 -0
- package/dist/plugins/devices-home-assistant/services/ha-supervisor.service.js.map +1 -0
- package/dist/plugins/devices-home-assistant/services/helper-adoption.service.js +1 -7
- package/dist/plugins/devices-home-assistant/services/helper-adoption.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant-config-validator.service.d.ts +3 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant-config-validator.service.js +9 -3
- package/dist/plugins/devices-home-assistant/services/home-assistant-config-validator.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant.http.service.d.ts +3 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant.http.service.js +19 -7
- package/dist/plugins/devices-home-assistant/services/home-assistant.http.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.d.ts +3 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js +18 -3
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js.map +1 -1
- package/dist/plugins/devices-reterminal/devices-reterminal.plugin.js +1 -1
- package/dist/plugins/devices-reterminal/devices-reterminal.plugin.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.d.ts +11 -1
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js +226 -49
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.d.ts +5 -0
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js +10 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.d.ts +5 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js +23 -4
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/dto/create-device.dto.d.ts +1 -1
- package/dist/plugins/devices-shelly-ng/dto/create-device.dto.js +11 -12
- package/dist/plugins/devices-shelly-ng/dto/create-device.dto.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/dto/update-device.dto.d.ts +2 -1
- package/dist/plugins/devices-shelly-ng/dto/update-device.dto.js +19 -4
- package/dist/plugins/devices-shelly-ng/dto/update-device.dto.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/entities/devices-shelly-ng.entity.d.ts +6 -1
- package/dist/plugins/devices-shelly-ng/entities/devices-shelly-ng.entity.js +38 -6
- package/dist/plugins/devices-shelly-ng/entities/devices-shelly-ng.entity.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/entities/shelly-ng-device-address.entity.d.ts +10 -0
- package/dist/plugins/devices-shelly-ng/entities/shelly-ng-device-address.entity.js +69 -0
- package/dist/plugins/devices-shelly-ng/entities/shelly-ng-device-address.entity.js.map +1 -0
- package/dist/plugins/devices-shelly-ng/services/database-discoverer.service.d.ts +3 -1
- package/dist/plugins/devices-shelly-ng/services/database-discoverer.service.js +19 -7
- package/dist/plugins/devices-shelly-ng/services/database-discoverer.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/services/device-address.service.d.ts +22 -0
- package/dist/plugins/devices-shelly-ng/services/device-address.service.js +149 -0
- package/dist/plugins/devices-shelly-ng/services/device-address.service.js.map +1 -0
- package/dist/plugins/devices-shelly-ng/services/device-manager.service.d.ts +3 -1
- package/dist/plugins/devices-shelly-ng/services/device-manager.service.js +20 -7
- package/dist/plugins/devices-shelly-ng/services/device-manager.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js +18 -3
- package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/subscribers/device-entity.subscriber.d.ts +6 -2
- package/dist/plugins/devices-shelly-ng/subscribers/device-entity.subscriber.js +75 -6
- package/dist/plugins/devices-shelly-ng/subscribers/device-entity.subscriber.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js +1 -1
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js.map +1 -1
- package/dist/plugins/devices-third-party/devices-third-party.plugin.js +1 -1
- package/dist/plugins/devices-third-party/devices-third-party.plugin.js.map +1 -1
- package/dist/plugins/devices-wled/devices-wled.plugin.js +1 -1
- package/dist/plugins/devices-wled/devices-wled.plugin.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.d.ts +4 -0
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js +5 -1
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.openapi.d.ts +2 -2
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.openapi.js +2 -0
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.openapi.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.plugin.js +12 -7
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.plugin.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/dto/update-config.dto.d.ts +10 -0
- package/dist/plugins/devices-zigbee2mqtt/dto/update-config.dto.js +117 -3
- package/dist/plugins/devices-zigbee2mqtt/dto/update-config.dto.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/interfaces/zigbee2mqtt.interface.d.ts +8 -0
- package/dist/plugins/devices-zigbee2mqtt/mappings/definitions/covers.yaml +5 -4
- package/dist/plugins/devices-zigbee2mqtt/models/config.model.d.ts +10 -0
- package/dist/plugins/devices-zigbee2mqtt/models/config.model.js +108 -3
- package/dist/plugins/devices-zigbee2mqtt/models/config.model.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/platforms/zigbee2mqtt.device.platform.d.ts +3 -4
- package/dist/plugins/devices-zigbee2mqtt/platforms/zigbee2mqtt.device.platform.js +11 -22
- package/dist/plugins/devices-zigbee2mqtt/platforms/zigbee2mqtt.device.platform.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.d.ts +35 -0
- package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js +265 -0
- package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js.map +1 -0
- package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js +6 -5
- package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.d.ts +4 -26
- package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js +16 -265
- package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/virtual-property.types.js +0 -16
- package/dist/plugins/devices-zigbee2mqtt/services/virtual-property.types.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/ws-client-adapter.service.d.ts +14 -0
- package/dist/plugins/devices-zigbee2mqtt/services/ws-client-adapter.service.js +199 -0
- package/dist/plugins/devices-zigbee2mqtt/services/ws-client-adapter.service.js.map +1 -0
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt-config-validator.service.d.ts +2 -0
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt-config-validator.service.js +69 -0
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt-config-validator.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.d.ts +8 -1
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js +86 -32
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js.map +1 -1
- package/dist/{modules/storage/plugins/influx-v1/influx-v1.update-config.dto.d.ts → plugins/influx-v1/dto/update-config.dto.d.ts} +1 -1
- package/dist/{modules/storage/plugins/influx-v1/influx-v1.update-config.dto.js → plugins/influx-v1/dto/update-config.dto.js} +3 -3
- package/dist/plugins/influx-v1/dto/update-config.dto.js.map +1 -0
- package/dist/plugins/influx-v1/influx-v1.constants.js.map +1 -0
- package/dist/{modules/storage/plugins → plugins}/influx-v1/influx-v1.openapi.d.ts +1 -1
- package/dist/plugins/influx-v1/influx-v1.openapi.js +7 -0
- package/dist/plugins/influx-v1/influx-v1.openapi.js.map +1 -0
- package/dist/{modules/storage/plugins/influx-v1/influx-v1.module.d.ts → plugins/influx-v1/influx-v1.plugin.d.ts} +6 -6
- package/dist/{modules/storage/plugins/influx-v1/influx-v1.module.js → plugins/influx-v1/influx-v1.plugin.js} +22 -22
- package/dist/plugins/influx-v1/influx-v1.plugin.js.map +1 -0
- package/dist/{modules/storage/plugins/influx-v1/influx-v1.config.model.d.ts → plugins/influx-v1/models/config.model.d.ts} +1 -1
- package/dist/{modules/storage/plugins/influx-v1/influx-v1.config.model.js → plugins/influx-v1/models/config.model.js} +3 -3
- package/dist/plugins/influx-v1/models/config.model.js.map +1 -0
- package/dist/{modules/storage/plugins/influx-v1/influx-v1.plugin.d.ts → plugins/influx-v1/services/influx-v1.storage.d.ts} +3 -3
- package/dist/{modules/storage/plugins/influx-v1/influx-v1.plugin.js → plugins/influx-v1/services/influx-v1.storage.js} +9 -9
- package/dist/plugins/influx-v1/services/influx-v1.storage.js.map +1 -0
- package/dist/{modules/storage/plugins/memory/memory.update-config.dto.d.ts → plugins/memory-storage/dto/update-config.dto.d.ts} +1 -1
- package/dist/{modules/storage/plugins/memory/memory.update-config.dto.js → plugins/memory-storage/dto/update-config.dto.js} +5 -5
- package/dist/plugins/memory-storage/dto/update-config.dto.js.map +1 -0
- package/dist/{modules/storage/plugins/memory/memory.constants.js → plugins/memory-storage/memory-storage.constants.js} +1 -1
- package/dist/plugins/memory-storage/memory-storage.constants.js.map +1 -0
- package/dist/{modules/storage/plugins/memory/memory.openapi.d.ts → plugins/memory-storage/memory-storage.openapi.d.ts} +1 -1
- package/dist/plugins/memory-storage/memory-storage.openapi.js +7 -0
- package/dist/plugins/memory-storage/memory-storage.openapi.js.map +1 -0
- package/dist/plugins/memory-storage/memory-storage.plugin.d.ts +13 -0
- package/dist/{modules/storage/plugins/memory/memory.module.js → plugins/memory-storage/memory-storage.plugin.js} +24 -24
- package/dist/plugins/memory-storage/memory-storage.plugin.js.map +1 -0
- package/dist/{modules/storage/plugins/memory/memory.config.model.d.ts → plugins/memory-storage/models/config.model.d.ts} +1 -1
- package/dist/{modules/storage/plugins/memory/memory.config.model.js → plugins/memory-storage/models/config.model.js} +5 -5
- package/dist/plugins/memory-storage/models/config.model.js.map +1 -0
- package/dist/{modules/storage/plugins/memory → plugins/memory-storage/services}/in-memory-timeseries.store.d.ts +1 -1
- package/dist/{modules/storage/plugins/memory → plugins/memory-storage/services}/in-memory-timeseries.store.js +3 -3
- package/dist/plugins/memory-storage/services/in-memory-timeseries.store.js.map +1 -0
- package/dist/plugins/memory-storage/services/influxql-parser.js.map +1 -0
- package/dist/{modules/storage/plugins/memory/memory.plugin.d.ts → plugins/memory-storage/services/memory-storage.storage.d.ts} +3 -3
- package/dist/{modules/storage/plugins/memory/memory.plugin.js → plugins/memory-storage/services/memory-storage.storage.js} +8 -8
- package/dist/plugins/memory-storage/services/memory-storage.storage.js.map +1 -0
- package/dist/plugins/simulator/simulator.plugin.js +4 -4
- package/dist/plugins/simulator/simulator.plugin.js.map +1 -1
- package/dist/plugins/tiles-device-preview/tiles-device-preview.plugin.js +1 -1
- package/dist/plugins/tiles-device-preview/tiles-device-preview.plugin.js.map +1 -1
- package/dist/plugins/tiles-scene/tiles-scene.plugin.js +1 -1
- package/dist/plugins/tiles-scene/tiles-scene.plugin.js.map +1 -1
- package/dist/plugins/tiles-time/tiles-time.plugin.js +1 -1
- package/dist/plugins/weather-openweathermap-onecall/weather-openweathermap-onecall.plugin.js +1 -1
- package/dist/plugins/weather-openweathermap-onecall/weather-openweathermap-onecall.plugin.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/modules/storage/plugins/influx-v1/influx-v1.config.model.js.map +0 -1
- package/dist/modules/storage/plugins/influx-v1/influx-v1.constants.js.map +0 -1
- package/dist/modules/storage/plugins/influx-v1/influx-v1.module.js.map +0 -1
- package/dist/modules/storage/plugins/influx-v1/influx-v1.openapi.js +0 -7
- package/dist/modules/storage/plugins/influx-v1/influx-v1.openapi.js.map +0 -1
- package/dist/modules/storage/plugins/influx-v1/influx-v1.plugin.js.map +0 -1
- package/dist/modules/storage/plugins/influx-v1/influx-v1.update-config.dto.js.map +0 -1
- package/dist/modules/storage/plugins/memory/in-memory-timeseries.store.js.map +0 -1
- package/dist/modules/storage/plugins/memory/influxql-parser.js.map +0 -1
- package/dist/modules/storage/plugins/memory/memory.config.model.js.map +0 -1
- package/dist/modules/storage/plugins/memory/memory.constants.js.map +0 -1
- package/dist/modules/storage/plugins/memory/memory.module.d.ts +0 -13
- package/dist/modules/storage/plugins/memory/memory.module.js.map +0 -1
- package/dist/modules/storage/plugins/memory/memory.openapi.js +0 -7
- package/dist/modules/storage/plugins/memory/memory.openapi.js.map +0 -1
- package/dist/modules/storage/plugins/memory/memory.plugin.js.map +0 -1
- package/dist/modules/storage/plugins/memory/memory.update-config.dto.js.map +0 -1
- /package/dist/{modules/storage/plugins → plugins}/influx-v1/influx-v1.constants.d.ts +0 -0
- /package/dist/{modules/storage/plugins → plugins}/influx-v1/influx-v1.constants.js +0 -0
- /package/dist/{modules/storage/plugins/memory/memory.constants.d.ts → plugins/memory-storage/memory-storage.constants.d.ts} +0 -0
- /package/dist/{modules/storage/plugins/memory → plugins/memory-storage/services}/influxql-parser.d.ts +0 -0
- /package/dist/{modules/storage/plugins/memory → plugins/memory-storage/services}/influxql-parser.js +0 -0
|
@@ -18,8 +18,8 @@ const devices_shelly_ng_constants_1 = require("../devices-shelly-ng.constants");
|
|
|
18
18
|
let CreateShellyNgDeviceDto = class CreateShellyNgDeviceDto extends create_device_dto_1.CreateDeviceDto {
|
|
19
19
|
constructor() {
|
|
20
20
|
super(...arguments);
|
|
21
|
-
this.hostname = null;
|
|
22
21
|
this.password = null;
|
|
22
|
+
this.wifiAddress = null;
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
exports.CreateShellyNgDeviceDto = CreateShellyNgDeviceDto;
|
|
@@ -36,28 +36,27 @@ __decorate([
|
|
|
36
36
|
], CreateShellyNgDeviceDto.prototype, "type", void 0);
|
|
37
37
|
__decorate([
|
|
38
38
|
(0, swagger_1.ApiPropertyOptional)({
|
|
39
|
-
description: 'Device
|
|
40
|
-
example: '
|
|
39
|
+
description: 'Device password',
|
|
40
|
+
example: 'password123',
|
|
41
41
|
nullable: true,
|
|
42
42
|
}),
|
|
43
43
|
(0, class_transformer_1.Expose)(),
|
|
44
44
|
(0, class_validator_1.IsOptional)(),
|
|
45
|
-
(0, class_validator_1.IsString)({
|
|
46
|
-
message: '[{"field":"hostname","reason":"Hostname attribute must be a valid IP address or network hostname."}]',
|
|
47
|
-
}),
|
|
45
|
+
(0, class_validator_1.IsString)({ message: '[{"field":"password","reason":"Password attribute must be a valid string."}]' }),
|
|
48
46
|
__metadata("design:type", String)
|
|
49
|
-
], CreateShellyNgDeviceDto.prototype, "
|
|
47
|
+
], CreateShellyNgDeviceDto.prototype, "password", void 0);
|
|
50
48
|
__decorate([
|
|
51
49
|
(0, swagger_1.ApiPropertyOptional)({
|
|
52
|
-
description: '
|
|
53
|
-
example: '
|
|
50
|
+
description: 'WiFi IP address or hostname of the device',
|
|
51
|
+
example: '192.168.1.100',
|
|
54
52
|
nullable: true,
|
|
53
|
+
name: 'wifi_address',
|
|
55
54
|
}),
|
|
56
|
-
(0, class_transformer_1.Expose)(),
|
|
55
|
+
(0, class_transformer_1.Expose)({ name: 'wifi_address' }),
|
|
57
56
|
(0, class_validator_1.IsOptional)(),
|
|
58
|
-
(0, class_validator_1.IsString)({ message: '[{"field":"
|
|
57
|
+
(0, class_validator_1.IsString)({ message: '[{"field":"wifi_address","reason":"WiFi address must be a valid string."}]' }),
|
|
59
58
|
__metadata("design:type", String)
|
|
60
|
-
], CreateShellyNgDeviceDto.prototype, "
|
|
59
|
+
], CreateShellyNgDeviceDto.prototype, "wifiAddress", void 0);
|
|
61
60
|
exports.CreateShellyNgDeviceDto = CreateShellyNgDeviceDto = __decorate([
|
|
62
61
|
(0, swagger_1.ApiSchema)({ name: 'DevicesShellyNgPluginCreateDevice' })
|
|
63
62
|
], CreateShellyNgDeviceDto);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-device.dto.js","sourceRoot":"","sources":["../../../../src/plugins/devices-shelly-ng/dto/create-device.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA2C;AAC3C,qDAAuD;AAEvD,6CAA8E;AAE9E,sFAAiF;AACjF,gFAAwE;AAGjE,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,mCAAe;IAArD;;
|
|
1
|
+
{"version":3,"file":"create-device.dto.js","sourceRoot":"","sources":["../../../../src/plugins/devices-shelly-ng/dto/create-device.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA2C;AAC3C,qDAAuD;AAEvD,6CAA8E;AAE9E,sFAAiF;AACjF,gFAAwE;AAGjE,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,mCAAe;IAArD;;QAmBN,aAAQ,GAAmB,IAAI,CAAC;QAWhC,gBAAW,GAAmB,IAAI,CAAC;IACpC,CAAC;CAAA,CAAA;AA/BY,0DAAuB;AAS1B;IARR,IAAA,qBAAW,EAAC;QACZ,WAAW,EAAE,aAAa;QAC1B,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,oDAAsB;QAC/B,OAAO,EAAE,oDAAsB;KAC/B,CAAC;IACD,IAAA,0BAAM,GAAE;IACR,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,wEAAwE,EAAE,CAAC;;qDACnD;AAU7C;IARC,IAAA,6BAAmB,EAAC;QACpB,WAAW,EAAE,iBAAiB;QAC9B,OAAO,EAAE,aAAa;QACtB,QAAQ,EAAE,IAAI;KACd,CAAC;IACD,IAAA,0BAAM,GAAE;IACR,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,8EAA8E,EAAE,CAAC;;yDACtE;AAWhC;IATC,IAAA,6BAAmB,EAAC;QACpB,WAAW,EAAE,2CAA2C;QACxD,OAAO,EAAE,eAAe;QACxB,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,cAAc;KACpB,CAAC;IACD,IAAA,0BAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IAChC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,4EAA4E,EAAE,CAAC;;4DACjE;kCA9BvB,uBAAuB;IADnC,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,mCAAmC,EAAE,CAAC;GAC5C,uBAAuB,CA+BnC"}
|
|
@@ -3,5 +3,6 @@ import { DEVICES_SHELLY_NG_TYPE } from '../devices-shelly-ng.constants';
|
|
|
3
3
|
export declare class UpdateShellyNgDeviceDto extends UpdateDeviceDto {
|
|
4
4
|
type: typeof DEVICES_SHELLY_NG_TYPE;
|
|
5
5
|
password?: string | null;
|
|
6
|
-
|
|
6
|
+
wifiAddress?: string | null;
|
|
7
|
+
ethernetAddress?: string | null;
|
|
7
8
|
}
|
|
@@ -42,17 +42,32 @@ __decorate([
|
|
|
42
42
|
], UpdateShellyNgDeviceDto.prototype, "password", void 0);
|
|
43
43
|
__decorate([
|
|
44
44
|
(0, swagger_1.ApiPropertyOptional)({
|
|
45
|
-
description: '
|
|
45
|
+
description: 'WiFi interface IP address',
|
|
46
|
+
name: 'wifi_address',
|
|
46
47
|
example: '192.168.1.100',
|
|
47
48
|
nullable: true,
|
|
48
49
|
}),
|
|
49
|
-
(0, class_transformer_1.Expose)(),
|
|
50
|
+
(0, class_transformer_1.Expose)({ name: 'wifi_address' }),
|
|
51
|
+
(0, class_validator_1.IsOptional)(),
|
|
52
|
+
(0, class_validator_1.IsString)({
|
|
53
|
+
message: '[{"field":"wifi_address","reason":"WiFi address must be a valid IP address or network hostname."}]',
|
|
54
|
+
}),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], UpdateShellyNgDeviceDto.prototype, "wifiAddress", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
59
|
+
description: 'Ethernet interface IP address',
|
|
60
|
+
name: 'ethernet_address',
|
|
61
|
+
example: '192.168.1.101',
|
|
62
|
+
nullable: true,
|
|
63
|
+
}),
|
|
64
|
+
(0, class_transformer_1.Expose)({ name: 'ethernet_address' }),
|
|
50
65
|
(0, class_validator_1.IsOptional)(),
|
|
51
66
|
(0, class_validator_1.IsString)({
|
|
52
|
-
message: '[{"field":"
|
|
67
|
+
message: '[{"field":"ethernet_address","reason":"Ethernet address must be a valid IP address or network hostname."}]',
|
|
53
68
|
}),
|
|
54
69
|
__metadata("design:type", String)
|
|
55
|
-
], UpdateShellyNgDeviceDto.prototype, "
|
|
70
|
+
], UpdateShellyNgDeviceDto.prototype, "ethernetAddress", void 0);
|
|
56
71
|
exports.UpdateShellyNgDeviceDto = UpdateShellyNgDeviceDto = __decorate([
|
|
57
72
|
(0, swagger_1.ApiSchema)({ name: 'DevicesShellyNgPluginUpdateDevice' })
|
|
58
73
|
], UpdateShellyNgDeviceDto);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-device.dto.js","sourceRoot":"","sources":["../../../../src/plugins/devices-shelly-ng/dto/update-device.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA2C;AAC3C,qDAAuD;AAEvD,6CAA8E;AAE9E,sFAAiF;AACjF,gFAAwE;AAGjE,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,mCAAe;
|
|
1
|
+
{"version":3,"file":"update-device.dto.js","sourceRoot":"","sources":["../../../../src/plugins/devices-shelly-ng/dto/update-device.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA2C;AAC3C,qDAAuD;AAEvD,6CAA8E;AAE9E,sFAAiF;AACjF,gFAAwE;AAGjE,IAAM,uBAAuB,GAA7B,MAAM,uBA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AC5C,uBAAuB,CA+CnC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { ChannelEntity, ChannelPropertyEntity, DeviceEntity } from '../../../modules/devices/entities/devices.entity';
|
|
2
|
+
import { ShellyNgDeviceAddressEntity } from './shelly-ng-device-address.entity';
|
|
2
3
|
export declare class ShellyNgDeviceEntity extends DeviceEntity {
|
|
3
4
|
get type(): string;
|
|
4
5
|
password: string | null;
|
|
5
|
-
|
|
6
|
+
canonicalMac: string | null;
|
|
7
|
+
hasEthernet: boolean;
|
|
8
|
+
wifiAddress?: string | null;
|
|
9
|
+
ethernetAddress?: string | null;
|
|
10
|
+
addresses: ShellyNgDeviceAddressEntity[];
|
|
6
11
|
toString(): string;
|
|
7
12
|
}
|
|
8
13
|
export declare class ShellyNgChannelEntity extends ChannelEntity {
|
|
@@ -16,11 +16,13 @@ const typeorm_1 = require("typeorm");
|
|
|
16
16
|
const swagger_1 = require("@nestjs/swagger");
|
|
17
17
|
const devices_entity_1 = require("../../../modules/devices/entities/devices.entity");
|
|
18
18
|
const devices_shelly_ng_constants_1 = require("../devices-shelly-ng.constants");
|
|
19
|
+
const shelly_ng_device_address_entity_1 = require("./shelly-ng-device-address.entity");
|
|
19
20
|
let ShellyNgDeviceEntity = class ShellyNgDeviceEntity extends devices_entity_1.DeviceEntity {
|
|
20
21
|
constructor() {
|
|
21
22
|
super(...arguments);
|
|
22
23
|
this.password = null;
|
|
23
|
-
this.
|
|
24
|
+
this.canonicalMac = null;
|
|
25
|
+
this.hasEthernet = false;
|
|
24
26
|
}
|
|
25
27
|
get type() {
|
|
26
28
|
return devices_shelly_ng_constants_1.DEVICES_SHELLY_NG_TYPE;
|
|
@@ -56,17 +58,47 @@ __decorate([
|
|
|
56
58
|
], ShellyNgDeviceEntity.prototype, "password", void 0);
|
|
57
59
|
__decorate([
|
|
58
60
|
(0, swagger_1.ApiPropertyOptional)({
|
|
59
|
-
description: '
|
|
61
|
+
description: 'Canonical MAC address from Shelly device info, used for deduplication of multi-interface devices',
|
|
62
|
+
name: 'canonical_mac',
|
|
60
63
|
type: 'string',
|
|
61
|
-
example: '
|
|
64
|
+
example: 'A8032ABE5084',
|
|
62
65
|
nullable: true,
|
|
63
66
|
}),
|
|
64
|
-
(0, class_transformer_1.Expose)(),
|
|
67
|
+
(0, class_transformer_1.Expose)({ name: 'canonical_mac' }),
|
|
65
68
|
(0, class_validator_1.IsOptional)(),
|
|
66
69
|
(0, class_validator_1.IsString)(),
|
|
67
|
-
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
70
|
+
(0, typeorm_1.Column)({ nullable: true, default: null, unique: true }),
|
|
68
71
|
__metadata("design:type", String)
|
|
69
|
-
], ShellyNgDeviceEntity.prototype, "
|
|
72
|
+
], ShellyNgDeviceEntity.prototype, "canonicalMac", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, swagger_1.ApiProperty)({
|
|
75
|
+
description: 'Whether the device has an Ethernet interface (Pro devices)',
|
|
76
|
+
name: 'has_ethernet',
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
example: false,
|
|
79
|
+
}),
|
|
80
|
+
(0, class_transformer_1.Expose)({ name: 'has_ethernet' }),
|
|
81
|
+
(0, class_validator_1.IsBoolean)(),
|
|
82
|
+
(0, typeorm_1.Column)({ type: 'boolean', default: false }),
|
|
83
|
+
__metadata("design:type", Boolean)
|
|
84
|
+
], ShellyNgDeviceEntity.prototype, "hasEthernet", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, class_transformer_1.Expose)({ name: 'wifi_address' }),
|
|
87
|
+
(0, class_validator_1.IsOptional)(),
|
|
88
|
+
(0, class_validator_1.IsString)(),
|
|
89
|
+
__metadata("design:type", String)
|
|
90
|
+
], ShellyNgDeviceEntity.prototype, "wifiAddress", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, class_transformer_1.Expose)({ name: 'ethernet_address' }),
|
|
93
|
+
(0, class_validator_1.IsOptional)(),
|
|
94
|
+
(0, class_validator_1.IsString)(),
|
|
95
|
+
__metadata("design:type", String)
|
|
96
|
+
], ShellyNgDeviceEntity.prototype, "ethernetAddress", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, class_transformer_1.Expose)(),
|
|
99
|
+
(0, typeorm_1.OneToMany)(() => shelly_ng_device_address_entity_1.ShellyNgDeviceAddressEntity, (addr) => addr.device, { eager: true }),
|
|
100
|
+
__metadata("design:type", Array)
|
|
101
|
+
], ShellyNgDeviceEntity.prototype, "addresses", void 0);
|
|
70
102
|
exports.ShellyNgDeviceEntity = ShellyNgDeviceEntity = __decorate([
|
|
71
103
|
(0, swagger_1.ApiSchema)({ name: 'DevicesShellyNgPluginDataDevice' }),
|
|
72
104
|
(0, typeorm_1.ChildEntity)()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devices-shelly-ng.entity.js","sourceRoot":"","sources":["../../../../src/plugins/devices-shelly-ng/entities/devices-shelly-ng.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"devices-shelly-ng.entity.js","sourceRoot":"","sources":["../../../../src/plugins/devices-shelly-ng/entities/devices-shelly-ng.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA2C;AAC3C,qDAAkE;AAClE,qCAAyD;AAEzD,6CAA8E;AAE9E,qFAAsH;AACtH,gFAAwE;AAExE,uFAAgF;AAIzE,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,6BAAY;IAA/C;;QAsBN,aAAQ,GAAkB,IAAI,CAAC;QAsB/B,iBAAY,GAAkB,IAAI,CAAC;QAWnC,gBAAW,GAAY,KAAK,CAAC;IAwB9B,CAAC;IA9EA,IAOI,IAAI;QACP,OAAO,oDAAsB,CAAC;IAC/B,CAAC;IAkED,QAAQ;QACP,OAAO,kBAAkB,IAAI,CAAC,UAAU,mBAAmB,IAAI,CAAC,EAAE,GAAG,CAAC;IACvE,CAAC;CACD,CAA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C;IAED,QAAQ;QACP,OAAO,+BAA+B,IAAI,CAAC,UAAU,6BAA6B,IAAI,CAAC,EAAE,GAAG,CAAC;IAC9F,CAAC;CACD,CAAA;AAfY,sEAA6B;AACzC;IAAC,IAAA,qBAAW,EAAC;QACZ,WAAW,EAAE,uBAAuB;QACpC,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,oDAAsB;QAC/B,OAAO,EAAE,oDAAsB;KAC/B,CAAC;IACD,IAAA,0BAAM,GAAE;;;yDAGR;wCAVW,6BAA6B;IAFzC,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,0CAA0C,EAAE,CAAC;IAC/D,IAAA,qBAAW,GAAE;GACD,6BAA6B,CAezC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseEntity } from '../../../common/entities/base.entity';
|
|
2
|
+
import { AddressType } from '../devices-shelly-ng.constants';
|
|
3
|
+
import { ShellyNgDeviceEntity } from './devices-shelly-ng.entity';
|
|
4
|
+
export declare class ShellyNgDeviceAddressEntity extends BaseEntity {
|
|
5
|
+
deviceId: string;
|
|
6
|
+
device: ShellyNgDeviceEntity;
|
|
7
|
+
interfaceType: AddressType;
|
|
8
|
+
address: string;
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ShellyNgDeviceAddressEntity = void 0;
|
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const typeorm_1 = require("typeorm");
|
|
16
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
17
|
+
const base_entity_1 = require("../../../common/entities/base.entity");
|
|
18
|
+
const devices_shelly_ng_constants_1 = require("../devices-shelly-ng.constants");
|
|
19
|
+
const devices_shelly_ng_entity_1 = require("./devices-shelly-ng.entity");
|
|
20
|
+
let ShellyNgDeviceAddressEntity = class ShellyNgDeviceAddressEntity extends base_entity_1.BaseEntity {
|
|
21
|
+
toString() {
|
|
22
|
+
return `Shelly Address [${this.interfaceType}:${this.address}] -> Device [${this.deviceId}]`;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.ShellyNgDeviceAddressEntity = ShellyNgDeviceAddressEntity;
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, swagger_1.ApiProperty)({
|
|
28
|
+
description: 'Device ID this address belongs to',
|
|
29
|
+
type: 'string',
|
|
30
|
+
format: 'uuid',
|
|
31
|
+
}),
|
|
32
|
+
(0, class_transformer_1.Expose)({ name: 'device_id' }),
|
|
33
|
+
(0, class_validator_1.IsString)(),
|
|
34
|
+
(0, typeorm_1.Column)({ type: 'varchar' }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], ShellyNgDeviceAddressEntity.prototype, "deviceId", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.ManyToOne)(() => devices_shelly_ng_entity_1.ShellyNgDeviceEntity, (device) => device.addresses, { onDelete: 'CASCADE' }),
|
|
39
|
+
(0, typeorm_1.JoinColumn)({ name: 'deviceId' }),
|
|
40
|
+
__metadata("design:type", devices_shelly_ng_entity_1.ShellyNgDeviceEntity)
|
|
41
|
+
], ShellyNgDeviceAddressEntity.prototype, "device", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, swagger_1.ApiProperty)({
|
|
44
|
+
description: 'Network interface type',
|
|
45
|
+
enum: devices_shelly_ng_constants_1.AddressType,
|
|
46
|
+
example: devices_shelly_ng_constants_1.AddressType.ETHERNET,
|
|
47
|
+
}),
|
|
48
|
+
(0, class_transformer_1.Expose)({ name: 'interface_type' }),
|
|
49
|
+
(0, class_validator_1.IsEnum)(devices_shelly_ng_constants_1.AddressType),
|
|
50
|
+
(0, typeorm_1.Column)({ type: 'varchar' }),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], ShellyNgDeviceAddressEntity.prototype, "interfaceType", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, swagger_1.ApiProperty)({
|
|
55
|
+
description: 'IP address of the device on this interface',
|
|
56
|
+
type: 'string',
|
|
57
|
+
example: '192.168.1.100',
|
|
58
|
+
}),
|
|
59
|
+
(0, class_transformer_1.Expose)(),
|
|
60
|
+
(0, class_validator_1.IsString)(),
|
|
61
|
+
(0, typeorm_1.Column)({ type: 'varchar' }),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], ShellyNgDeviceAddressEntity.prototype, "address", void 0);
|
|
64
|
+
exports.ShellyNgDeviceAddressEntity = ShellyNgDeviceAddressEntity = __decorate([
|
|
65
|
+
(0, swagger_1.ApiSchema)({ name: 'DevicesShellyNgPluginDataDeviceAddress' }),
|
|
66
|
+
(0, typeorm_1.Entity)('devices_shelly_ng_addresses'),
|
|
67
|
+
(0, typeorm_1.Unique)('UQ_shelly_ng_device_interface', ['deviceId', 'interfaceType'])
|
|
68
|
+
], ShellyNgDeviceAddressEntity);
|
|
69
|
+
//# sourceMappingURL=shelly-ng-device-address.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shelly-ng-device-address.entity.js","source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ARC,IAAA,qBAAW,EAAC;QACZ,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,eAAe;KACxB,CAAC;IACD,IAAA,0BAAM,GAAE;IACR,IAAA,0BAAQ,GAAE;IACV,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;4DACZ;sCAjCJ,2BAA2B;IAHvC,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,wCAAwC,EAAE,CAAC;IAC7D,IAAA,gBAAM,EAAC,6BAA6B,CAAC;IACrC,IAAA,gBAAM,EAAC,+BAA+B,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;GAC1D,2BAA2B,CAsCvC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { DeviceDiscoverer, DeviceIdentifiers } from 'shellies-ds9';
|
|
2
2
|
import { DevicesService } from '../../../modules/devices/services/devices.service';
|
|
3
|
+
import { DeviceAddressService } from './device-address.service';
|
|
3
4
|
export declare class DatabaseDiscovererService extends DeviceDiscoverer {
|
|
4
5
|
private readonly devicesService;
|
|
6
|
+
private readonly deviceAddressService;
|
|
5
7
|
private readonly logger;
|
|
6
8
|
private readonly emitInterval;
|
|
7
|
-
constructor(devicesService: DevicesService);
|
|
9
|
+
constructor(devicesService: DevicesService, deviceAddressService: DeviceAddressService);
|
|
8
10
|
run(): Promise<void>;
|
|
9
11
|
protected emitDevice(identifiers: DeviceIdentifiers): Promise<void>;
|
|
10
12
|
}
|
|
@@ -15,25 +15,36 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const logger_1 = require("../../../common/logger");
|
|
16
16
|
const devices_service_1 = require("../../../modules/devices/services/devices.service");
|
|
17
17
|
const devices_shelly_ng_constants_1 = require("../devices-shelly-ng.constants");
|
|
18
|
+
const device_address_service_1 = require("./device-address.service");
|
|
18
19
|
let DatabaseDiscovererService = class DatabaseDiscovererService extends shellies_ds9_1.DeviceDiscoverer {
|
|
19
|
-
constructor(devicesService) {
|
|
20
|
+
constructor(devicesService, deviceAddressService) {
|
|
20
21
|
super();
|
|
21
22
|
this.devicesService = devicesService;
|
|
23
|
+
this.deviceAddressService = deviceAddressService;
|
|
22
24
|
this.logger = (0, logger_1.createExtensionLogger)(devices_shelly_ng_constants_1.DEVICES_SHELLY_NG_PLUGIN_NAME, 'DatabaseDiscovererService');
|
|
23
25
|
this.emitInterval = 20;
|
|
24
26
|
}
|
|
25
27
|
async run() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const devices = await this.devicesService.findAll(devices_shelly_ng_constants_1.DEVICES_SHELLY_NG_TYPE);
|
|
29
|
+
const enabledDevices = devices.filter((d) => {
|
|
30
|
+
if (d.enabled === false)
|
|
31
|
+
return false;
|
|
30
32
|
if (d.identifier === null) {
|
|
31
33
|
this.logger.error(`Failed to prepare device to be managed by Shelly manager. Missing identifier for device=${d.id}`);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
|
+
const preferredAddresses = await this.deviceAddressService.getPreferredAddresses(enabledDevices.map((d) => d.id));
|
|
39
|
+
for (const d of enabledDevices) {
|
|
40
|
+
const hostname = preferredAddresses.get(d.id) ?? (await this.deviceAddressService.getPreferredAddressOrMigrate(d.id));
|
|
41
|
+
if (hostname === null) {
|
|
42
|
+
this.logger.warn(`No address found for device=${d.id}, skipping discovery emit`);
|
|
32
43
|
continue;
|
|
33
44
|
}
|
|
34
45
|
await this.emitDevice({
|
|
35
46
|
deviceId: d.identifier,
|
|
36
|
-
hostname
|
|
47
|
+
hostname,
|
|
37
48
|
});
|
|
38
49
|
}
|
|
39
50
|
}
|
|
@@ -49,6 +60,7 @@ let DatabaseDiscovererService = class DatabaseDiscovererService extends shellies
|
|
|
49
60
|
exports.DatabaseDiscovererService = DatabaseDiscovererService;
|
|
50
61
|
exports.DatabaseDiscovererService = DatabaseDiscovererService = __decorate([
|
|
51
62
|
(0, common_1.Injectable)(),
|
|
52
|
-
__metadata("design:paramtypes", [devices_service_1.DevicesService
|
|
63
|
+
__metadata("design:paramtypes", [devices_service_1.DevicesService,
|
|
64
|
+
device_address_service_1.DeviceAddressService])
|
|
53
65
|
], DatabaseDiscovererService);
|
|
54
66
|
//# sourceMappingURL=database-discoverer.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-discoverer.service.js","sourceRoot":"","sources":["../../../../src/plugins/devices-shelly-ng/services/database-discoverer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAmE;AAEnE,2CAA4C;AAE5C,mDAAuF;AACvF,uFAAmF;AACnF,gFAAuG;
|
|
1
|
+
{"version":3,"file":"database-discoverer.service.js","sourceRoot":"","sources":["../../../../src/plugins/devices-shelly-ng/services/database-discoverer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAmE;AAEnE,2CAA4C;AAE5C,mDAAuF;AACvF,uFAAmF;AACnF,gFAAuG;AAGvG,qEAAgE;AAGzD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,+BAAgB;IAQ9D,YACkB,cAA8B,EAC9B,oBAA0C;QAE3D,KAAK,EAAE,CAAC;QAHS,mBAAc,GAAd,cAAc,CAAgB;QAC9B,yBAAoB,GAApB,oBAAoB,CAAsB;QAT3C,WAAM,GAA2B,IAAA,8BAAqB,EACtE,2DAA6B,EAC7B,2BAA2B,CAC3B,CAAC;QAEe,iBAAY,GAAG,EAAE,CAAC;IAOnC,CAAC;IAED,KAAK,CAAC,GAAG;QACR,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAuB,oDAAsB,CAAC,CAAC;QAEhG,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;YAC3C,IAAI,CAAC,CAAC,OAAO,KAAK,KAAK;gBAAE,OAAO,KAAK,CAAC;YAEtC,IAAI,CAAC,CAAC,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CAAoB;GAVhD,yBAAyB,CAiErC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { AddressType } from '../devices-shelly-ng.constants';
|
|
3
|
+
import { ShellyNgDeviceEntity } from '../entities/devices-shelly-ng.entity';
|
|
4
|
+
import { ShellyNgDeviceAddressEntity } from '../entities/shelly-ng-device-address.entity';
|
|
5
|
+
export declare function normalizeMac(mac: string): string;
|
|
6
|
+
export declare class DeviceAddressService {
|
|
7
|
+
private readonly addressRepository;
|
|
8
|
+
private readonly deviceRepository;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
constructor(addressRepository: Repository<ShellyNgDeviceAddressEntity>, deviceRepository: Repository<ShellyNgDeviceEntity>);
|
|
11
|
+
upsertAddress(deviceId: string, interfaceType: AddressType, address: string): Promise<void>;
|
|
12
|
+
removeAddress(deviceId: string, interfaceType: AddressType): Promise<void>;
|
|
13
|
+
syncAddresses(deviceId: string, wifiIp: string | null, ethernetIp: string | null): Promise<void>;
|
|
14
|
+
getPreferredAddressOrMigrate(deviceId: string): Promise<string | null>;
|
|
15
|
+
getPreferredAddress(deviceId: string): Promise<string | null>;
|
|
16
|
+
getPreferredAddresses(deviceIds: string[]): Promise<Map<string, string>>;
|
|
17
|
+
getAddresses(deviceId: string): Promise<ShellyNgDeviceAddressEntity[]>;
|
|
18
|
+
findDeviceByCanonicalMac(canonicalMac: string): Promise<ShellyNgDeviceEntity | null>;
|
|
19
|
+
setCanonicalMac(deviceId: string, canonicalMac: string): Promise<void>;
|
|
20
|
+
setHasEthernet(deviceId: string, hasEthernet: boolean): Promise<void>;
|
|
21
|
+
getLegacyHostname(deviceId: string): Promise<string | null>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DeviceAddressService = void 0;
|
|
16
|
+
exports.normalizeMac = normalizeMac;
|
|
17
|
+
const typeorm_1 = require("typeorm");
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const typeorm_2 = require("@nestjs/typeorm");
|
|
20
|
+
const logger_1 = require("../../../common/logger");
|
|
21
|
+
const devices_shelly_ng_constants_1 = require("../devices-shelly-ng.constants");
|
|
22
|
+
const devices_shelly_ng_entity_1 = require("../entities/devices-shelly-ng.entity");
|
|
23
|
+
const shelly_ng_device_address_entity_1 = require("../entities/shelly-ng-device-address.entity");
|
|
24
|
+
function normalizeMac(mac) {
|
|
25
|
+
return mac.replace(/[:-]/g, '').toUpperCase();
|
|
26
|
+
}
|
|
27
|
+
let DeviceAddressService = class DeviceAddressService {
|
|
28
|
+
constructor(addressRepository, deviceRepository) {
|
|
29
|
+
this.addressRepository = addressRepository;
|
|
30
|
+
this.deviceRepository = deviceRepository;
|
|
31
|
+
this.logger = (0, logger_1.createExtensionLogger)(devices_shelly_ng_constants_1.DEVICES_SHELLY_NG_PLUGIN_NAME, 'DeviceAddressService');
|
|
32
|
+
}
|
|
33
|
+
async upsertAddress(deviceId, interfaceType, address) {
|
|
34
|
+
const existing = await this.addressRepository.findOne({
|
|
35
|
+
where: { deviceId, interfaceType },
|
|
36
|
+
});
|
|
37
|
+
if (existing) {
|
|
38
|
+
if (existing.address !== address) {
|
|
39
|
+
existing.address = address;
|
|
40
|
+
await this.addressRepository.save(existing);
|
|
41
|
+
this.logger.log(`Updated ${interfaceType} address to ${address} for device=${deviceId}`, {
|
|
42
|
+
resource: deviceId,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
try {
|
|
48
|
+
const entity = this.addressRepository.create({
|
|
49
|
+
deviceId,
|
|
50
|
+
interfaceType,
|
|
51
|
+
address,
|
|
52
|
+
});
|
|
53
|
+
await this.addressRepository.save(entity);
|
|
54
|
+
this.logger.log(`Stored ${interfaceType} address ${address} for device=${deviceId}`, {
|
|
55
|
+
resource: deviceId,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
await this.addressRepository.update({ deviceId, interfaceType }, { address });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async removeAddress(deviceId, interfaceType) {
|
|
64
|
+
const result = await this.addressRepository.delete({ deviceId, interfaceType });
|
|
65
|
+
if (result.affected) {
|
|
66
|
+
this.logger.log(`Removed ${interfaceType} address for device=${deviceId}`, { resource: deviceId });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async syncAddresses(deviceId, wifiIp, ethernetIp) {
|
|
70
|
+
if (ethernetIp) {
|
|
71
|
+
await this.upsertAddress(deviceId, devices_shelly_ng_constants_1.AddressType.ETHERNET, ethernetIp);
|
|
72
|
+
}
|
|
73
|
+
if (wifiIp) {
|
|
74
|
+
await this.upsertAddress(deviceId, devices_shelly_ng_constants_1.AddressType.WIFI, wifiIp);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async getPreferredAddressOrMigrate(deviceId) {
|
|
78
|
+
const preferred = await this.getPreferredAddress(deviceId);
|
|
79
|
+
if (preferred !== null) {
|
|
80
|
+
return preferred;
|
|
81
|
+
}
|
|
82
|
+
const legacyHostname = await this.getLegacyHostname(deviceId);
|
|
83
|
+
if (legacyHostname) {
|
|
84
|
+
await this.upsertAddress(deviceId, devices_shelly_ng_constants_1.AddressType.WIFI, legacyHostname);
|
|
85
|
+
this.logger.log(`Migrated legacy hostname=${legacyHostname} to address table for device=${deviceId}`, {
|
|
86
|
+
resource: deviceId,
|
|
87
|
+
});
|
|
88
|
+
return legacyHostname;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
async getPreferredAddress(deviceId) {
|
|
93
|
+
const addresses = await this.addressRepository.find({
|
|
94
|
+
where: { deviceId },
|
|
95
|
+
});
|
|
96
|
+
if (addresses.length === 0) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
addresses.sort((a, b) => (devices_shelly_ng_constants_1.ADDRESS_PRIORITY[a.interfaceType] ?? 99) - (devices_shelly_ng_constants_1.ADDRESS_PRIORITY[b.interfaceType] ?? 99));
|
|
100
|
+
return addresses[0].address;
|
|
101
|
+
}
|
|
102
|
+
async getPreferredAddresses(deviceIds) {
|
|
103
|
+
if (deviceIds.length === 0) {
|
|
104
|
+
return new Map();
|
|
105
|
+
}
|
|
106
|
+
const addresses = await this.addressRepository.find({
|
|
107
|
+
where: { deviceId: (0, typeorm_1.In)(deviceIds) },
|
|
108
|
+
});
|
|
109
|
+
const byDevice = new Map();
|
|
110
|
+
for (const addr of addresses) {
|
|
111
|
+
const list = byDevice.get(addr.deviceId) ?? [];
|
|
112
|
+
list.push(addr);
|
|
113
|
+
byDevice.set(addr.deviceId, list);
|
|
114
|
+
}
|
|
115
|
+
const result = new Map();
|
|
116
|
+
for (const [deviceId, addrs] of byDevice) {
|
|
117
|
+
addrs.sort((a, b) => (devices_shelly_ng_constants_1.ADDRESS_PRIORITY[a.interfaceType] ?? 99) - (devices_shelly_ng_constants_1.ADDRESS_PRIORITY[b.interfaceType] ?? 99));
|
|
118
|
+
result.set(deviceId, addrs[0].address);
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
async getAddresses(deviceId) {
|
|
123
|
+
return this.addressRepository.find({ where: { deviceId } });
|
|
124
|
+
}
|
|
125
|
+
async findDeviceByCanonicalMac(canonicalMac) {
|
|
126
|
+
return this.deviceRepository.findOne({
|
|
127
|
+
where: { canonicalMac: normalizeMac(canonicalMac) },
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async setCanonicalMac(deviceId, canonicalMac) {
|
|
131
|
+
await this.deviceRepository.update(deviceId, { canonicalMac: normalizeMac(canonicalMac) });
|
|
132
|
+
}
|
|
133
|
+
async setHasEthernet(deviceId, hasEthernet) {
|
|
134
|
+
await this.deviceRepository.update(deviceId, { hasEthernet });
|
|
135
|
+
}
|
|
136
|
+
async getLegacyHostname(deviceId) {
|
|
137
|
+
const result = await this.deviceRepository.query('SELECT "hostname" FROM "devices_module_devices" WHERE "id" = ?', [deviceId]);
|
|
138
|
+
return result[0]?.hostname ?? null;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
exports.DeviceAddressService = DeviceAddressService;
|
|
142
|
+
exports.DeviceAddressService = DeviceAddressService = __decorate([
|
|
143
|
+
(0, common_1.Injectable)(),
|
|
144
|
+
__param(0, (0, typeorm_2.InjectRepository)(shelly_ng_device_address_entity_1.ShellyNgDeviceAddressEntity)),
|
|
145
|
+
__param(1, (0, typeorm_2.InjectRepository)(devices_shelly_ng_entity_1.ShellyNgDeviceEntity)),
|
|
146
|
+
__metadata("design:paramtypes", [typeorm_1.Repository,
|
|
147
|
+
typeorm_1.Repository])
|
|
148
|
+
], DeviceAddressService);
|
|
149
|
+
//# sourceMappingURL=device-address.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-address.service.js","sourceRoot":"","sources":["../../../../src/plugins/devices-sh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AAC;IACJ,CAAC;IAKD,KAAK,CAAC,eAAe,CAAC,QAAgB,EAAE,YAAoB;QAC3D,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;IAMD,KAAK,CAAC,cAAc,CAAC,QAAgB,EAAE,WAAoB;QAC1D,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAC/D,CAAC;IAQD,KAAK,CAAC,iBAAiB,CAAC,QAAgB;QACvC,MAAM,MAAM,GAAkC,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAC9E,gEAAgE,EAChE,CAAC,QAAQ,CAAC,CACV,CAAC;QAEF,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,IAAI,IAAI,CAAC;IACpC,CAAC;CACD,CAAA;AA3MY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAQV,WAAA,IAAA,0BAAgB,EAAC,6DAA2B,CAAC,CAAA;IAE7C,WAAA,IAAA,0BAAgB,EAAC,+CAAoB,CAAC,CAAA;qCADH,oBAAU;QAEX,oBAAU;GAVlC,oBAAoB,CA2MhC"}
|
|
@@ -4,6 +4,7 @@ import { DeviceProvisionQueueService } from '../../../modules/devices/services/d
|
|
|
4
4
|
import { DevicesService } from '../../../modules/devices/services/devices.service';
|
|
5
5
|
import { ShellyNgDeviceEntity } from '../entities/devices-shelly-ng.entity';
|
|
6
6
|
import { MappingLoaderService, PropertyMappingStorageService, TransformerRegistry } from '../mappings';
|
|
7
|
+
import { DeviceAddressService } from './device-address.service';
|
|
7
8
|
import { ShellyRpcClientService } from './shelly-rpc-client.service';
|
|
8
9
|
export declare class DeviceManagerService {
|
|
9
10
|
private readonly shellyRpcClientService;
|
|
@@ -14,12 +15,13 @@ export declare class DeviceManagerService {
|
|
|
14
15
|
private readonly transformerRegistry;
|
|
15
16
|
private readonly propertyMappingStorage;
|
|
16
17
|
private readonly provisionQueue;
|
|
18
|
+
private readonly deviceAddressService;
|
|
17
19
|
private readonly logger;
|
|
18
20
|
private readonly defaultManager;
|
|
19
21
|
private readonly strictSchema;
|
|
20
22
|
private timeoutSec;
|
|
21
23
|
private rpcConcurrency;
|
|
22
|
-
constructor(shellyRpcClientService: ShellyRpcClientService, devicesService: DevicesService, channelsService: ChannelsService, channelsPropertiesService: ChannelsPropertiesService, mappingLoaderService: MappingLoaderService, transformerRegistry: TransformerRegistry, propertyMappingStorage: PropertyMappingStorageService, provisionQueue: DeviceProvisionQueueService);
|
|
24
|
+
constructor(shellyRpcClientService: ShellyRpcClientService, devicesService: DevicesService, channelsService: ChannelsService, channelsPropertiesService: ChannelsPropertiesService, mappingLoaderService: MappingLoaderService, transformerRegistry: TransformerRegistry, propertyMappingStorage: PropertyMappingStorageService, provisionQueue: DeviceProvisionQueueService, deviceAddressService: DeviceAddressService);
|
|
23
25
|
getDeviceInfo(hostname: string, password: string | undefined): Promise<{
|
|
24
26
|
id: string;
|
|
25
27
|
name: string | null | undefined;
|