iobroker.iot 4.0.1 → 4.0.2
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 +1 -1
- package/admin/assets/index-5zouxn2w.js +680 -0
- package/admin/index_m.html +1 -1
- package/admin/rules/assets/{ActionVisu-DE8dgNVF.js → ActionVisu-D9x2f6zu.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react__loadShare__-BKaC-p5K.js → ActionVisu__loadShare__react__loadShare__-Cg21Ef1U.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react_mf_2_dom__loadShare__-Bs1o8DtQ.js → ActionVisu__loadShare__react_mf_2_dom__loadShare__-B1zRWn0u.js} +2 -2
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-Cz053nO7.js +10 -0
- package/admin/rules/assets/bootstrap-BCFKIiwZ.js +1 -0
- package/admin/rules/assets/hostInit-hos3Txsy.js +1 -1
- package/admin/rules/assets/{index-DjPMvPni.js → index-CAAeiKCc.js} +2 -2
- package/admin/rules/assets/{index-CbxmbJvB.js → index-Duo7mFlZ.js} +2 -2
- package/admin/rules/assets/index-DwYdaT5M.js +1151 -0
- package/admin/rules/assets/{virtualExposes-BNZJTatg.js → virtualExposes-BqVak7rX.js} +2 -2
- package/admin/rules/customRuleBlocks.js +2 -2
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js +268 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +110 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +16 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js +68 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +25 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +37 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +32 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +29 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js +82 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +39 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js +47 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +36 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +57 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +57 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +12 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +16 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +127 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +18 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +38 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js +53 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +23 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js +37 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +34 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +18 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js +25 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +31 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +22 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +49 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +21 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +38 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +20 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +26 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js +148 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Blind.js +13 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Blind.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +17 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Control.js +321 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Control.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js +182 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js +127 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Door.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Door.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js +38 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js +208 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Light.js +47 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Light.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js +35 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js +17 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +26 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Slider.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Slider.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js +21 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js +21 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js +85 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +27 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js +116 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Window.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Window.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js +121 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Device.js +83 -0
- package/build-backend/lib/AlexaSmartHomeV3/Device.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/DeviceManager.js +392 -0
- package/build-backend/lib/AlexaSmartHomeV3/DeviceManager.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js +37 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +53 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/FileHelper.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/IotProxy.js +27 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/IotProxy.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Logger.js +93 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Logger.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +112 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Utils.js +625 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Utils.js.map +1 -0
- package/build-backend/lib/Utils.js +96 -0
- package/build-backend/lib/Utils.js.map +1 -0
- package/build-backend/lib/adminCommonSocket.js +715 -0
- package/build-backend/lib/adminCommonSocket.js.map +1 -0
- package/build-backend/lib/alexaCustom.js +542 -0
- package/build-backend/lib/alexaCustom.js.map +1 -0
- package/build-backend/lib/alexaSmartHomeV2.js +2788 -0
- package/build-backend/lib/alexaSmartHomeV3.js +97 -0
- package/build-backend/lib/alexaSmartHomeV3.js.map +1 -0
- package/build-backend/lib/alisa.js +2409 -0
- package/build-backend/lib/devices.js +23 -0
- package/build-backend/lib/devices.js.map +1 -0
- package/build-backend/lib/functions.js +24 -0
- package/build-backend/lib/functions.js.map +1 -0
- package/build-backend/lib/googleHome.js +3322 -0
- package/build-backend/lib/notifications.js +30 -0
- package/build-backend/lib/notifications.js.map +1 -0
- package/build-backend/lib/remote.js +1342 -0
- package/build-backend/lib/remote.js.map +1 -0
- package/build-backend/lib/rooms.js +48 -0
- package/build-backend/lib/rooms.js.map +1 -0
- package/build-backend/lib/texts.js +81 -0
- package/build-backend/lib/texts.js.map +1 -0
- package/build-backend/lib/translate.js +21 -0
- package/build-backend/lib/translate.js.map +1 -0
- package/build-backend/lib/visuApp.js +147 -0
- package/build-backend/lib/visuApp.js.map +1 -0
- package/build-backend/main.js +1361 -0
- package/build-backend/main.js.map +1 -0
- package/io-package.json +2 -2
- package/package.json +2 -2
- package/admin/assets/index-Y479CE6x.js +0 -681
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-DtUoI3FU.js +0 -5
- package/admin/rules/assets/bootstrap-Ba57tu25.js +0 -1
- package/admin/rules/assets/index-_Y2FN5EZ.js +0 -1152
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleSendToAdapter = handleSendToAdapter;
|
|
4
|
+
exports.handleGetInstances = handleGetInstances;
|
|
5
|
+
exports.handleGeofenceData = handleGeofenceData;
|
|
6
|
+
exports.handleDevicesData = handleDevicesData;
|
|
7
|
+
/**
|
|
8
|
+
* Handles `sendToAdapter` command
|
|
9
|
+
*
|
|
10
|
+
* @param visuData the data sent by the app
|
|
11
|
+
* @param adapter the adapter instance
|
|
12
|
+
*/
|
|
13
|
+
async function handleSendToAdapter(visuData, adapter) {
|
|
14
|
+
const { instance, message, data } = visuData;
|
|
15
|
+
const resp = await adapter.sendToAsync(instance, message, data, { timeout: 2_000 });
|
|
16
|
+
return { ...resp };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Handles `sendToAdapter` command
|
|
20
|
+
*
|
|
21
|
+
* @param visuData the data sent by the app
|
|
22
|
+
* @param adapter the adapter instance
|
|
23
|
+
*/
|
|
24
|
+
async function handleGetInstances(visuData, adapter) {
|
|
25
|
+
const { adapterName } = visuData;
|
|
26
|
+
const res = await adapter.getObjectViewAsync('system', 'instance', {
|
|
27
|
+
startkey: `system.adapter.${adapterName}.`,
|
|
28
|
+
endkey: `system.adapter.${adapterName}.\u9999`,
|
|
29
|
+
});
|
|
30
|
+
const instances = res.rows.map(item => item.id.substring('system.adapter.'.length));
|
|
31
|
+
return { instances };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Handle Geofence data update from app
|
|
35
|
+
*
|
|
36
|
+
* @param visuData the data sent by app
|
|
37
|
+
* @param adapter the adapter instance
|
|
38
|
+
*/
|
|
39
|
+
async function handleGeofenceData(visuData, adapter) {
|
|
40
|
+
await adapter.setObjectNotExistsAsync('app.geofence', {
|
|
41
|
+
type: 'folder',
|
|
42
|
+
common: {
|
|
43
|
+
name: 'Geofence',
|
|
44
|
+
desc: 'Collection of all the Geofence-locations managed by ioBroker Visu App',
|
|
45
|
+
},
|
|
46
|
+
native: {},
|
|
47
|
+
});
|
|
48
|
+
for (const [locationName, presenceStatus] of Object.entries(visuData.presence)) {
|
|
49
|
+
const id = `app.geofence.${locationName.replace(adapter.FORBIDDEN_CHARS, '_').replace(/\s|ä|ü|ö/g, '_')}`;
|
|
50
|
+
await adapter.setObjectNotExistsAsync(id, {
|
|
51
|
+
type: 'state',
|
|
52
|
+
common: {
|
|
53
|
+
name: locationName,
|
|
54
|
+
desc: `Geofence Status of ${locationName}`,
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
read: true,
|
|
57
|
+
write: false,
|
|
58
|
+
role: 'indicator',
|
|
59
|
+
},
|
|
60
|
+
native: {},
|
|
61
|
+
});
|
|
62
|
+
await adapter.setState(id, presenceStatus, true);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Map data name to state common */
|
|
66
|
+
const commonMapping = {
|
|
67
|
+
actionResponse: {
|
|
68
|
+
name: 'Action response for a notification',
|
|
69
|
+
desc: 'User clicked on a notification and this is the response from the app',
|
|
70
|
+
type: 'string',
|
|
71
|
+
read: true,
|
|
72
|
+
write: false,
|
|
73
|
+
role: 'text',
|
|
74
|
+
},
|
|
75
|
+
ssid: {
|
|
76
|
+
name: 'Current connected WiFi',
|
|
77
|
+
desc: 'Current connected WiFi network',
|
|
78
|
+
type: 'string',
|
|
79
|
+
read: true,
|
|
80
|
+
write: false,
|
|
81
|
+
role: 'text',
|
|
82
|
+
},
|
|
83
|
+
connectionType: {
|
|
84
|
+
name: 'Current connection type',
|
|
85
|
+
desc: 'Current connection type',
|
|
86
|
+
type: 'string',
|
|
87
|
+
read: true,
|
|
88
|
+
write: false,
|
|
89
|
+
role: 'text',
|
|
90
|
+
},
|
|
91
|
+
batteryLevel: {
|
|
92
|
+
name: 'Current battery level',
|
|
93
|
+
desc: 'Current battery level',
|
|
94
|
+
type: 'number',
|
|
95
|
+
read: true,
|
|
96
|
+
write: false,
|
|
97
|
+
role: 'level.battery',
|
|
98
|
+
unit: '%',
|
|
99
|
+
},
|
|
100
|
+
batteryState: {
|
|
101
|
+
name: 'Current battery state',
|
|
102
|
+
desc: 'Current battery state',
|
|
103
|
+
type: 'number',
|
|
104
|
+
read: true,
|
|
105
|
+
write: false,
|
|
106
|
+
role: 'value',
|
|
107
|
+
states: {
|
|
108
|
+
0: 'unknown',
|
|
109
|
+
1: 'unplugged',
|
|
110
|
+
2: 'charging',
|
|
111
|
+
3: 'full',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Handle device's data update from app
|
|
117
|
+
*
|
|
118
|
+
* @param visuData the data sent by app
|
|
119
|
+
* @param adapter the adapter instance
|
|
120
|
+
*/
|
|
121
|
+
async function handleDevicesData(visuData, adapter) {
|
|
122
|
+
// e.g. {"devices":{"iPhone":{"batteryLevel":95,"batteryState":2,"ssid":"FRITZ!Box Fon WLAN","connectionType":"wifi"}}}
|
|
123
|
+
for (const [deviceName, deviceData] of Object.entries(visuData.devices)) {
|
|
124
|
+
const deviceId = `app.devices.${deviceName.replace(adapter.FORBIDDEN_CHARS, '_').replace(/\s|ä|ü|ö/g, '_')}`;
|
|
125
|
+
await adapter.setObjectNotExistsAsync(deviceId, {
|
|
126
|
+
type: 'folder',
|
|
127
|
+
common: {
|
|
128
|
+
name: deviceName,
|
|
129
|
+
desc: 'All states related to this device',
|
|
130
|
+
},
|
|
131
|
+
native: {},
|
|
132
|
+
});
|
|
133
|
+
for (const [dataName, dataVal] of Object.entries(deviceData)) {
|
|
134
|
+
const id = `${deviceId}.${dataName}`;
|
|
135
|
+
if (!commonMapping[dataName]) {
|
|
136
|
+
adapter.log.warn(`Unknown device data "${dataName}" with value "${dataVal}"`);
|
|
137
|
+
}
|
|
138
|
+
await adapter.setObjectNotExistsAsync(id, {
|
|
139
|
+
type: 'state',
|
|
140
|
+
common: commonMapping[dataName],
|
|
141
|
+
native: {},
|
|
142
|
+
});
|
|
143
|
+
await adapter.setState(id, dataVal, true);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=visuApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visuApp.js","sourceRoot":"","sources":["../../src/lib/visuApp.ts"],"names":[],"mappings":";;AAOA,kDAQC;AAQD,gDAaC;AAQD,gDA+BC;AA2DD,8CAmCC;AAxKD;;;;;GAKG;AACI,KAAK,UAAU,mBAAmB,CACrC,QAAoF,EACpF,OAAmB;IAEnB,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;IAE7C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACpF,OAAO,EAAE,GAAG,IAAI,EAAyC,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,kBAAkB,CACpC,QAA0D,EAC1D,OAAmB;IAEnB,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;IAEjC,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,QAAQ,EAAE,UAAU,EAAE;QAC/D,QAAQ,EAAE,kBAAkB,WAAW,GAAG;QAC1C,MAAM,EAAE,kBAAkB,WAAW,SAAS;KACjD,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;IACpF,OAAO,EAAE,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AE,UAAU;gBAChB,IAAI,EAAE,mCAAmC;aAC5C;YACD,MAAM,EAAE,EAAE;SACb,CAAC,CAAC;QAEH,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3D,MAAM,EAAE,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;YAErC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,wBAAwB,QAAQ,iBAAiB,OAAO,GAAG,CAAC,CAAC;YAClF,CAAC;YAED,MAAM,OAAO,CAAC,uBAAuB,CAAC,EAAE,EAAE;gBACtC,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;gBAC/B,MAAM,EAAE,EAAE;aACb,CAAC,CAAC;YAEH,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;AACL,CAAC","sourcesContent":["import type { IotAdapter } from '../main';\n/**\n * Handles `sendToAdapter` command\n *\n * @param visuData the data sent by the app\n * @param adapter the adapter instance\n */\nexport async function handleSendToAdapter(\n visuData: { command: 'sendToAdapter'; instance: string; message: string; data: any },\n adapter: IotAdapter,\n): Promise<{ error?: string; result?: string }> {\n const { instance, message, data } = visuData;\n\n const resp = await adapter.sendToAsync(instance, message, data, { timeout: 2_000 });\n return { ...resp } as { error?: string; result?: string };\n}\n\n/**\n * Handles `sendToAdapter` command\n *\n * @param visuData the data sent by the app\n * @param adapter the adapter instance\n */\nexport async function handleGetInstances(\n visuData: { command: 'getInstances'; adapterName: string },\n adapter: IotAdapter,\n): Promise<{ instances: string[] }> {\n const { adapterName } = visuData;\n\n const res = await adapter.getObjectViewAsync('system', 'instance', {\n startkey: `system.adapter.${adapterName}.`,\n endkey: `system.adapter.${adapterName}.\\u9999`,\n });\n\n const instances = res.rows.map(item => item.id.substring('system.adapter.'.length));\n return { instances };\n}\n\n/**\n * Handle Geofence data update from app\n *\n * @param visuData the data sent by app\n * @param adapter the adapter instance\n */\nexport async function handleGeofenceData(\n visuData: { presence: Record<string, boolean>; devices?: Record<string, any> },\n adapter: IotAdapter,\n): Promise<void> {\n await adapter.setObjectNotExistsAsync('app.geofence', {\n type: 'folder',\n common: {\n name: 'Geofence',\n desc: 'Collection of all the Geofence-locations managed by ioBroker Visu App',\n },\n native: {},\n });\n\n for (const [locationName, presenceStatus] of Object.entries(visuData.presence)) {\n const id = `app.geofence.${locationName.replace(adapter.FORBIDDEN_CHARS, '_').replace(/\\s|ä|ü|ö/g, '_')}`;\n\n await adapter.setObjectNotExistsAsync(id, {\n type: 'state',\n common: {\n name: locationName,\n desc: `Geofence Status of ${locationName}`,\n type: 'boolean',\n read: true,\n write: false,\n role: 'indicator',\n },\n native: {},\n });\n\n await adapter.setState(id, presenceStatus, true);\n }\n}\n\n/** Map data name to state common */\nconst commonMapping: Record<string, ioBroker.StateCommon> = {\n actionResponse: {\n name: 'Action response for a notification',\n desc: 'User clicked on a notification and this is the response from the app',\n type: 'string',\n read: true,\n write: false,\n role: 'text',\n },\n ssid: {\n name: 'Current connected WiFi',\n desc: 'Current connected WiFi network',\n type: 'string',\n read: true,\n write: false,\n role: 'text',\n },\n connectionType: {\n name: 'Current connection type',\n desc: 'Current connection type',\n type: 'string',\n read: true,\n write: false,\n role: 'text',\n },\n batteryLevel: {\n name: 'Current battery level',\n desc: 'Current battery level',\n type: 'number',\n read: true,\n write: false,\n role: 'level.battery',\n unit: '%',\n },\n batteryState: {\n name: 'Current battery state',\n desc: 'Current battery state',\n type: 'number',\n read: true,\n write: false,\n role: 'value',\n states: {\n 0: 'unknown',\n 1: 'unplugged',\n 2: 'charging',\n 3: 'full',\n },\n },\n};\n\n/**\n * Handle device's data update from app\n *\n * @param visuData the data sent by app\n * @param adapter the adapter instance\n */\nexport async function handleDevicesData(\n visuData: {\n presence?: Record<string, boolean>;\n devices: { [deviceId: string]: { [dataName: string]: ioBroker.StateValue } };\n },\n adapter: IotAdapter,\n): Promise<void> {\n // e.g. {\"devices\":{\"iPhone\":{\"batteryLevel\":95,\"batteryState\":2,\"ssid\":\"FRITZ!Box Fon WLAN\",\"connectionType\":\"wifi\"}}}\n for (const [deviceName, deviceData] of Object.entries(visuData.devices)) {\n const deviceId = `app.devices.${deviceName.replace(adapter.FORBIDDEN_CHARS, '_').replace(/\\s|ä|ü|ö/g, '_')}`;\n await adapter.setObjectNotExistsAsync(deviceId, {\n type: 'folder',\n common: {\n name: deviceName,\n desc: 'All states related to this device',\n },\n native: {},\n });\n\n for (const [dataName, dataVal] of Object.entries(deviceData)) {\n const id = `${deviceId}.${dataName}`;\n\n if (!commonMapping[dataName]) {\n adapter.log.warn(`Unknown device data \"${dataName}\" with value \"${dataVal}\"`);\n }\n\n await adapter.setObjectNotExistsAsync(id, {\n type: 'state',\n common: commonMapping[dataName],\n native: {},\n });\n\n await adapter.setState(id, dataVal, true);\n }\n }\n}\n"]}
|