hoffmation-base 1.0.41 → 1.0.45

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 (98) hide show
  1. package/lib/index.d.ts +2 -2
  2. package/lib/models/rooms/RoomBase.d.ts +2 -2
  3. package/lib/server/devices/DeviceCapability.d.ts +17 -0
  4. package/lib/server/devices/DeviceCapability.js +21 -0
  5. package/lib/server/devices/IoBrokerBaseDevice.d.ts +4 -2
  6. package/lib/server/devices/IoBrokerBaseDevice.js +1 -0
  7. package/lib/server/devices/baseDeviceInterfaces/iAcDevice.d.ts +14 -0
  8. package/lib/server/devices/baseDeviceInterfaces/iAcDevice.js +2 -0
  9. package/lib/server/devices/baseDeviceInterfaces/iActuator.d.ts +15 -0
  10. package/lib/server/devices/baseDeviceInterfaces/iActuator.js +2 -0
  11. package/lib/server/devices/baseDeviceInterfaces/iBaseDevice.d.ts +4 -2
  12. package/lib/server/devices/baseDeviceInterfaces/iButtonSwitch.d.ts +2 -2
  13. package/lib/server/devices/baseDeviceInterfaces/iDimmableLamp.d.ts +16 -0
  14. package/lib/server/devices/baseDeviceInterfaces/iDimmableLamp.js +2 -0
  15. package/lib/server/devices/baseDeviceInterfaces/iEnergyManager.d.ts +2 -2
  16. package/lib/server/devices/baseDeviceInterfaces/iHandleSensor.d.ts +9 -0
  17. package/lib/server/devices/baseDeviceInterfaces/iHandleSensor.js +2 -0
  18. package/lib/server/devices/baseDeviceInterfaces/iHeater.d.ts +2 -2
  19. package/lib/server/devices/baseDeviceInterfaces/iHumiditySensor.d.ts +2 -2
  20. package/lib/server/devices/baseDeviceInterfaces/iLamp.d.ts +4 -4
  21. package/lib/server/devices/baseDeviceInterfaces/iMotionSensor.d.ts +2 -2
  22. package/lib/server/devices/baseDeviceInterfaces/iShutter.d.ts +2 -2
  23. package/lib/server/devices/baseDeviceInterfaces/iSpeaker.d.ts +8 -0
  24. package/lib/server/devices/baseDeviceInterfaces/iSpeaker.js +2 -0
  25. package/lib/server/devices/baseDeviceInterfaces/iTemperatureSensor.d.ts +2 -2
  26. package/lib/server/devices/baseDeviceInterfaces/iVibrationSensor.d.ts +2 -2
  27. package/lib/server/devices/baseDeviceInterfaces/index.d.ts +4 -0
  28. package/lib/server/devices/baseDeviceInterfaces/index.js +4 -0
  29. package/lib/server/devices/device-cluster.d.ts +4 -5
  30. package/lib/server/devices/device-cluster.js +6 -0
  31. package/lib/server/devices/device-list.d.ts +3 -5
  32. package/lib/server/devices/device-list.js +4 -13
  33. package/lib/server/devices/deviceUpdater.js +2 -1
  34. package/lib/server/devices/devices.d.ts +2 -2
  35. package/lib/server/devices/groups/heatGroup.js +1 -1
  36. package/lib/server/devices/groups/index.d.ts +1 -1
  37. package/lib/server/devices/groups/index.js +1 -1
  38. package/lib/server/devices/groups/lampenGroup.d.ts +3 -3
  39. package/lib/server/devices/groups/lampenGroup.js +3 -3
  40. package/lib/server/devices/groups/{sonosGroup.d.ts → speakerGroup.d.ts} +3 -3
  41. package/lib/server/devices/groups/{sonosGroup.js → speakerGroup.js} +6 -8
  42. package/lib/server/devices/hmIPDevices/hmIpBewegung.js +3 -0
  43. package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +4 -3
  44. package/lib/server/devices/hmIPDevices/hmIpGriff.js +1 -1
  45. package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.js +4 -0
  46. package/lib/server/devices/hmIPDevices/hmIpLampe.js +2 -0
  47. package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +3 -0
  48. package/lib/server/devices/hmIPDevices/hmIpRoll.js +2 -0
  49. package/lib/server/devices/hmIPDevices/hmIpTaster.js +2 -0
  50. package/lib/server/devices/hmIPDevices/hmIpWippe.js +2 -0
  51. package/lib/server/devices/jsObject/jsObjectEnergyManager.js +2 -0
  52. package/lib/server/devices/zigbee/BaseDevices/ZigbeeActuator.d.ts +4 -3
  53. package/lib/server/devices/zigbee/BaseDevices/ZigbeeActuator.js +2 -0
  54. package/lib/server/devices/zigbee/BaseDevices/index.d.ts +1 -0
  55. package/lib/server/devices/zigbee/BaseDevices/index.js +1 -0
  56. package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.js +2 -0
  57. package/lib/server/devices/zigbee/{zigbeeMotionSensor.d.ts → BaseDevices/zigbeeMotionSensor.d.ts} +5 -5
  58. package/lib/server/devices/zigbee/{zigbeeMotionSensor.js → BaseDevices/zigbeeMotionSensor.js} +6 -4
  59. package/lib/server/devices/zigbee/BaseDevices/zigbeeShutter.js +2 -0
  60. package/lib/server/devices/zigbee/index.d.ts +0 -1
  61. package/lib/server/devices/zigbee/index.js +0 -1
  62. package/lib/server/devices/zigbee/zigbeeAquaraMotion.d.ts +1 -1
  63. package/lib/server/devices/zigbee/zigbeeAquaraMotion.js +4 -2
  64. package/lib/server/devices/zigbee/zigbeeAquaraVibra.js +2 -0
  65. package/lib/server/devices/zigbee/zigbeeBlitzShp.js +2 -0
  66. package/lib/server/devices/zigbee/zigbeeIkeaSteckdose.d.ts +0 -3
  67. package/lib/server/devices/zigbee/zigbeeIkeaSteckdose.js +0 -9
  68. package/lib/server/devices/zigbee/zigbeeIlluDimmer.d.ts +2 -2
  69. package/lib/server/devices/zigbee/zigbeeIlluDimmer.js +3 -0
  70. package/lib/server/devices/zigbee/zigbeeIlluLampe.js +2 -0
  71. package/lib/server/devices/zigbee/zigbeeSonoffMotion.d.ts +1 -1
  72. package/lib/server/devices/zigbee/zigbeeSonoffMotion.js +2 -2
  73. package/lib/server/devices/zigbee/zigbeeSonoffTemp.js +3 -0
  74. package/lib/server/devices/zigbee/zigbeeUbisysShutter.d.ts +1 -1
  75. package/lib/server/services/Sonos/OwnSonosDevices.d.ts +1 -1
  76. package/lib/server/services/Sonos/OwnSonosDevices.js +1 -1
  77. package/lib/server/services/Sonos/index.d.ts +1 -0
  78. package/lib/server/services/Sonos/index.js +3 -0
  79. package/lib/server/services/Sonos/own-sonos-device.d.ts +26 -0
  80. package/lib/server/services/Sonos/own-sonos-device.js +108 -0
  81. package/lib/server/services/Sonos/sonos-service.d.ts +1 -20
  82. package/lib/server/services/Sonos/sonos-service.js +5 -94
  83. package/lib/server/services/ac/ac-device.d.ts +4 -2
  84. package/lib/server/services/ac/ac-device.js +2 -0
  85. package/lib/server/services/api/api-service.d.ts +22 -5
  86. package/lib/server/services/api/api-service.js +47 -5
  87. package/lib/server/services/calendar/muell-tonne.d.ts +3 -3
  88. package/lib/server/services/calendar/muell-tonne.js +6 -12
  89. package/lib/server/services/calendar/m/303/274ll-service.d.ts +3 -3
  90. package/lib/server/services/calendar/m/303/274ll-service.js +7 -7
  91. package/lib/server/services/news-service.d.ts +3 -3
  92. package/lib/server/services/news-service.js +4 -4
  93. package/lib/server/services/room-service/room-service.d.ts +3 -2
  94. package/lib/server/services/room-service/room-service.js +1 -0
  95. package/lib/server/services/weather/weather-service.d.ts +2 -2
  96. package/lib/server/services/weather/weather-service.js +14 -15
  97. package/lib/tsconfig.tsbuildinfo +1 -1
  98. package/package.json +3 -3
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OwnSonosDevice = void 0;
7
+ const devices_1 = require("../../devices");
8
+ const models_1 = require("../../../models");
9
+ const log_service_1 = require("../log-service");
10
+ const utils_1 = require("../utils");
11
+ const lodash_1 = __importDefault(require("lodash"));
12
+ const sonos_service_1 = require("./sonos-service");
13
+ const DeviceCapability_1 = require("../../devices/DeviceCapability");
14
+ const settings_service_1 = require("../settings-service");
15
+ const polly_service_1 = require("./polly-service");
16
+ class OwnSonosDevice {
17
+ constructor(discoveryName, roomName, device) {
18
+ this.device = device;
19
+ this.maxPlayOnAllVolume = 80;
20
+ this.deviceType = devices_1.DeviceType.Sonos;
21
+ this.deviceCapabilities = [DeviceCapability_1.DeviceCapability.speaker];
22
+ this.discoveryName = discoveryName;
23
+ this._info = new devices_1.DeviceInfo();
24
+ this._info.fullName = `Sonos ${roomName} ${discoveryName}`;
25
+ this._info.customName = `Sonos ${discoveryName}`;
26
+ this._info.room = roomName;
27
+ this._info.allDevicesKey = `sonos-${roomName}-${discoveryName}`;
28
+ devices_1.Devices.alLDevices[`sonos-${roomName}-${discoveryName}`] = this;
29
+ }
30
+ get info() {
31
+ return this._info;
32
+ }
33
+ set info(info) {
34
+ this._info = info;
35
+ }
36
+ get id() {
37
+ var _a;
38
+ return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `sonos-${this.info.room}-${this.info.customName}`;
39
+ }
40
+ get name() {
41
+ return this.info.customName;
42
+ }
43
+ playOnDevice(mp3Name, duration, volume = undefined, onlyWhenPlaying = undefined, resolveAfterRevert = false) {
44
+ var _a, _b;
45
+ if (((_a = settings_service_1.SettingsService.settings.mp3Server) === null || _a === void 0 ? void 0 : _a.serverAddress) === undefined) {
46
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Alert, `Sonos: Can't speak as we have no mp3Server`);
47
+ return;
48
+ }
49
+ const specificTimeout = Math.ceil(duration / 1000) + 5;
50
+ const options = {
51
+ catchQueueErrors: true,
52
+ trackUri: `${(_b = settings_service_1.SettingsService.settings.mp3Server) === null || _b === void 0 ? void 0 : _b.serverAddress}/file.mp3?fname=${mp3Name}`,
53
+ delayMs: 750,
54
+ onlyWhenPlaying: onlyWhenPlaying,
55
+ resolveAfterRevert: resolveAfterRevert,
56
+ volume: volume,
57
+ specificTimeout: specificTimeout,
58
+ notificationFired: (played) => {
59
+ this.log(models_1.LogLevel.Trace, `Sonos Notification ("${mp3Name}") was${played ? '' : "n't"} played (duration: "${specificTimeout}")`);
60
+ },
61
+ };
62
+ try {
63
+ if (this.device === undefined) {
64
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Alert, `Sonos Geräte ${this.name} ist nicht initialisiert`);
65
+ utils_1.Utils.guardedTimeout(() => {
66
+ sonos_service_1.SonosService.initialize();
67
+ }, 500, this);
68
+ return;
69
+ }
70
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Trace, `Spiele nun die Ausgabe für "${mp3Name}" auf "${this.name}"`);
71
+ this.device.PlayNotificationTwo(options).then((played) => {
72
+ this.log(models_1.LogLevel.Debug, `Sonos Notification ("${mp3Name}") was${played ? '' : "n't"} played (duration: "${specificTimeout}")`);
73
+ });
74
+ }
75
+ catch (err) {
76
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Sonos Error ${err.message}: ${err.stack}`);
77
+ }
78
+ }
79
+ playTestMessage() {
80
+ this.speakOnDevice(`Ich bin ${this.name}`);
81
+ }
82
+ speakOnDevice(pMessage, volume = undefined, onlyWhenPlaying = undefined, resolveAfterRevert = undefined) {
83
+ polly_service_1.PollyService.tts(pMessage, (networkPath, duration) => {
84
+ this.playOnDevice(networkPath, duration, volume, onlyWhenPlaying, resolveAfterRevert);
85
+ });
86
+ }
87
+ stop() {
88
+ var _a;
89
+ (_a = this.device) === null || _a === void 0 ? void 0 : _a.Stop();
90
+ }
91
+ playUrl(url) {
92
+ var _a;
93
+ (_a = this.device) === null || _a === void 0 ? void 0 : _a.SetAVTransportURI(url);
94
+ }
95
+ log(level, message, debugType = log_service_1.LogDebugType.None) {
96
+ var _a, _b;
97
+ log_service_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
98
+ debugType: debugType,
99
+ room: (_b = (_a = this.room) === null || _a === void 0 ? void 0 : _a.roomName) !== null && _b !== void 0 ? _b : '',
100
+ deviceId: this.name,
101
+ deviceName: this.name,
102
+ });
103
+ }
104
+ toJSON() {
105
+ return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['room']));
106
+ }
107
+ }
108
+ exports.OwnSonosDevice = OwnSonosDevice;
@@ -1,22 +1,5 @@
1
1
  import { SonosDevice } from '@svrooij/sonos/lib';
2
- import { LogLevel, RoomBase } from '../../../models';
3
- import { LogDebugType } from '../log-service';
4
- import { DeviceInfo, DeviceType, IBaseDevice } from '../../devices';
5
- export declare class OwnSonosDevice implements IBaseDevice {
6
- device: SonosDevice | undefined;
7
- maxPlayOnAllVolume: number;
8
- room: RoomBase | undefined;
9
- readonly deviceType: DeviceType;
10
- constructor(name: string, roomName: string, device: SonosDevice | undefined);
11
- protected _info: DeviceInfo;
12
- get info(): DeviceInfo;
13
- set info(info: DeviceInfo);
14
- get id(): string;
15
- get name(): string;
16
- playTestMessage(): void;
17
- log(level: LogLevel, message: string, debugType?: LogDebugType): void;
18
- toJSON(): Partial<OwnSonosDevice>;
19
- }
2
+ import { OwnSonosDevice } from './own-sonos-device';
20
3
  export declare class SonosService {
21
4
  static all: SonosDevice[];
22
5
  static devicesDict: {
@@ -33,8 +16,6 @@ export declare class SonosService {
33
16
  static initialize(reinitialize?: boolean): void;
34
17
  static checkAll(): Promise<void>;
35
18
  static speakOnAll(pMessage: string, volumeOverride?: number): void;
36
- static playOnDevice(ownSnDevice: OwnSonosDevice, mp3Name: string, duration: number, volume?: number | undefined, onlyWhenPlaying?: boolean | undefined, resolveAfterRevert?: boolean | undefined): void;
37
- static speakOnDevice(pMessage: string, ownSnDevice: OwnSonosDevice, volume?: number | undefined, onlyWhenPlaying?: boolean | undefined, resolveAfterRevert?: boolean | undefined): void;
38
19
  static speakTestMessageOnEachDevice(): void;
39
20
  private static initializeDevice;
40
21
  }
@@ -1,61 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SonosService = exports.OwnSonosDevice = void 0;
3
+ exports.SonosService = void 0;
7
4
  const lib_1 = require("@svrooij/sonos/lib");
8
5
  const models_1 = require("../../../models");
9
6
  const log_service_1 = require("../log-service");
10
- const utils_1 = require("../utils");
11
7
  const polly_service_1 = require("./polly-service");
12
8
  const Telegram_1 = require("../Telegram");
13
9
  const time_callback_service_1 = require("../time-callback-service");
14
10
  const settings_service_1 = require("../settings-service");
15
- const devices_1 = require("../../devices");
16
- const lodash_1 = __importDefault(require("lodash"));
17
- class OwnSonosDevice {
18
- constructor(name, roomName, device) {
19
- this.device = device;
20
- this.maxPlayOnAllVolume = 80;
21
- this.deviceType = devices_1.DeviceType.Sonos;
22
- this._info = new devices_1.DeviceInfo();
23
- this._info.fullName = `Sonos ${name}`;
24
- this._info.customName = `${roomName} ${name}`;
25
- this._info.room = roomName;
26
- this._info.allDevicesKey = `sonos-${roomName}-${name}`;
27
- devices_1.Devices.alLDevices[`sonos-${roomName}-${name}`] = this;
28
- }
29
- get info() {
30
- return this._info;
31
- }
32
- set info(info) {
33
- this._info = info;
34
- }
35
- get id() {
36
- var _a;
37
- return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `sonos-${this.info.room}-${this.info.customName}`;
38
- }
39
- get name() {
40
- return this.info.customName;
41
- }
42
- playTestMessage() {
43
- SonosService.speakOnDevice(`Ich bin ${this.name}`, this);
44
- }
45
- log(level, message, debugType = log_service_1.LogDebugType.None) {
46
- var _a, _b;
47
- log_service_1.ServerLogService.writeLog(level, `${this.name}: ${message}`, {
48
- debugType: debugType,
49
- room: (_b = (_a = this.room) === null || _a === void 0 ? void 0 : _a.roomName) !== null && _b !== void 0 ? _b : '',
50
- deviceId: this.name,
51
- deviceName: this.name,
52
- });
53
- }
54
- toJSON() {
55
- return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['room']));
56
- }
57
- }
58
- exports.OwnSonosDevice = OwnSonosDevice;
59
11
  class SonosService {
60
12
  static addOwnDevices(snDevices, reinitializationDevice) {
61
13
  this.ownDevices = snDevices;
@@ -86,6 +38,7 @@ class SonosService {
86
38
  this.sonosManager
87
39
  .InitializeWithDiscovery(10)
88
40
  .then(() => {
41
+ var _a;
89
42
  this.sonosManager.OnNewDevice((d) => {
90
43
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `SonosDevice ${d.Name} joined`);
91
44
  SonosService.initializeDevice(d);
@@ -95,8 +48,8 @@ class SonosService {
95
48
  SonosService.initializeDevice(d);
96
49
  });
97
50
  this.isInitialized = true;
98
- if (!reinitialize && this.reinitializationDevice !== undefined) {
99
- this.speakOnDevice(`Sonos System initialisiert und bereit für Sprachausgaben.`, this.reinitializationDevice, 30);
51
+ if (!reinitialize) {
52
+ (_a = this.reinitializationDevice) === null || _a === void 0 ? void 0 : _a.speakOnDevice(`Sonos System initialisiert und bereit für Sprachausgaben.`, 30);
100
53
  }
101
54
  })
102
55
  .catch(console.error);
@@ -131,52 +84,10 @@ class SonosService {
131
84
  const hours = new Date().getHours();
132
85
  const volume = hours < 10 || hours > 22 ? 40 : 80;
133
86
  for (const deviceName in this.ownDevices) {
134
- SonosService.playOnDevice(this.ownDevices[deviceName], networkPath, duration, volumeOverride > -1 ? volumeOverride : Math.min(volume, this.ownDevices[deviceName].maxPlayOnAllVolume));
87
+ this.ownDevices[deviceName].playOnDevice(networkPath, duration, volumeOverride > -1 ? volumeOverride : Math.min(volume, this.ownDevices[deviceName].maxPlayOnAllVolume));
135
88
  }
136
89
  });
137
90
  }
138
- static playOnDevice(ownSnDevice, mp3Name, duration, volume = undefined, onlyWhenPlaying = undefined, resolveAfterRevert = false) {
139
- var _a, _b;
140
- if (((_a = settings_service_1.SettingsService.settings.mp3Server) === null || _a === void 0 ? void 0 : _a.serverAddress) === undefined) {
141
- log_service_1.ServerLogService.writeLog(models_1.LogLevel.Alert, `Sonos: Can't speak as we have no mp3Server`);
142
- return;
143
- }
144
- const specificTimeout = Math.ceil(duration / 1000) + 5;
145
- const options = {
146
- catchQueueErrors: true,
147
- trackUri: `${(_b = settings_service_1.SettingsService.settings.mp3Server) === null || _b === void 0 ? void 0 : _b.serverAddress}/file.mp3?fname=${mp3Name}`,
148
- delayMs: 750,
149
- onlyWhenPlaying: onlyWhenPlaying,
150
- resolveAfterRevert: resolveAfterRevert,
151
- volume: volume,
152
- specificTimeout: specificTimeout,
153
- notificationFired: (played) => {
154
- ownSnDevice.log(models_1.LogLevel.Trace, `Sonos Notification ("${mp3Name}") was${played ? '' : "n't"} played (duration: "${specificTimeout}")`);
155
- },
156
- };
157
- try {
158
- const device = ownSnDevice.device;
159
- if (device === undefined) {
160
- log_service_1.ServerLogService.writeLog(models_1.LogLevel.Alert, `Sonos Geräte ${ownSnDevice.name} ist nicht initialisiert`);
161
- utils_1.Utils.guardedTimeout(() => {
162
- this.initialize();
163
- }, 500, this);
164
- return;
165
- }
166
- log_service_1.ServerLogService.writeLog(models_1.LogLevel.Trace, `Spiele nun die Ausgabe für "${mp3Name}" auf "${ownSnDevice.name}"`);
167
- device.PlayNotificationTwo(options).then((played) => {
168
- ownSnDevice.log(models_1.LogLevel.Debug, `Sonos Notification ("${mp3Name}") was${played ? '' : "n't"} played (duration: "${specificTimeout}")`);
169
- });
170
- }
171
- catch (err) {
172
- log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Sonos Error ${err.message}: ${err.stack}`);
173
- }
174
- }
175
- static speakOnDevice(pMessage, ownSnDevice, volume = undefined, onlyWhenPlaying = undefined, resolveAfterRevert = undefined) {
176
- polly_service_1.PollyService.tts(pMessage, (networkPath, duration) => {
177
- SonosService.playOnDevice(ownSnDevice, networkPath, duration, volume, onlyWhenPlaying, resolveAfterRevert);
178
- });
179
- }
180
91
  static speakTestMessageOnEachDevice() {
181
92
  for (const deviceName in this.ownDevices) {
182
93
  this.ownDevices[deviceName].playTestMessage();
@@ -1,16 +1,18 @@
1
- import { DeviceInfo, DeviceType, IBaseDevice, iExcessEnergyConsumer } from '../../devices';
1
+ import { DeviceInfo, DeviceType, iAcDevice, iBaseDevice, iExcessEnergyConsumer } from '../../devices';
2
2
  import { ExcessEnergyConsumerSettings, LogLevel, RoomBase } from '../../../models';
3
3
  import { LogDebugType } from '../log-service';
4
4
  import { AcMode } from './ac-mode';
5
5
  import { AcSettings } from '../../../models/deviceSettings/acSettings';
6
6
  import { AcDeviceType } from './acDeviceType';
7
- export declare abstract class AcDevice implements iExcessEnergyConsumer, IBaseDevice {
7
+ import { DeviceCapability } from '../../devices/DeviceCapability';
8
+ export declare abstract class AcDevice implements iExcessEnergyConsumer, iBaseDevice, iAcDevice {
8
9
  ip: string;
9
10
  acDeviceType: AcDeviceType;
10
11
  currentConsumption: number;
11
12
  energyConsumerSettings: ExcessEnergyConsumerSettings;
12
13
  acSettings: AcSettings;
13
14
  room: RoomBase | undefined;
15
+ deviceCapabilities: DeviceCapability[];
14
16
  protected _info: DeviceInfo;
15
17
  protected constructor(name: string, roomName: string, ip: string, acDeviceType: AcDeviceType);
16
18
  get info(): DeviceInfo;
@@ -11,6 +11,7 @@ const log_service_1 = require("../log-service");
11
11
  const ac_mode_1 = require("./ac-mode");
12
12
  const acSettings_1 = require("../../../models/deviceSettings/acSettings");
13
13
  const lodash_1 = __importDefault(require("lodash"));
14
+ const DeviceCapability_1 = require("../../devices/DeviceCapability");
14
15
  class AcDevice {
15
16
  constructor(name, roomName, ip, acDeviceType) {
16
17
  this.ip = ip;
@@ -18,6 +19,7 @@ class AcDevice {
18
19
  this.currentConsumption = -1;
19
20
  this.energyConsumerSettings = new models_1.ExcessEnergyConsumerSettings();
20
21
  this.acSettings = new acSettings_1.AcSettings();
22
+ this.deviceCapabilities = [DeviceCapability_1.DeviceCapability.ac];
21
23
  this._activatedByExcessEnergy = false;
22
24
  this._blockAutomaticTurnOnMS = -1;
23
25
  this._info = new devices_1.DeviceInfo();
@@ -1,18 +1,18 @@
1
- import { IBaseDevice } from '../../devices';
1
+ import { iBaseDevice } from '../../devices';
2
2
  import { RoomBase } from '../../../models';
3
3
  import { LogObject } from '../log-service';
4
4
  import { AcDevice } from '../ac';
5
5
  export declare class API {
6
6
  /**
7
- * Gets the instance of an Ac Device identified by name
7
+ * Gets the instance of an Ac Device identified by id
8
8
  * @param {string} id
9
9
  * @returns {OwnDaikinDevice | undefined}
10
10
  */
11
11
  static getAc(id: string): AcDevice | undefined;
12
12
  static getDevices(): {
13
- [id: string]: IBaseDevice;
13
+ [id: string]: iBaseDevice;
14
14
  };
15
- static getDevice(id: string): IBaseDevice;
15
+ static getDevice(id: string): iBaseDevice;
16
16
  static getRooms(): Map<string, RoomBase>;
17
17
  static getRoom(id: string): RoomBase | undefined;
18
18
  static getLog(): LogObject[];
@@ -33,5 +33,22 @@ export declare class API {
33
33
  * @param {boolean} state The desired new state
34
34
  * @returns {Error | null} In case it failed the Error containing the reason
35
35
  */
36
- static setLight(deviceId: string, state: boolean): Error | null;
36
+ static setLamp(deviceId: string, state: boolean): Error | null;
37
+ /**
38
+ * Changes the status of a given actuator
39
+ * @param {string} deviceId The device Id of the actuator
40
+ * @param {boolean} state The desired new state
41
+ * @returns {Error | null} In case it failed the Error containing the reason
42
+ */
43
+ static setActuator(deviceId: string, state: boolean): Error | null;
44
+ /**
45
+ * Changes the status of a given actuator
46
+ * @param {string} deviceId The device Id of the actuator
47
+ * @param {boolean} state The desired new state
48
+ * @param timeout A chosen Timeout after which the light should be reset
49
+ * @param brightness The desired brightness
50
+ * @param transitionTime The transition time during turnOn/turnOff
51
+ * @returns {Error | null} In case it failed the Error containing the reason
52
+ */
53
+ static setDimmer(deviceId: string, state: boolean, timeout?: number, brightness?: number, transitionTime?: number): Error | null;
37
54
  }
@@ -6,15 +6,16 @@ const models_1 = require("../../../models");
6
6
  const room_service_1 = require("../room-service");
7
7
  const log_service_1 = require("../log-service");
8
8
  const ac_1 = require("../ac");
9
+ const DeviceCapability_1 = require("../../devices/DeviceCapability");
9
10
  class API {
10
11
  /**
11
- * Gets the instance of an Ac Device identified by name
12
+ * Gets the instance of an Ac Device identified by id
12
13
  * @param {string} id
13
14
  * @returns {OwnDaikinDevice | undefined}
14
15
  */
15
16
  static getAc(id) {
16
17
  const result = this.getDevice(id);
17
- if ((result === null || result === void 0 ? void 0 : result.deviceType) !== devices_1.DeviceType.Daikin) {
18
+ if (!result.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.ac)) {
18
19
  return undefined;
19
20
  }
20
21
  return result;
@@ -48,7 +49,11 @@ class API {
48
49
  static setAc(id, desiredState) {
49
50
  const d = this.getAc(id);
50
51
  if (!d) {
51
- log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Daikin Device for name ${name} not found`);
52
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `AC Device for id ${id} not found`);
53
+ return false;
54
+ }
55
+ if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.ac)) {
56
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Device for id ${id} is not an ac`);
52
57
  return false;
53
58
  }
54
59
  if (desiredState) {
@@ -72,16 +77,53 @@ class API {
72
77
  * @param {boolean} state The desired new state
73
78
  * @returns {Error | null} In case it failed the Error containing the reason
74
79
  */
75
- static setLight(deviceId, state) {
80
+ static setLamp(deviceId, state) {
76
81
  const d = this.getDevice(deviceId);
77
82
  if (d === undefined) {
78
83
  return new Error(`Device with ID ${deviceId} not found`);
79
84
  }
80
- if (typeof d.setLight !== 'function') {
85
+ if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.lamp)) {
81
86
  return new Error(`Device with ID ${deviceId} is no Lamp`);
82
87
  }
83
88
  d.setLight(state, 60 * 60 * 1000, true);
84
89
  return null;
85
90
  }
91
+ /**
92
+ * Changes the status of a given actuator
93
+ * @param {string} deviceId The device Id of the actuator
94
+ * @param {boolean} state The desired new state
95
+ * @returns {Error | null} In case it failed the Error containing the reason
96
+ */
97
+ static setActuator(deviceId, state) {
98
+ const d = this.getDevice(deviceId);
99
+ if (d === undefined) {
100
+ return new Error(`Device with ID ${deviceId} not found`);
101
+ }
102
+ if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.actuator)) {
103
+ return new Error(`Device with ID ${deviceId} is no actuator`);
104
+ }
105
+ d.setActuator(state, 60 * 60 * 1000, true);
106
+ return null;
107
+ }
108
+ /**
109
+ * Changes the status of a given actuator
110
+ * @param {string} deviceId The device Id of the actuator
111
+ * @param {boolean} state The desired new state
112
+ * @param timeout A chosen Timeout after which the light should be reset
113
+ * @param brightness The desired brightness
114
+ * @param transitionTime The transition time during turnOn/turnOff
115
+ * @returns {Error | null} In case it failed the Error containing the reason
116
+ */
117
+ static setDimmer(deviceId, state, timeout, brightness, transitionTime) {
118
+ const d = this.getDevice(deviceId);
119
+ if (d === undefined) {
120
+ return new Error(`Device with ID ${deviceId} not found`);
121
+ }
122
+ if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.dimmablelamp)) {
123
+ return new Error(`Device with ID ${deviceId} is no dimmablelamp`);
124
+ }
125
+ d.setLight(state, timeout, true, brightness, transitionTime);
126
+ return null;
127
+ }
86
128
  }
87
129
  exports.API = API;
@@ -1,11 +1,11 @@
1
- import { OwnSonosDevice } from '../Sonos';
1
+ import { ISpeaker } from '../../devices';
2
2
  export declare class MuellTonne {
3
3
  name: string;
4
- ownSonosDevice?: OwnSonosDevice | undefined;
4
+ ownSpeaker?: ISpeaker | undefined;
5
5
  static oneDay: number;
6
6
  nextDate: Date | undefined;
7
7
  dates: Date[];
8
- constructor(name: string, ownSonosDevice?: OwnSonosDevice | undefined);
8
+ constructor(name: string, ownSpeaker?: ISpeaker | undefined);
9
9
  sortDates(): void;
10
10
  removePassedDates(): void;
11
11
  check(): void;
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MuellTonne = void 0;
4
- const Sonos_1 = require("../Sonos");
5
4
  const log_service_1 = require("../log-service");
6
5
  const Telegram_1 = require("../Telegram");
7
6
  const models_1 = require("../../../models");
8
7
  class MuellTonne {
9
- constructor(name, ownSonosDevice) {
8
+ constructor(name, ownSpeaker) {
10
9
  this.name = name;
11
- this.ownSonosDevice = ownSonosDevice;
10
+ this.ownSpeaker = ownSpeaker;
12
11
  this.nextDate = undefined;
13
12
  this.dates = [];
14
13
  }
@@ -27,6 +26,7 @@ class MuellTonne {
27
26
  this.nextDate = this.dates[0];
28
27
  }
29
28
  check() {
29
+ var _a, _b, _c;
30
30
  this.removePassedDates();
31
31
  if (this.nextDate === undefined) {
32
32
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Alert, `Die Mülltonne mit dem Namen ${this.name} hat keine nächste Abholung!`);
@@ -46,25 +46,19 @@ class MuellTonne {
46
46
  if (nextTimestamp >= tomorowMidnight) {
47
47
  const message = `Die Mülltonne mit dem Namen ${this.name} wird morgen abgeholt!`;
48
48
  Telegram_1.TelegramService.inform(message);
49
- if (this.ownSonosDevice) {
50
- Sonos_1.SonosService.speakOnDevice(message, this.ownSonosDevice, 30);
51
- }
49
+ (_a = this.ownSpeaker) === null || _a === void 0 ? void 0 : _a.speakOnDevice(message, 30);
52
50
  return;
53
51
  }
54
52
  if (nextTimestamp >= todayMidnight) {
55
53
  if (new Date().getHours() > 10) {
56
54
  const message = `Die Mülltonne mit dem Namen ${this.name} wurde heute abgeholt, Mülltonne zurückstellen!`;
57
55
  Telegram_1.TelegramService.inform(message);
58
- if (this.ownSonosDevice) {
59
- Sonos_1.SonosService.speakOnDevice(message, this.ownSonosDevice, 30);
60
- }
56
+ (_b = this.ownSpeaker) === null || _b === void 0 ? void 0 : _b.speakOnDevice(message, 30);
61
57
  }
62
58
  else {
63
59
  const message = `Die Mülltonne mit dem Namen ${this.name} wird heute abgeholt!`;
64
60
  Telegram_1.TelegramService.inform(message);
65
- if (this.ownSonosDevice) {
66
- Sonos_1.SonosService.speakOnDevice(message, this.ownSonosDevice, 30);
67
- }
61
+ (_c = this.ownSpeaker) === null || _c === void 0 ? void 0 : _c.speakOnDevice(message, 30);
68
62
  }
69
63
  return;
70
64
  }
@@ -1,7 +1,7 @@
1
1
  import { TimeCallback } from '../../../models';
2
2
  import { iMuellSettings } from '../../config';
3
- import { OwnSonosDevice } from '../Sonos';
4
3
  import { MuellTonne } from './muell-tonne';
4
+ import { ISpeaker } from '../../devices';
5
5
  export declare class MuellService {
6
6
  static alleTonnen: Array<{
7
7
  name: string;
@@ -18,8 +18,8 @@ export declare class MuellService {
18
18
  private static lastCheck;
19
19
  private static _calendarURL;
20
20
  private static _active;
21
- private static defaultSonosDevice;
22
- static intialize(config: iMuellSettings, defaultSonosDevice: OwnSonosDevice | undefined): void;
21
+ private static defaultSpeaker;
22
+ static intialize(config: iMuellSettings, defaultSpeaker: ISpeaker | undefined): void;
23
23
  static updateCalendar(checkAfterwards?: boolean): void;
24
24
  static checkAll(pRetries?: number): void;
25
25
  }
@@ -8,8 +8,8 @@ const utils_1 = require("../utils");
8
8
  const muell_tonne_1 = require("./muell-tonne");
9
9
  const time_callback_service_1 = require("../time-callback-service");
10
10
  class MuellService {
11
- static intialize(config, defaultSonosDevice) {
12
- this.defaultSonosDevice = defaultSonosDevice;
11
+ static intialize(config, defaultSpeaker) {
12
+ this.defaultSpeaker = defaultSpeaker;
13
13
  this._active = true;
14
14
  this._calendarURL = config.calendarURL;
15
15
  this.updateTimeCallback = new models_1.TimeCallback('MuelltonnenServiceUpdater', models_1.TimeCallbackType.TimeOfDay, () => {
@@ -28,10 +28,10 @@ class MuellService {
28
28
  .fromURL(this._calendarURL)
29
29
  .then((data) => {
30
30
  this.loadingPending = false;
31
- this.gelbeTonne = new muell_tonne_1.MuellTonne('Gelbe Tonne', this.defaultSonosDevice);
32
- this.graueTonne = new muell_tonne_1.MuellTonne('Graue Tonne', this.defaultSonosDevice);
33
- this.blaueTonne = new muell_tonne_1.MuellTonne('Blaue Tonne', this.defaultSonosDevice);
34
- this.brauneTonne = new muell_tonne_1.MuellTonne('Braune Tonne', this.defaultSonosDevice);
31
+ this.gelbeTonne = new muell_tonne_1.MuellTonne('Gelbe Tonne', this.defaultSpeaker);
32
+ this.graueTonne = new muell_tonne_1.MuellTonne('Graue Tonne', this.defaultSpeaker);
33
+ this.blaueTonne = new muell_tonne_1.MuellTonne('Blaue Tonne', this.defaultSpeaker);
34
+ this.brauneTonne = new muell_tonne_1.MuellTonne('Braune Tonne', this.defaultSpeaker);
35
35
  this.alleTonnen = [];
36
36
  const todayMidnight = new Date().setHours(0, 0, 0, 0);
37
37
  for (const k in data) {
@@ -112,4 +112,4 @@ MuellService.loadingPending = true;
112
112
  MuellService.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
113
113
  MuellService.lastCheck = new Date(0);
114
114
  MuellService._active = false;
115
- MuellService.defaultSonosDevice = undefined;
115
+ MuellService.defaultSpeaker = undefined;
@@ -1,5 +1,5 @@
1
- import { OwnSonosDevice } from './Sonos';
2
1
  import { iNewsSettings } from '../config';
2
+ import { ISpeaker } from '../devices';
3
3
  export declare class NewsService {
4
4
  static lastNewsAudioFile: string;
5
5
  private static readonly newsFilePrefix;
@@ -25,11 +25,11 @@ export declare class NewsService {
25
25
  static getLatestNews(): void;
26
26
  /**
27
27
  * Plays the latest news on a sonos device
28
- * @param ownSonosDevice Sonos device to play from
28
+ * @param speaker Sonos device to play from
29
29
  * @param volume volume to play at
30
30
  * @param retries Number of times playing should be tried if there is currently no audio file available
31
31
  */
32
- static playLastNews(ownSonosDevice: OwnSonosDevice, volume?: number, retries?: number): void;
32
+ static playLastNews(speaker: ISpeaker, volume?: number, retries?: number): void;
33
33
  private static downloadLatestFileFromFeed;
34
34
  /**
35
35
  * Deletes all files in the given directory that are older than the given age.
@@ -96,18 +96,18 @@ class NewsService {
96
96
  }
97
97
  /**
98
98
  * Plays the latest news on a sonos device
99
- * @param ownSonosDevice Sonos device to play from
99
+ * @param speaker Sonos device to play from
100
100
  * @param volume volume to play at
101
101
  * @param retries Number of times playing should be tried if there is currently no audio file available
102
102
  */
103
- static playLastNews(ownSonosDevice, volume = 30, retries = 5) {
103
+ static playLastNews(speaker, volume = 30, retries = 5) {
104
104
  if (!NewsService.lastNewsAudioFile) {
105
105
  if (retries > 0) {
106
106
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Service not ready yet --> waiting, remaining tries: ${retries - 1}`, {
107
107
  source: logSource_1.LogSource.News,
108
108
  });
109
109
  utils_1.Utils.guardedTimeout(() => {
110
- NewsService.playLastNews(ownSonosDevice, volume, retries - 1);
110
+ NewsService.playLastNews(speaker, volume, retries - 1);
111
111
  }, 1000);
112
112
  }
113
113
  else {
@@ -117,7 +117,7 @@ class NewsService {
117
117
  }
118
118
  return;
119
119
  }
120
- Sonos_1.SonosService.playOnDevice(ownSonosDevice, path_1.default.basename(NewsService.lastNewsAudioFile, path_1.default.extname(NewsService.lastNewsAudioFile)), Sonos_1.PollyService.getDuration(NewsService.lastNewsAudioFile), volume);
120
+ speaker.playOnDevice(path_1.default.basename(NewsService.lastNewsAudioFile, path_1.default.extname(NewsService.lastNewsAudioFile)), Sonos_1.PollyService.getDuration(NewsService.lastNewsAudioFile), volume);
121
121
  }
122
122
  static downloadLatestFileFromFeed(rssUrl, targetDir) {
123
123
  const parser = new rss_parser_1.default();
@@ -1,6 +1,6 @@
1
1
  import { ringStorage } from '../utils';
2
2
  import { iRoomBase, RoomBase } from '../../../models';
3
- import { IBaseDevice } from '../../devices';
3
+ import { iBaseDevice } from '../../devices';
4
4
  export declare class RoomService {
5
5
  static Rooms: Map<string, RoomBase>;
6
6
  static awayModeActive: boolean;
@@ -25,12 +25,13 @@ export declare class RoomService {
25
25
  * !!floor -1 sets all lamps in house instead!!
26
26
  * @param floor the level on which all lamps shall be changed -1 equals all rooms
27
27
  * @param status
28
+ * @param timeout
28
29
  */
29
30
  static setAllLampsOfFloor(floor: number, status?: boolean, timeout?: number): void;
30
31
  static clearAllAlarms(): void;
31
32
  static startAwayMode(): void;
32
33
  static startNightAlarmMode(): void;
33
- static startIntrusionAlarm(room: iRoomBase, device: IBaseDevice): void;
34
+ static startIntrusionAlarm(room: iRoomBase, device: iBaseDevice): void;
34
35
  static endAlarmModes(): void;
35
36
  static getLastMovements(): string;
36
37
  private static stopIntrusionAlarm;
@@ -32,6 +32,7 @@ class RoomService {
32
32
  * !!floor -1 sets all lamps in house instead!!
33
33
  * @param floor the level on which all lamps shall be changed -1 equals all rooms
34
34
  * @param status
35
+ * @param timeout
35
36
  */
36
37
  static setAllLampsOfFloor(floor, status = false, timeout) {
37
38
  var _a, _b, _c, _d;