hoffmation-base 0.1.36 → 0.1.37

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 (32) hide show
  1. package/lib/server/config/iConfig.d.ts +0 -1
  2. package/lib/server/devices/button.d.ts +24 -0
  3. package/lib/server/devices/button.js +97 -0
  4. package/lib/server/devices/deviceType.d.ts +1 -0
  5. package/lib/server/devices/deviceType.js +1 -0
  6. package/lib/server/devices/devices.js +4 -0
  7. package/lib/server/devices/groups/praesenzGroup.d.ts +6 -0
  8. package/lib/server/devices/groups/praesenzGroup.js +14 -5
  9. package/lib/server/devices/groups/tasterGroup.d.ts +2 -2
  10. package/lib/server/devices/groups/tasterGroup.js +9 -7
  11. package/lib/server/devices/hmIPDevices/hmIpTaster.d.ts +13 -7
  12. package/lib/server/devices/hmIPDevices/hmIpTaster.js +34 -21
  13. package/lib/server/devices/hmIPDevices/hmIpWippe.d.ts +13 -6
  14. package/lib/server/devices/hmIPDevices/hmIpWippe.js +27 -9
  15. package/lib/server/devices/iButtonSwitch.d.ts +13 -0
  16. package/lib/server/devices/{iTaster.js → iButtonSwitch.js} +0 -0
  17. package/lib/server/devices/index.d.ts +2 -2
  18. package/lib/server/devices/index.js +2 -2
  19. package/lib/server/devices/zigbee/index.d.ts +2 -0
  20. package/lib/server/devices/zigbee/index.js +2 -0
  21. package/lib/server/devices/zigbee/zigbeeAqaraOpple3Switch.d.ts +19 -0
  22. package/lib/server/devices/zigbee/zigbeeAqaraOpple3Switch.js +105 -0
  23. package/lib/server/devices/zigbee/zigbeeIlluShutter.js +4 -0
  24. package/lib/server/devices/zigbee/zigbeeSwitch.d.ts +19 -0
  25. package/lib/server/devices/zigbee/zigbeeSwitch.js +13 -0
  26. package/lib/server/services/Telegram/telegram-Commands.js +1 -1
  27. package/lib/server/services/news-service.js +6 -1
  28. package/lib/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +14 -14
  30. package/lib/server/devices/iTaster.d.ts +0 -7
  31. package/lib/server/devices/taste.d.ts +0 -15
  32. package/lib/server/devices/taste.js +0 -64
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZigbeeAqaraOpple3Switch = void 0;
4
+ const zigbeeSwitch_1 = require("./zigbeeSwitch");
5
+ const button_1 = require("../button");
6
+ const deviceType_1 = require("../deviceType");
7
+ const logLevel_1 = require("../../../models/logLevel");
8
+ class ZigbeeAqaraOpple3Switch extends zigbeeSwitch_1.ZigbeeSwitch {
9
+ constructor(pInfo) {
10
+ super(pInfo, deviceType_1.DeviceType.ZigbeeAqaraOpple3Switch);
11
+ this.buttonTopLeft = new button_1.Button('TopLeft', ZigbeeAqaraOpple3Switch.BUTTON_CAPABILLITIES);
12
+ this.buttonMidLeft = new button_1.Button('MidLeft', ZigbeeAqaraOpple3Switch.BUTTON_CAPABILLITIES);
13
+ this.buttonBotLeft = new button_1.Button('BotLeft', ZigbeeAqaraOpple3Switch.BUTTON_CAPABILLITIES);
14
+ this.buttonTopRight = new button_1.Button('TopRight', ZigbeeAqaraOpple3Switch.BUTTON_CAPABILLITIES);
15
+ this.buttonMidRight = new button_1.Button('MidRight', ZigbeeAqaraOpple3Switch.BUTTON_CAPABILLITIES);
16
+ this.buttonBotRight = new button_1.Button('BotRight', ZigbeeAqaraOpple3Switch.BUTTON_CAPABILLITIES);
17
+ this.buttonBot = undefined;
18
+ this.buttonTop = undefined;
19
+ }
20
+ update(idSplit, state, initial = false) {
21
+ this.log(logLevel_1.LogLevel.DeepTrace, `Magnet Contact Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`);
22
+ super.update(idSplit, state, initial, true);
23
+ const name = idSplit[3];
24
+ if (name.startsWith('button_')) {
25
+ this.updateButton(name, state.val);
26
+ }
27
+ }
28
+ updateButton(name, val) {
29
+ const parts = name.split('_');
30
+ if (parts.length < 3) {
31
+ this.log(logLevel_1.LogLevel.Error, `Unknown State Name: ${name}, expected something like "button_3_click"`);
32
+ return;
33
+ }
34
+ const index = parseInt(parts[1], 10);
35
+ let taste;
36
+ switch (index) {
37
+ case 1:
38
+ taste = this.buttonTopLeft;
39
+ break;
40
+ case 2:
41
+ taste = this.buttonTopRight;
42
+ break;
43
+ case 3:
44
+ taste = this.buttonMidLeft;
45
+ break;
46
+ case 4:
47
+ taste = this.buttonMidRight;
48
+ break;
49
+ case 5:
50
+ taste = this.buttonBotLeft;
51
+ break;
52
+ case 6:
53
+ taste = this.buttonBotRight;
54
+ break;
55
+ default:
56
+ this.log(logLevel_1.LogLevel.Error, `Unknown index: ${index} for button, Aqara Opple 3 has only 6 buttons.`);
57
+ return;
58
+ }
59
+ switch (parts[2]) {
60
+ case 'click':
61
+ taste.updateState(button_1.ButtonPressType.short, val);
62
+ return;
63
+ case 'hold':
64
+ taste.updateState(button_1.ButtonPressType.long, val);
65
+ return;
66
+ case 'double':
67
+ taste.updateState(button_1.ButtonPressType.double, val);
68
+ return;
69
+ case 'triple':
70
+ taste.updateState(button_1.ButtonPressType.triple, val);
71
+ return;
72
+ default:
73
+ this.log(logLevel_1.LogLevel.Error, `Unknown pressType: "${parts[2]}" for button, Aqara Opple 3 has only types "click, hold, double, triple".`);
74
+ return;
75
+ }
76
+ }
77
+ getButtonAssignment() {
78
+ const result = [`Button: ${this.info.customName}`];
79
+ for (const taste of [
80
+ this.buttonTopLeft,
81
+ this.buttonTopRight,
82
+ this.buttonMidLeft,
83
+ this.buttonMidRight,
84
+ this.buttonBotLeft,
85
+ this.buttonBotRight,
86
+ ]) {
87
+ const desc = taste.getDescription();
88
+ if (desc === '') {
89
+ continue;
90
+ }
91
+ result.push(`Button "${taste.name}":`);
92
+ result.push(desc);
93
+ result.push('');
94
+ }
95
+ result.push('____________');
96
+ return result.join('\n');
97
+ }
98
+ }
99
+ exports.ZigbeeAqaraOpple3Switch = ZigbeeAqaraOpple3Switch;
100
+ ZigbeeAqaraOpple3Switch.BUTTON_CAPABILLITIES = {
101
+ shortPress: true,
102
+ longPress: true,
103
+ doublePress: true,
104
+ triplePress: true,
105
+ };
@@ -87,6 +87,7 @@ class ZigbeeIlluShutter extends zigbeeShutter_1.ZigbeeShutter {
87
87
  }
88
88
  processNewMovementState(val) {
89
89
  const newState = val <= 30 ? MovementState.Down : val >= 70 ? MovementState.Up : MovementState.Stop;
90
+ this.log(logLevel_1.LogLevel.Trace, `New Movementstate "${MovementState[val]}"`);
90
91
  if (newState !== MovementState.Stop) {
91
92
  this._movementState = newState;
92
93
  return;
@@ -101,6 +102,7 @@ class ZigbeeIlluShutter extends zigbeeShutter_1.ZigbeeShutter {
101
102
  this._shutterCalibrationData.averageUp +=
102
103
  (this._msTilTop - this._shutterCalibrationData.averageUp) / this._shutterCalibrationData.counterUp;
103
104
  this.persistCalibrationData();
105
+ this.log(logLevel_1.LogLevel.Trace, `New Measurment for shutter up (${this._msTilTop}ms), new Average: ${this._shutterCalibrationData.averageUp}`);
104
106
  return;
105
107
  }
106
108
  if (this._movementStartPos === 100 && oldState === MovementState.Down && this._setLevel === 0) {
@@ -111,6 +113,7 @@ class ZigbeeIlluShutter extends zigbeeShutter_1.ZigbeeShutter {
111
113
  this._shutterCalibrationData.averageDown +=
112
114
  (this._msTilBot - this._shutterCalibrationData.averageDown) / this._shutterCalibrationData.counterDown;
113
115
  this.persistCalibrationData();
116
+ this.log(logLevel_1.LogLevel.Trace, `New Measurment for shutter down (${this._msTilBot}ms), new Average: ${this._shutterCalibrationData.averageDown}`);
114
117
  return;
115
118
  }
116
119
  if (!this.isCalibrated()) {
@@ -127,6 +130,7 @@ class ZigbeeIlluShutter extends zigbeeShutter_1.ZigbeeShutter {
127
130
  return this._shutterCalibrationData.averageUp > 0 && this._shutterCalibrationData.averageDown > 0;
128
131
  }
129
132
  persistCalibrationData() {
133
+ this.log(logLevel_1.LogLevel.Trace, `Persiting Calibration Data. Average Up: ${this._shutterCalibrationData.averageUp}, Down: ${this._shutterCalibrationData.averageDown}`);
130
134
  persist_1.Persist.persistShutterCalibration(this._shutterCalibrationData);
131
135
  }
132
136
  }
@@ -0,0 +1,19 @@
1
+ /// <reference types="iobroker" />
2
+ import { iButtonSwitch } from '../iButtonSwitch';
3
+ import { ZigbeeDevice } from './zigbeeDevice';
4
+ import { DeviceInfo } from '../DeviceInfo';
5
+ import { DeviceType } from '../deviceType';
6
+ import { Button } from '../button';
7
+ export declare abstract class ZigbeeSwitch extends ZigbeeDevice implements iButtonSwitch {
8
+ abstract buttonBot: Button | undefined;
9
+ abstract buttonBotLeft: Button | undefined;
10
+ abstract buttonBotRight: Button | undefined;
11
+ abstract buttonMidLeft: Button | undefined;
12
+ abstract buttonMidRight: Button | undefined;
13
+ abstract buttonTop: Button | undefined;
14
+ abstract buttonTopLeft: Button | undefined;
15
+ abstract buttonTopRight: Button | undefined;
16
+ constructor(pInfo: DeviceInfo, deviceType: DeviceType);
17
+ update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverrride?: boolean): void;
18
+ abstract getButtonAssignment(): string;
19
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZigbeeSwitch = void 0;
4
+ const zigbeeDevice_1 = require("./zigbeeDevice");
5
+ class ZigbeeSwitch extends zigbeeDevice_1.ZigbeeDevice {
6
+ constructor(pInfo, deviceType) {
7
+ super(pInfo, deviceType);
8
+ }
9
+ update(idSplit, state, initial = false, pOverrride = false) {
10
+ super.update(idSplit, state, initial, pOverrride);
11
+ }
12
+ }
13
+ exports.ZigbeeSwitch = ZigbeeSwitch;
@@ -114,7 +114,7 @@ class TelegramCommands {
114
114
  for (const id in devices_1.Devices.alLDevices) {
115
115
  const d = devices_1.Devices.alLDevices[id];
116
116
  if (d.deviceType === deviceType_1.DeviceType.HmIpTaster) {
117
- response.push(d.getTastenAssignment());
117
+ response.push(d.getButtonAssignment());
118
118
  }
119
119
  }
120
120
  telegram_service_1.TelegramService.sendMessage([m.from.id], response.join('\n'));
@@ -93,7 +93,9 @@ class NewsService {
93
93
  }
94
94
  static downloadLatestFileFromFeed(rssUrl, targetDir) {
95
95
  const parser = new rss_parser_1.default();
96
- parser.parseURL(rssUrl).then((feed) => {
96
+ parser
97
+ .parseURL(rssUrl)
98
+ .then((feed) => {
97
99
  try {
98
100
  const currentFeedItem = feed.items[0];
99
101
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Most recent news on ${feed.title} is "${currentFeedItem.title}"`);
@@ -129,6 +131,9 @@ class NewsService {
129
131
  catch (e) {
130
132
  log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Error while parsing feed: ${e}`, { source: logSource_1.LogSource.News });
131
133
  }
134
+ })
135
+ .catch((e) => {
136
+ log_service_1.ServerLogService.writeLog(logLevel_1.LogLevel.Debug, `Error while getting feed: ${e}`, { source: logSource_1.LogSource.News });
132
137
  });
133
138
  }
134
139
  /**