hoffmation-base 3.0.0-alpha.61 → 3.0.0-alpha.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/lib/server/devices/IoBrokerDeviceInfo.d.ts +7 -5
  2. package/lib/server/devices/IoBrokerDeviceInfo.js +49 -47
  3. package/lib/server/devices/device-cluster.js +1 -0
  4. package/lib/server/devices/deviceType.d.ts +3 -0
  5. package/lib/server/devices/deviceType.js +3 -0
  6. package/lib/server/devices/deviceUpdater.js +11 -0
  7. package/lib/server/devices/devices.d.ts +5 -0
  8. package/lib/server/devices/devices.js +18 -8
  9. package/lib/server/devices/index.d.ts +2 -0
  10. package/lib/server/devices/index.js +2 -0
  11. package/lib/server/devices/smartGarden/SmartGardenDeviceRegistrationInfo.d.ts +9 -0
  12. package/lib/server/devices/smartGarden/SmartGardenDeviceRegistrationInfo.js +13 -0
  13. package/lib/server/devices/smartGarden/SmartGardenService.d.ts +7 -0
  14. package/lib/server/devices/smartGarden/SmartGardenService.js +52 -0
  15. package/lib/server/devices/smartGarden/index.d.ts +2 -0
  16. package/lib/server/devices/smartGarden/index.js +18 -0
  17. package/lib/server/devices/smartGarden/smartGardenDevice.d.ts +33 -0
  18. package/lib/server/devices/smartGarden/smartGardenDevice.js +98 -0
  19. package/lib/server/devices/smartGarden/smartGardenMower.d.ts +35 -0
  20. package/lib/server/devices/smartGarden/smartGardenMower.js +107 -0
  21. package/lib/server/devices/smartGarden/smartGardenSensor.d.ts +43 -0
  22. package/lib/server/devices/smartGarden/smartGardenSensor.js +119 -0
  23. package/lib/server/devices/smartGarden/smartGardenValve.d.ts +36 -0
  24. package/lib/server/devices/smartGarden/smartGardenValve.js +105 -0
  25. package/lib/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +1 -1
@@ -6,17 +6,19 @@ export declare class IoBrokerDeviceInfo extends DeviceInfo {
6
6
  deviceRoomIndex: number;
7
7
  type: 'device' | 'channel' | 'state';
8
8
  fullID: string;
9
- channel?: number;
10
- valueName?: string;
11
9
  devConf: deviceConfig;
12
10
  static idSplitter(id: string): string[];
13
11
  private static replaceInvalidIdChars;
14
12
  /**
15
13
  * Extracts the relevant infos from the passed deviceConfig and combines them in a new Info object
16
14
  * @param pDevConf - The device Config based on the extracted devices.json from ioBroker
17
- * @param isJsStateChildObject - Within JS Objects, creating devices is limited,
18
- * so we name the first child state for the object creation (e.g. javascript.0.00-EnergyManager.CurrentProduction)
15
+ * @param deviceId - The id of the device
16
+ * @param deviceType - The type of the device
17
+ * @param room - The room id of the device
18
+ * @param deviceRoomIndex - Index of this device in regards to the devicetype.
19
19
  */
20
- constructor(pDevConf: deviceConfig, isJsStateChildObject?: boolean);
20
+ constructor(pDevConf: deviceConfig, deviceId: string, deviceType: string, room: string, deviceRoomIndex: number);
21
+ static byStateJsSplit(pDevConf: deviceConfig): IoBrokerDeviceInfo;
22
+ static byDeviceConfig(pDevConf: deviceConfig): IoBrokerDeviceInfo;
21
23
  toJSON(): Partial<IoBrokerDeviceInfo>;
22
24
  }
@@ -20,60 +20,62 @@ class IoBrokerDeviceInfo extends DeviceInfo_1.DeviceInfo {
20
20
  /**
21
21
  * Extracts the relevant infos from the passed deviceConfig and combines them in a new Info object
22
22
  * @param pDevConf - The device Config based on the extracted devices.json from ioBroker
23
- * @param isJsStateChildObject - Within JS Objects, creating devices is limited,
24
- * so we name the first child state for the object creation (e.g. javascript.0.00-EnergyManager.CurrentProduction)
23
+ * @param deviceId - The id of the device
24
+ * @param deviceType - The type of the device
25
+ * @param room - The room id of the device
26
+ * @param deviceRoomIndex - Index of this device in regards to the devicetype.
25
27
  */
26
- constructor(pDevConf, isJsStateChildObject = false) {
28
+ constructor(pDevConf, deviceId, deviceType, room, deviceRoomIndex) {
27
29
  super();
28
30
  this.devConf = pDevConf;
29
31
  this.type = pDevConf.type;
30
- const idSplit = IoBrokerDeviceInfo.idSplitter(pDevConf._id);
31
32
  this.fullID = pDevConf._id;
32
- this.devID = idSplit[2];
33
+ this.devID = deviceId;
33
34
  this.fullName = pDevConf.common.name;
35
+ this.deviceType = deviceType;
36
+ this.deviceRoomIndex = deviceRoomIndex;
37
+ this.room = room;
38
+ }
39
+ static byStateJsSplit(pDevConf) {
34
40
  const nameSplit = pDevConf.common.name.split('-');
35
- if (!isJsStateChildObject) {
36
- /**
37
- * 0: hm-rpc
38
- * 1: rcpInstance
39
- * 2: Device ID
40
- * 3?: Channel
41
- * 4?: ValueName
42
- */
43
- if (idSplit.length > 3) {
44
- this.channel = Number(idSplit[3]);
45
- }
46
- if (idSplit.length > 4) {
47
- this.valueName = idSplit[4];
48
- }
49
- /**
50
- * Name-Split
51
- * 0: Indikator own "00"
52
- * 1: "HmIP"
53
- * 2: Raum
54
- * 3: Was für ein Gerät
55
- * 4: Index dieses Gerätes im Raum (ggf. + :Channel)
56
- * 5?: Name des Wertes
57
- */
58
- this.room = nameSplit[2];
59
- this.deviceType = nameSplit[3];
60
- this.deviceRoomIndex = Number(nameSplit[4].split(':')[0]);
61
- return;
62
- }
63
- else {
64
- /**
65
- * Name-Split
66
- * 0: Indikator own "00"
67
- * 1: "EnergyManager"
68
- * 2: Raum
69
- * 3: Was für ein Gerät
70
- * 4: Index dieses Gerätes im Raum (ggf. + :Channel)
71
- * 5?: Name des Wertes
72
- */
73
- this.deviceType = nameSplit[1];
74
- this.room = nameSplit.length >= 3 ? nameSplit[2] : '';
75
- this.deviceRoomIndex = nameSplit.length >= 4 ? Number(nameSplit[3]) : 0;
76
- }
41
+ const idSplit = IoBrokerDeviceInfo.idSplitter(pDevConf._id);
42
+ /**
43
+ * Name-Split
44
+ * 0: Indikator own "00"
45
+ * 1: "EnergyManager"
46
+ * 2: Raum
47
+ * 3: Was für ein Gerät
48
+ * 4: Index dieses Gerätes im Raum (ggf. + :Channel)
49
+ * 5?: Name des Wertes
50
+ */
51
+ const deviceType = nameSplit[1];
52
+ const room = nameSplit.length >= 3 ? nameSplit[2] : '';
53
+ const deviceRoomIndex = nameSplit.length >= 4 ? Number(nameSplit[3]) : 0;
54
+ return new IoBrokerDeviceInfo(pDevConf, idSplit[2], deviceType, room, deviceRoomIndex);
55
+ }
56
+ static byDeviceConfig(pDevConf) {
57
+ const nameSplit = pDevConf.common.name.split('-');
58
+ const idSplit = IoBrokerDeviceInfo.idSplitter(pDevConf._id);
59
+ /**
60
+ * 0: hm-rpc
61
+ * 1: rcpInstance
62
+ * 2: Device ID
63
+ * 3?: Channel
64
+ * 4?: ValueName
65
+ */
66
+ /**
67
+ * Name-Split
68
+ * 0: Indikator own "00"
69
+ * 1: "HmIP"
70
+ * 2: Raum
71
+ * 3: Was für ein Gerät
72
+ * 4: Index dieses Gerätes im Raum (ggf. + : Channel)
73
+ * 5?: Name des Wertes
74
+ */
75
+ const room = nameSplit[2];
76
+ const deviceType = nameSplit[3];
77
+ const deviceRoomIndex = Number(nameSplit[4].split(':')[0]);
78
+ return new IoBrokerDeviceInfo(pDevConf, idSplit[2], deviceType, room, deviceRoomIndex);
77
79
  }
78
80
  toJSON() {
79
81
  return lodash_1.default.omit(this, ['devConf']);
@@ -54,6 +54,7 @@ class DeviceCluster {
54
54
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.Shutter);
55
55
  break;
56
56
  case deviceType_1.DeviceType.ZigbeeSonoffTemp:
57
+ case deviceType_1.DeviceType.SmartGardenSensor:
57
58
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.TemperaturSensor);
58
59
  clusterTypes.push(device_cluster_type_1.DeviceClusterType.HumiditySensor);
59
60
  break;
@@ -43,6 +43,9 @@ export declare enum DeviceType {
43
43
  ShellyTrv = 402,
44
44
  ShellyActuator = 403,
45
45
  TuyaGarageDoorOpener = 501,
46
+ SmartGardenValve = 601,
47
+ SmartGardenMower = 602,
48
+ SmartGardenSensor = 603,
46
49
  WledDevice = 1001,
47
50
  GoveeLed = 1002,
48
51
  Daikin = 2001,
@@ -47,6 +47,9 @@ var DeviceType;
47
47
  DeviceType[DeviceType["ShellyTrv"] = 402] = "ShellyTrv";
48
48
  DeviceType[DeviceType["ShellyActuator"] = 403] = "ShellyActuator";
49
49
  DeviceType[DeviceType["TuyaGarageDoorOpener"] = 501] = "TuyaGarageDoorOpener";
50
+ DeviceType[DeviceType["SmartGardenValve"] = 601] = "SmartGardenValve";
51
+ DeviceType[DeviceType["SmartGardenMower"] = 602] = "SmartGardenMower";
52
+ DeviceType[DeviceType["SmartGardenSensor"] = 603] = "SmartGardenSensor";
50
53
  DeviceType[DeviceType["WledDevice"] = 1001] = "WledDevice";
51
54
  DeviceType[DeviceType["GoveeLed"] = 1002] = "GoveeLed";
52
55
  DeviceType[DeviceType["Daikin"] = 2001] = "Daikin";
@@ -37,6 +37,17 @@ class DeviceUpdater {
37
37
  classifier = devices_1.Devices.IDENTIFIER_ZIGBEE;
38
38
  devId = idSplit[2].substring(2);
39
39
  }
40
+ else if (idSplit[0] == devices_1.Devices.IDENTIFIER_SMART_GARDEN) {
41
+ if (idSplit[1] === 'admin' ||
42
+ idSplit[2].indexOf('LOCATION') !== 0 ||
43
+ idSplit.length < 4 ||
44
+ idSplit[3].indexOf('DEVICE') !== 0) {
45
+ // This is no update for a smartgarden device
46
+ return;
47
+ }
48
+ classifier = devices_1.Devices.IDENTIFIER_SMART_GARDEN;
49
+ devId = idSplit[3];
50
+ }
40
51
  const device = services_1.API.getDevice(`${classifier}-${devId}`, false);
41
52
  if (typeof device === 'undefined' || device.update === undefined) {
42
53
  return;
@@ -31,6 +31,10 @@ export declare class Devices {
31
31
  * A constant for the identifier of WLED Adapter devices
32
32
  */
33
33
  static readonly IDENTIFIER_WLED: string;
34
+ /**
35
+ * A constant for the identifier of SmartGarden devices.
36
+ */
37
+ static readonly IDENTIFIER_SMART_GARDEN: string;
34
38
  /**
35
39
  * A Map containing all devices
36
40
  */
@@ -61,6 +65,7 @@ export declare class Devices {
61
65
  private static processShellyDevice;
62
66
  private static processTuyaDevice;
63
67
  private static processZigbeeDevice;
68
+ private static processSmartGardenDevice;
64
69
  private static processWledDevice;
65
70
  private static processHMIPDevice;
66
71
  private static createEnergyManager;
@@ -12,7 +12,7 @@ const wledDevice_1 = require("./wledDevice");
12
12
  const DeviceCapability_1 = require("./DeviceCapability");
13
13
  const shelly_1 = require("./shelly");
14
14
  const tuya_1 = require("./tuya");
15
- const shellyActuator_1 = require("./shelly/shellyActuator");
15
+ const smartGarden_1 = require("./smartGarden");
16
16
  class Devices {
17
17
  constructor(pDeviceData, pRoomImportEnforcer, config) {
18
18
  var _a;
@@ -44,6 +44,9 @@ class Devices {
44
44
  else if (cName.indexOf('00-Tuya') === 0) {
45
45
  Devices.processTuyaDevice(cDevConf);
46
46
  }
47
+ else if (cDevConf.type === 'device' && cName.indexOf('DEVICE_') === 0 && cID.indexOf('smartgarden') === 0) {
48
+ Devices.processSmartGardenDevice(cDevConf);
49
+ }
47
50
  else if (cName.indexOf('00-EnergyManager') === 0 &&
48
51
  cDevConf.type !== 'folder' &&
49
52
  !((_a = config === null || config === void 0 ? void 0 : config.energyManager) === null || _a === void 0 ? void 0 : _a.disableJsEnergyManager)) {
@@ -93,7 +96,7 @@ class Devices {
93
96
  return result.join('\n');
94
97
  }
95
98
  static processShellyDevice(cDevConf) {
96
- const shellyInfo = new IoBrokerDeviceInfo_1.IoBrokerDeviceInfo(cDevConf);
99
+ const shellyInfo = IoBrokerDeviceInfo_1.IoBrokerDeviceInfo.byDeviceConfig(cDevConf);
97
100
  const fullName = `${Devices.IDENTIFIER_Shelly}-${shellyInfo.devID}`;
98
101
  shellyInfo.allDevicesKey = fullName;
99
102
  if (typeof Devices.alLDevices[fullName] !== 'undefined') {
@@ -106,7 +109,7 @@ class Devices {
106
109
  d = new shelly_1.ShellyTrv(shellyInfo);
107
110
  break;
108
111
  case 'Actuator':
109
- d = new shellyActuator_1.ShellyActuator(shellyInfo);
112
+ d = new shelly_1.ShellyActuator(shellyInfo);
110
113
  break;
111
114
  default:
112
115
  services_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `No shelly Device Type for ${shellyInfo.deviceType} defined`);
@@ -115,7 +118,7 @@ class Devices {
115
118
  Devices.alLDevices[fullName] = d;
116
119
  }
117
120
  static processTuyaDevice(cDevConf) {
118
- const tuyaInfo = new IoBrokerDeviceInfo_1.IoBrokerDeviceInfo(cDevConf);
121
+ const tuyaInfo = IoBrokerDeviceInfo_1.IoBrokerDeviceInfo.byDeviceConfig(cDevConf);
119
122
  const fullName = `${Devices.IDENTIFIER_TUYA}-${tuyaInfo.devID}`;
120
123
  tuyaInfo.allDevicesKey = fullName;
121
124
  if (typeof Devices.alLDevices[fullName] !== 'undefined') {
@@ -134,7 +137,7 @@ class Devices {
134
137
  Devices.alLDevices[fullName] = d;
135
138
  }
136
139
  static processZigbeeDevice(cDevConf) {
137
- const zigbeeInfo = new IoBrokerDeviceInfo_1.IoBrokerDeviceInfo(cDevConf);
140
+ const zigbeeInfo = IoBrokerDeviceInfo_1.IoBrokerDeviceInfo.byDeviceConfig(cDevConf);
138
141
  const apiDevId = zigbeeInfo.devID.startsWith('0x') ? zigbeeInfo.devID.substring(2) : zigbeeInfo.devID;
139
142
  const fullName = `zigbee-${apiDevId}`;
140
143
  zigbeeInfo.allDevicesKey = fullName;
@@ -225,8 +228,11 @@ class Devices {
225
228
  }
226
229
  Devices.alLDevices[fullName] = d;
227
230
  }
231
+ static processSmartGardenDevice(cDevConf) {
232
+ smartGarden_1.SmartGardenService.processSmartGardenDevice(cDevConf);
233
+ }
228
234
  static processWledDevice(cDevConf) {
229
- const wledIoBrokerDeviceInfo = new IoBrokerDeviceInfo_1.IoBrokerDeviceInfo(cDevConf);
235
+ const wledIoBrokerDeviceInfo = IoBrokerDeviceInfo_1.IoBrokerDeviceInfo.byDeviceConfig(cDevConf);
230
236
  const fullName = `${Devices.IDENTIFIER_WLED}-${wledIoBrokerDeviceInfo.devID}`;
231
237
  wledIoBrokerDeviceInfo.allDevicesKey = fullName;
232
238
  if (typeof Devices.alLDevices[fullName] !== 'undefined') {
@@ -236,7 +242,7 @@ class Devices {
236
242
  Devices.alLDevices[fullName] = new wledDevice_1.WledDevice(wledIoBrokerDeviceInfo);
237
243
  }
238
244
  static processHMIPDevice(cDevConf) {
239
- const hmIPInfo = new IoBrokerDeviceInfo_1.IoBrokerDeviceInfo(cDevConf);
245
+ const hmIPInfo = IoBrokerDeviceInfo_1.IoBrokerDeviceInfo.byDeviceConfig(cDevConf);
240
246
  const fullName = `${Devices.IDENTIFIER_HOMEMATIC}-${hmIPInfo.devID}`;
241
247
  hmIPInfo.allDevicesKey = fullName;
242
248
  if (typeof Devices.alLDevices[fullName] !== 'undefined') {
@@ -292,7 +298,7 @@ class Devices {
292
298
  if (Devices.energymanager !== undefined) {
293
299
  return;
294
300
  }
295
- const devInfo = new IoBrokerDeviceInfo_1.IoBrokerDeviceInfo(cDevConf, true);
301
+ const devInfo = IoBrokerDeviceInfo_1.IoBrokerDeviceInfo.byStateJsSplit(cDevConf);
296
302
  const fullName = `${Devices.IDENTIFIER_JS}-${devInfo.devID}`;
297
303
  devInfo.allDevicesKey = fullName;
298
304
  Devices.energymanager = new jsObject_1.JsObjectEnergyManager(devInfo);
@@ -328,6 +334,10 @@ Devices.IDENTIFIER_ZIGBEE2MQTT = 'zigbee2mqtt';
328
334
  * A constant for the identifier of WLED Adapter devices
329
335
  */
330
336
  Devices.IDENTIFIER_WLED = 'wled';
337
+ /**
338
+ * A constant for the identifier of SmartGarden devices.
339
+ */
340
+ Devices.IDENTIFIER_SMART_GARDEN = 'smartgarden';
331
341
  /**
332
342
  * A Map containing all devices
333
343
  */
@@ -1,6 +1,7 @@
1
1
  export * from './baseDeviceInterfaces/index';
2
2
  export * from './blueIris/index';
3
3
  export * from './button/index';
4
+ export * from './dachs/index';
4
5
  export * from './espresense/index';
5
6
  export * from './groups/index';
6
7
  export * from './hmIPDevices/index';
@@ -9,6 +10,7 @@ export * from './models/index';
9
10
  export * from './scene/index';
10
11
  export * from './sharedFunctions/index';
11
12
  export * from './shelly/index';
13
+ export * from './smartGarden/index';
12
14
  export * from './tuya/index';
13
15
  export * from './tv/index';
14
16
  export * from './zigbee/index';
@@ -18,6 +18,7 @@ exports.NameAmountValuePair = exports.DeviceCapability = void 0;
18
18
  __exportStar(require("./baseDeviceInterfaces/index"), exports);
19
19
  __exportStar(require("./blueIris/index"), exports);
20
20
  __exportStar(require("./button/index"), exports);
21
+ __exportStar(require("./dachs/index"), exports);
21
22
  __exportStar(require("./espresense/index"), exports);
22
23
  __exportStar(require("./groups/index"), exports);
23
24
  __exportStar(require("./hmIPDevices/index"), exports);
@@ -26,6 +27,7 @@ __exportStar(require("./models/index"), exports);
26
27
  __exportStar(require("./scene/index"), exports);
27
28
  __exportStar(require("./sharedFunctions/index"), exports);
28
29
  __exportStar(require("./shelly/index"), exports);
30
+ __exportStar(require("./smartGarden/index"), exports);
29
31
  __exportStar(require("./tuya/index"), exports);
30
32
  __exportStar(require("./tv/index"), exports);
31
33
  __exportStar(require("./zigbee/index"), exports);
@@ -0,0 +1,9 @@
1
+ import { DeviceType } from '../deviceType';
2
+ export declare class SmartGardenDeviceRegistrationInfo {
3
+ readonly deviceType: DeviceType;
4
+ readonly deviceId: string;
5
+ readonly deviceName: string;
6
+ readonly room: string;
7
+ readonly roomIndex: number;
8
+ constructor(deviceType: DeviceType, deviceId: string, deviceName: string, room: string, roomIndex: number);
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartGardenDeviceRegistrationInfo = void 0;
4
+ class SmartGardenDeviceRegistrationInfo {
5
+ constructor(deviceType, deviceId, deviceName, room, roomIndex) {
6
+ this.deviceType = deviceType;
7
+ this.deviceId = deviceId;
8
+ this.deviceName = deviceName;
9
+ this.room = room;
10
+ this.roomIndex = roomIndex;
11
+ }
12
+ }
13
+ exports.SmartGardenDeviceRegistrationInfo = SmartGardenDeviceRegistrationInfo;
@@ -0,0 +1,7 @@
1
+ import { SmartGardenDeviceRegistrationInfo } from './SmartGardenDeviceRegistrationInfo';
2
+ import { deviceConfig } from '../../../models';
3
+ export declare class SmartGardenService {
4
+ private static readonly _registeredDevices;
5
+ static preRegisterDevice(id: string, registrationInfo: SmartGardenDeviceRegistrationInfo): void;
6
+ static processSmartGardenDevice(cDevConf: deviceConfig): void;
7
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartGardenService = void 0;
4
+ const models_1 = require("../../../models");
5
+ const services_1 = require("../../services");
6
+ const IoBrokerDeviceInfo_1 = require("../IoBrokerDeviceInfo");
7
+ const deviceType_1 = require("../deviceType");
8
+ const devices_1 = require("../devices");
9
+ const smartGardenSensor_1 = require("./smartGardenSensor");
10
+ const smartGardenMower_1 = require("./smartGardenMower");
11
+ const smartGardenValve_1 = require("./smartGardenValve");
12
+ class SmartGardenService {
13
+ static preRegisterDevice(id, registrationInfo) {
14
+ this._registeredDevices.set(id, registrationInfo);
15
+ }
16
+ static processSmartGardenDevice(cDevConf) {
17
+ var _a;
18
+ const devName = (_a = cDevConf.common) === null || _a === void 0 ? void 0 : _a.name;
19
+ if (!devName || typeof devName !== 'string') {
20
+ return;
21
+ }
22
+ const registrationInfo = this._registeredDevices.get(devName);
23
+ if (!registrationInfo) {
24
+ services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `SmartGarden Device ${devName} not registered`);
25
+ return;
26
+ }
27
+ const ioBrokerDeviceInfo = new IoBrokerDeviceInfo_1.IoBrokerDeviceInfo(cDevConf, registrationInfo.deviceId, deviceType_1.DeviceType[registrationInfo.deviceType], registrationInfo.room, registrationInfo.roomIndex);
28
+ const fullName = `${devices_1.Devices.IDENTIFIER_SMART_GARDEN}-${ioBrokerDeviceInfo.devID}`;
29
+ if (typeof devices_1.Devices.alLDevices[fullName] !== 'undefined') {
30
+ return;
31
+ }
32
+ ioBrokerDeviceInfo.allDevicesKey = fullName;
33
+ let d;
34
+ switch (registrationInfo.deviceType) {
35
+ case deviceType_1.DeviceType.SmartGardenSensor:
36
+ d = new smartGardenSensor_1.SmartGardenSensor(ioBrokerDeviceInfo);
37
+ break;
38
+ case deviceType_1.DeviceType.SmartGardenMower:
39
+ d = new smartGardenMower_1.SmartGardenMower(ioBrokerDeviceInfo);
40
+ break;
41
+ case deviceType_1.DeviceType.SmartGardenValve:
42
+ d = new smartGardenValve_1.SmartGardenValve(ioBrokerDeviceInfo);
43
+ break;
44
+ default:
45
+ services_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `No SmartGarden Device Type for ${registrationInfo.deviceType} defined`);
46
+ return;
47
+ }
48
+ devices_1.Devices.alLDevices[fullName] = d;
49
+ }
50
+ }
51
+ exports.SmartGardenService = SmartGardenService;
52
+ SmartGardenService._registeredDevices = new Map();
@@ -0,0 +1,2 @@
1
+ export * from './SmartGardenService';
2
+ export * from './SmartGardenDeviceRegistrationInfo';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./SmartGardenService"), exports);
18
+ __exportStar(require("./SmartGardenDeviceRegistrationInfo"), exports);
@@ -0,0 +1,33 @@
1
+ import { IoBrokerBaseDevice } from '../IoBrokerBaseDevice';
2
+ import { iDisposable } from '../../services';
3
+ import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
4
+ import { DeviceType } from '../deviceType';
5
+ import { BatteryLevelChangeAction } from '../../../models';
6
+ import { iBatteryDevice } from '../baseDeviceInterfaces';
7
+ export declare class SmartGardenDevice extends IoBrokerBaseDevice implements iDisposable, iBatteryDevice {
8
+ protected _criticalBatteryLevel: number;
9
+ protected readonly _deviceSerial: string;
10
+ private _lastUpdate;
11
+ private _lastBatteryLevel;
12
+ private _batteryLevelCallbacks;
13
+ private _lastBatteryPersist;
14
+ private _battery;
15
+ constructor(pInfo: IoBrokerDeviceInfo, pType: DeviceType);
16
+ /** @inheritDoc */
17
+ get lastBatteryPersist(): number;
18
+ /** @inheritDoc */
19
+ get battery(): number;
20
+ get lastUpdate(): Date;
21
+ /** @inheritDoc */
22
+ addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
23
+ /** @inheritDoc */
24
+ update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverride?: boolean): void;
25
+ /** @inheritDoc */
26
+ persistBatteryDevice(): void;
27
+ /** @inheritDoc */
28
+ dispose(): void;
29
+ /**
30
+ * Checks whether the battery level did change and if so fires the callbacks
31
+ */
32
+ private checkForBatteryChange;
33
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SmartGardenDevice = void 0;
4
+ const IoBrokerBaseDevice_1 = require("../IoBrokerBaseDevice");
5
+ const services_1 = require("../../services");
6
+ const models_1 = require("../../../models");
7
+ const DeviceCapability_1 = require("../DeviceCapability");
8
+ class SmartGardenDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
9
+ constructor(pInfo, pType) {
10
+ super(pInfo, pType);
11
+ this._criticalBatteryLevel = 20;
12
+ this._lastUpdate = new Date(0);
13
+ this._lastBatteryLevel = -1;
14
+ this._batteryLevelCallbacks = [];
15
+ this._lastBatteryPersist = 0;
16
+ this._battery = -99;
17
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
18
+ this._deviceSerial = pInfo.devID.replace('DEVICE_', '');
19
+ }
20
+ /** @inheritDoc */
21
+ get lastBatteryPersist() {
22
+ return this._lastBatteryPersist;
23
+ }
24
+ /** @inheritDoc */
25
+ get battery() {
26
+ return this._battery;
27
+ }
28
+ get lastUpdate() {
29
+ return this._lastUpdate;
30
+ }
31
+ /** @inheritDoc */
32
+ addBatteryLevelCallback(pCallback) {
33
+ this._batteryLevelCallbacks.push(pCallback);
34
+ }
35
+ /** @inheritDoc */
36
+ update(idSplit, state, initial = false, pOverride = false) {
37
+ this.log(models_1.LogLevel.DeepTrace, `Smartgarden: ${initial ? 'Initiales ' : ''}Update: ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
38
+ if (!pOverride) {
39
+ this.log(models_1.LogLevel.Warn, `Keine Update Überschreibung:\n\tID: ${idSplit.join('.')}\n\tData: ${JSON.stringify(state)}`);
40
+ }
41
+ const stateLastUpdate = new Date(state.ts);
42
+ if (stateLastUpdate > this._lastUpdate) {
43
+ this._lastUpdate = stateLastUpdate;
44
+ }
45
+ if (idSplit.length < 6) {
46
+ return;
47
+ }
48
+ const folder = idSplit[4];
49
+ const stateName = idSplit[5];
50
+ if (folder.indexOf('SERVICE_COMMON') === 0) {
51
+ switch (stateName) {
52
+ case 'batteryLevel_value':
53
+ this._battery = state.val;
54
+ this.checkForBatteryChange();
55
+ this.persistBatteryDevice();
56
+ if (this._battery < this._criticalBatteryLevel) {
57
+ this.log(models_1.LogLevel.Warn, 'This SmartGarden device reached critical battery level.');
58
+ }
59
+ break;
60
+ }
61
+ }
62
+ this.stateMap.set(idSplit[5], state);
63
+ const individualCallbacks = this.individualStateCallbacks.get(idSplit[5]);
64
+ if (individualCallbacks !== undefined) {
65
+ for (const cb of individualCallbacks) {
66
+ cb(state.val);
67
+ }
68
+ }
69
+ }
70
+ /** @inheritDoc */
71
+ persistBatteryDevice() {
72
+ var _a;
73
+ const now = services_1.Utils.nowMS();
74
+ if (this._lastBatteryPersist + 60000 > now) {
75
+ return;
76
+ }
77
+ (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
78
+ this._lastBatteryPersist = now;
79
+ }
80
+ /** @inheritDoc */
81
+ dispose() {
82
+ // Nothing yet
83
+ }
84
+ /**
85
+ * Checks whether the battery level did change and if so fires the callbacks
86
+ */
87
+ checkForBatteryChange() {
88
+ const newLevel = this.battery;
89
+ if (newLevel == -1 || newLevel == this._lastBatteryLevel) {
90
+ return;
91
+ }
92
+ for (const cb of this._batteryLevelCallbacks) {
93
+ cb(new models_1.BatteryLevelChangeAction(this));
94
+ }
95
+ this._lastBatteryLevel = newLevel;
96
+ }
97
+ }
98
+ exports.SmartGardenDevice = SmartGardenDevice;
@@ -0,0 +1,35 @@
1
+ import { SmartGardenDevice } from './smartGardenDevice';
2
+ import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
3
+ import { iActuator } from '../baseDeviceInterfaces';
4
+ import { BlockAutomaticHandler } from '../../services/blockAutomaticHandler';
5
+ import { ActuatorSetStateCommand, ActuatorSettings, ActuatorToggleCommand, ActuatorWriteStateToDeviceCommand, RestoreTargetAutomaticValueCommand } from '../../../models';
6
+ export declare class SmartGardenMower extends SmartGardenDevice implements iActuator {
7
+ /** @inheritDoc */
8
+ readonly blockAutomationHandler: BlockAutomaticHandler;
9
+ /** @inheritDoc */
10
+ targetAutomaticState: boolean;
11
+ /** @inheritDoc */
12
+ settings: ActuatorSettings;
13
+ /** @inheritDoc */
14
+ queuedValue: boolean | null;
15
+ private _lastPersist;
16
+ private readonly _activityControlStateId;
17
+ private _actuatorOn;
18
+ constructor(pInfo: IoBrokerDeviceInfo);
19
+ /** @inheritDoc */
20
+ get actuatorOn(): boolean;
21
+ /** @inheritDoc */
22
+ restoreTargetAutomaticValue(c: RestoreTargetAutomaticValueCommand): void;
23
+ /** @inheritDoc */
24
+ update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
25
+ /** @inheritDoc */
26
+ setActuator(command: ActuatorSetStateCommand): void;
27
+ /** @inheritDoc */
28
+ persist(): void;
29
+ /** @inheritDoc */
30
+ toggleActuator(command: ActuatorToggleCommand): boolean;
31
+ /** @inheritDoc */
32
+ writeActuatorStateToDevice(c: ActuatorWriteStateToDeviceCommand): void;
33
+ private park;
34
+ private mov;
35
+ }