hoffmation-base 1.0.39 → 1.0.43

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 (70) 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/DeviceCapabilities.d.ts +15 -0
  4. package/lib/server/devices/DeviceCapabilities.js +19 -0
  5. package/lib/server/devices/IoBrokerBaseDevice.d.ts +2 -0
  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/iBaseDevice.d.ts +2 -0
  10. package/lib/server/devices/baseDeviceInterfaces/iSpeaker.d.ts +8 -0
  11. package/lib/server/devices/baseDeviceInterfaces/iSpeaker.js +2 -0
  12. package/lib/server/devices/baseDeviceInterfaces/index.d.ts +2 -0
  13. package/lib/server/devices/baseDeviceInterfaces/index.js +2 -0
  14. package/lib/server/devices/device-cluster.d.ts +1 -2
  15. package/lib/server/devices/device-cluster.js +6 -0
  16. package/lib/server/devices/device-list.d.ts +2 -4
  17. package/lib/server/devices/device-list.js +4 -13
  18. package/lib/server/devices/groups/heatGroup.js +1 -1
  19. package/lib/server/devices/groups/index.d.ts +1 -1
  20. package/lib/server/devices/groups/index.js +1 -1
  21. package/lib/server/devices/groups/{sonosGroup.d.ts → speakerGroup.d.ts} +3 -3
  22. package/lib/server/devices/groups/{sonosGroup.js → speakerGroup.js} +6 -8
  23. package/lib/server/devices/hmIPDevices/hmIpBewegung.js +3 -0
  24. package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.js +4 -0
  25. package/lib/server/devices/hmIPDevices/hmIpLampe.js +2 -0
  26. package/lib/server/devices/hmIPDevices/hmIpPraezenz.js +3 -0
  27. package/lib/server/devices/hmIPDevices/hmIpRoll.js +2 -0
  28. package/lib/server/devices/hmIPDevices/hmIpTaster.js +2 -0
  29. package/lib/server/devices/hmIPDevices/hmIpWippe.js +2 -0
  30. package/lib/server/devices/jsObject/jsObjectEnergyManager.js +2 -0
  31. package/lib/server/devices/zigbee/BaseDevices/index.d.ts +1 -0
  32. package/lib/server/devices/zigbee/BaseDevices/index.js +1 -0
  33. package/lib/server/devices/zigbee/BaseDevices/zigbeeHeater.js +2 -0
  34. package/lib/server/devices/zigbee/{zigbeeMotionSensor.d.ts → BaseDevices/zigbeeMotionSensor.d.ts} +5 -5
  35. package/lib/server/devices/zigbee/{zigbeeMotionSensor.js → BaseDevices/zigbeeMotionSensor.js} +6 -4
  36. package/lib/server/devices/zigbee/BaseDevices/zigbeeShutter.js +2 -0
  37. package/lib/server/devices/zigbee/index.d.ts +0 -1
  38. package/lib/server/devices/zigbee/index.js +0 -1
  39. package/lib/server/devices/zigbee/zigbeeAquaraMotion.d.ts +1 -1
  40. package/lib/server/devices/zigbee/zigbeeAquaraMotion.js +4 -2
  41. package/lib/server/devices/zigbee/zigbeeAquaraVibra.js +2 -0
  42. package/lib/server/devices/zigbee/zigbeeBlitzShp.js +2 -0
  43. package/lib/server/devices/zigbee/zigbeeIlluDimmer.js +2 -0
  44. package/lib/server/devices/zigbee/zigbeeIlluLampe.js +2 -0
  45. package/lib/server/devices/zigbee/zigbeeSonoffMotion.d.ts +1 -1
  46. package/lib/server/devices/zigbee/zigbeeSonoffMotion.js +2 -2
  47. package/lib/server/devices/zigbee/zigbeeSonoffTemp.js +3 -0
  48. package/lib/server/devices/zigbee/zigbeeUbisysShutter.d.ts +1 -1
  49. package/lib/server/services/Sonos/OwnSonosDevices.d.ts +1 -1
  50. package/lib/server/services/Sonos/OwnSonosDevices.js +1 -1
  51. package/lib/server/services/Sonos/index.d.ts +1 -0
  52. package/lib/server/services/Sonos/index.js +3 -0
  53. package/lib/server/services/Sonos/own-sonos-device.d.ts +26 -0
  54. package/lib/server/services/Sonos/own-sonos-device.js +108 -0
  55. package/lib/server/services/Sonos/sonos-service.d.ts +1 -20
  56. package/lib/server/services/Sonos/sonos-service.js +5 -94
  57. package/lib/server/services/ac/ac-device.d.ts +4 -2
  58. package/lib/server/services/ac/ac-device.js +6 -1
  59. package/lib/server/services/api/api-service.d.ts +6 -6
  60. package/lib/server/services/api/api-service.js +13 -9
  61. package/lib/server/services/calendar/muell-tonne.d.ts +3 -3
  62. package/lib/server/services/calendar/muell-tonne.js +6 -12
  63. package/lib/server/services/calendar/m/303/274ll-service.d.ts +3 -3
  64. package/lib/server/services/calendar/m/303/274ll-service.js +7 -7
  65. package/lib/server/services/news-service.d.ts +3 -3
  66. package/lib/server/services/news-service.js +4 -4
  67. package/lib/server/services/weather/weather-service.d.ts +2 -2
  68. package/lib/server/services/weather/weather-service.js +14 -15
  69. package/lib/tsconfig.tsbuildinfo +1 -1
  70. package/package.json +1 -1
@@ -5,6 +5,7 @@ const deviceType_1 = require("../deviceType");
5
5
  const services_1 = require("../../services");
6
6
  const models_1 = require("../../../models");
7
7
  const BaseDevices_1 = require("./BaseDevices");
8
+ const DeviceCapabilities_1 = require("../DeviceCapabilities");
8
9
  class ZigbeeAquaraVibra extends BaseDevices_1.ZigbeeDevice {
9
10
  constructor(pInfo) {
10
11
  super(pInfo, deviceType_1.DeviceType.ZigbeeAquaraVibra);
@@ -23,6 +24,7 @@ class ZigbeeAquaraVibra extends BaseDevices_1.ZigbeeDevice {
23
24
  // TODO Set Sensitivity
24
25
  this._vibrationBlockedByGriff = false;
25
26
  this._vibrationBlockedByMotion = false;
27
+ this.deviceCapabilities.push(DeviceCapabilities_1.DeviceCapabilities.vibrationSensor);
26
28
  this._alarmMessage = services_1.Res.vibrationAlarm(this.info.customName);
27
29
  services_1.PollyService.preloadTTS(this._alarmMessage);
28
30
  this._idSensitivity = `${this.info.fullID}.sensitivity`;
@@ -4,6 +4,7 @@ exports.ZigbeeBlitzShp = void 0;
4
4
  const deviceType_1 = require("../deviceType");
5
5
  const models_1 = require("../../../models");
6
6
  const BaseDevices_1 = require("./BaseDevices");
7
+ const DeviceCapabilities_1 = require("../DeviceCapabilities");
7
8
  class ZigbeeBlitzShp extends BaseDevices_1.ZigbeeDevice {
8
9
  constructor(pInfo) {
9
10
  super(pInfo, deviceType_1.DeviceType.ZigbeeBlitzShp);
@@ -16,6 +17,7 @@ class ZigbeeBlitzShp extends BaseDevices_1.ZigbeeDevice {
16
17
  this._availableForExcessEnergy = true;
17
18
  this.steckerOnSwitchID = '';
18
19
  this._activatedByExcessEnergy = false;
20
+ this.deviceCapabilities.push(DeviceCapabilities_1.DeviceCapabilities.excessEnergyConsumer);
19
21
  this.steckerOnSwitchID = `${this.info.fullID}.state`;
20
22
  }
21
23
  get currentConsumption() {
@@ -5,6 +5,7 @@ const models_1 = require("../../../models");
5
5
  const deviceType_1 = require("../deviceType");
6
6
  const services_1 = require("../../services");
7
7
  const BaseDevices_1 = require("./BaseDevices");
8
+ const DeviceCapabilities_1 = require("../DeviceCapabilities");
8
9
  class ZigbeeIlluDimmer extends BaseDevices_1.ZigbeeDevice {
9
10
  constructor(pInfo) {
10
11
  super(pInfo, deviceType_1.DeviceType.ZigbeeIlluDimmer);
@@ -18,6 +19,7 @@ class ZigbeeIlluDimmer extends BaseDevices_1.ZigbeeDevice {
18
19
  this.transitionID = 'transition_time';
19
20
  this._turnOffTimeout = undefined;
20
21
  this.turnOffTime = 0;
22
+ this.deviceCapabilities.push(DeviceCapabilities_1.DeviceCapabilities.lamp);
21
23
  this.stateID = `${this.info.fullID}.state`;
22
24
  this.brightnessID = `${this.info.fullID}.brightness`;
23
25
  this.transitionID = `${this.info.fullID}.transition_time`;
@@ -5,9 +5,11 @@ const deviceType_1 = require("../deviceType");
5
5
  const zigbeeIlluActuator_1 = require("./zigbeeIlluActuator");
6
6
  const models_1 = require("../../../models");
7
7
  const services_1 = require("../../services");
8
+ const DeviceCapabilities_1 = require("../DeviceCapabilities");
8
9
  class ZigbeeIlluLampe extends zigbeeIlluActuator_1.ZigbeeIlluActuator {
9
10
  constructor(pInfo) {
10
11
  super(pInfo, deviceType_1.DeviceType.ZigbeeIlluLampe);
12
+ this.deviceCapabilities.push(DeviceCapabilities_1.DeviceCapabilities.lamp);
11
13
  }
12
14
  get lightOn() {
13
15
  return super.actuatorOn;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="iobroker" />
2
- import { ZigbeeMotionSensor } from './zigbeeMotionSensor';
2
+ import { ZigbeeMotionSensor } from './BaseDevices';
3
3
  import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
4
4
  export declare class ZigbeeSonoffMotion extends ZigbeeMotionSensor {
5
5
  constructor(pInfo: IoBrokerDeviceInfo);
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZigbeeSonoffMotion = void 0;
4
4
  const deviceType_1 = require("../deviceType");
5
5
  const models_1 = require("../../../models");
6
- const zigbeeMotionSensor_1 = require("./zigbeeMotionSensor");
7
- class ZigbeeSonoffMotion extends zigbeeMotionSensor_1.ZigbeeMotionSensor {
6
+ const BaseDevices_1 = require("./BaseDevices");
7
+ class ZigbeeSonoffMotion extends BaseDevices_1.ZigbeeMotionSensor {
8
8
  constructor(pInfo) {
9
9
  super(pInfo, deviceType_1.DeviceType.ZigbeeSonoffMotion);
10
10
  this._needsMovementResetFallback = false;
@@ -4,6 +4,7 @@ exports.ZigbeeSonoffTemp = void 0;
4
4
  const BaseDevices_1 = require("./BaseDevices");
5
5
  const baseDeviceInterfaces_1 = require("../baseDeviceInterfaces");
6
6
  const deviceType_1 = require("../deviceType");
7
+ const DeviceCapabilities_1 = require("../DeviceCapabilities");
7
8
  class ZigbeeSonoffTemp extends BaseDevices_1.ZigbeeDevice {
8
9
  constructor(pInfo) {
9
10
  super(pInfo, deviceType_1.DeviceType.ZigbeeSonoffTemp);
@@ -11,6 +12,8 @@ class ZigbeeSonoffTemp extends BaseDevices_1.ZigbeeDevice {
11
12
  this._temperaturCallbacks = [];
12
13
  this._humidity = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
13
14
  this._temperature = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
15
+ this.deviceCapabilities.push(DeviceCapabilities_1.DeviceCapabilities.temperatureSensor);
16
+ this.deviceCapabilities.push(DeviceCapabilities_1.DeviceCapabilities.humiditySensor);
14
17
  }
15
18
  get humidity() {
16
19
  return this._humidity;
@@ -2,7 +2,7 @@
2
2
  import { ZigbeeShutter } from './BaseDevices';
3
3
  import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
4
4
  export declare class ZigbeeUbisysShutter extends ZigbeeShutter {
5
- private _positionStateId;
5
+ private readonly _positionStateId;
6
6
  constructor(pInfo: IoBrokerDeviceInfo);
7
7
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
8
8
  protected moveToPosition(pPosition: number): void;
@@ -1,4 +1,4 @@
1
- import { OwnSonosDevice } from './sonos-service';
1
+ import { OwnSonosDevice } from './own-sonos-device';
2
2
  export declare class OwnSonosDevices {
3
3
  static ownDevices: {
4
4
  [name: string]: OwnSonosDevice;
@@ -6,7 +6,7 @@ const models_1 = require("../../../models");
6
6
  class OwnSonosDevices {
7
7
  static addDevice(device) {
8
8
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Device ${device.name} for room "${device.info.room}" addded`);
9
- this.ownDevices[device.name] = device;
9
+ this.ownDevices[device.discoveryName] = device;
10
10
  }
11
11
  }
12
12
  exports.OwnSonosDevices = OwnSonosDevices;
@@ -2,3 +2,4 @@ export * from './mp3-server';
2
2
  export * from './OwnSonosDevices';
3
3
  export * from './polly-service';
4
4
  export * from './sonos-service';
5
+ export { OwnSonosDevice } from './own-sonos-device';
@@ -14,7 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.OwnSonosDevice = void 0;
17
18
  __exportStar(require("./mp3-server"), exports);
18
19
  __exportStar(require("./OwnSonosDevices"), exports);
19
20
  __exportStar(require("./polly-service"), exports);
20
21
  __exportStar(require("./sonos-service"), exports);
22
+ var own_sonos_device_1 = require("./own-sonos-device");
23
+ Object.defineProperty(exports, "OwnSonosDevice", { enumerable: true, get: function () { return own_sonos_device_1.OwnSonosDevice; } });
@@ -0,0 +1,26 @@
1
+ import { DeviceInfo, DeviceType, ISpeaker } from '../../devices';
2
+ import { LogLevel, RoomBase } from '../../../models';
3
+ import { SonosDevice } from '@svrooij/sonos/lib';
4
+ import { LogDebugType } from '../log-service';
5
+ import { DeviceCapabilities } from '../../devices/DeviceCapabilities';
6
+ export declare class OwnSonosDevice implements ISpeaker {
7
+ device: SonosDevice | undefined;
8
+ maxPlayOnAllVolume: number;
9
+ room: RoomBase | undefined;
10
+ readonly deviceType: DeviceType;
11
+ readonly discoveryName: string;
12
+ readonly deviceCapabilities: DeviceCapabilities[];
13
+ constructor(discoveryName: string, roomName: string, device: SonosDevice | undefined);
14
+ protected _info: DeviceInfo;
15
+ get info(): DeviceInfo;
16
+ set info(info: DeviceInfo);
17
+ get id(): string;
18
+ get name(): string;
19
+ playOnDevice(mp3Name: string, duration: number, volume?: number | undefined, onlyWhenPlaying?: boolean | undefined, resolveAfterRevert?: boolean | undefined): void;
20
+ playTestMessage(): void;
21
+ speakOnDevice(pMessage: string, volume?: number | undefined, onlyWhenPlaying?: boolean | undefined, resolveAfterRevert?: boolean | undefined): void;
22
+ stop(): void;
23
+ playUrl(url: string): void;
24
+ log(level: LogLevel, message: string, debugType?: LogDebugType): void;
25
+ toJSON(): Partial<OwnSonosDevice>;
26
+ }
@@ -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 DeviceCapabilities_1 = require("../../devices/DeviceCapabilities");
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 = [DeviceCapabilities_1.DeviceCapabilities.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 { DeviceCapabilities } from '../../devices/DeviceCapabilities';
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: DeviceCapabilities[];
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 DeviceCapabilities_1 = require("../../devices/DeviceCapabilities");
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 = [DeviceCapabilities_1.DeviceCapabilities.ac];
21
23
  this._activatedByExcessEnergy = false;
22
24
  this._blockAutomaticTurnOnMS = -1;
23
25
  this._info = new devices_1.DeviceInfo();
@@ -111,7 +113,10 @@ class AcDevice {
111
113
  }
112
114
  }
113
115
  toJSON() {
114
- return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['room']));
116
+ // eslint-disable-next-line
117
+ const result = lodash_1.default.omit(this, ['room']);
118
+ result['on'] = this.on;
119
+ return utils_1.Utils.jsonFilter(result);
115
120
  }
116
121
  }
117
122
  exports.AcDevice = AcDevice;
@@ -4,11 +4,11 @@ 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
8
- * @param {string} name
7
+ * Gets the instance of an Ac Device identified by id
8
+ * @param {string} id
9
9
  * @returns {OwnDaikinDevice | undefined}
10
10
  */
11
- static getAc(name: string): AcDevice | undefined;
11
+ static getAc(id: string): AcDevice | undefined;
12
12
  static getDevices(): {
13
13
  [id: string]: IBaseDevice;
14
14
  };
@@ -17,11 +17,11 @@ export declare class API {
17
17
  static getRoom(id: string): RoomBase | undefined;
18
18
  static getLog(): LogObject[];
19
19
  /**
20
- * Turns on/off one AC identified by it's name
21
- * @param name The name of the device, if wrong false will be returned
20
+ * Turns on/off one AC identified by it's id
21
+ * @param id The id of the device, if wrong false will be returned
22
22
  * @param {boolean} desiredState
23
23
  */
24
- static setAc(name: string, desiredState: boolean): boolean;
24
+ static setAc(id: string, desiredState: boolean): boolean;
25
25
  /**
26
26
  * Turns on/off all AC´s in the home
27
27
  * @param {boolean} desiredState
@@ -8,12 +8,16 @@ const log_service_1 = require("../log-service");
8
8
  const ac_1 = require("../ac");
9
9
  class API {
10
10
  /**
11
- * Gets the instance of an Ac Device identified by name
12
- * @param {string} name
11
+ * Gets the instance of an Ac Device identified by id
12
+ * @param {string} id
13
13
  * @returns {OwnDaikinDevice | undefined}
14
14
  */
15
- static getAc(name) {
16
- return ac_1.OwnAcDevices.ownDevices[name];
15
+ static getAc(id) {
16
+ const result = this.getDevice(id);
17
+ if ((result === null || result === void 0 ? void 0 : result.deviceType) !== devices_1.DeviceType.Daikin) {
18
+ return undefined;
19
+ }
20
+ return result;
17
21
  }
18
22
  static getDevices() {
19
23
  // console.log(Util.inspect(Devices.alLDevices, false, 5));
@@ -37,14 +41,14 @@ class API {
37
41
  return log_service_1.ServerLogService.getLog();
38
42
  }
39
43
  /**
40
- * Turns on/off one AC identified by it's name
41
- * @param name The name of the device, if wrong false will be returned
44
+ * Turns on/off one AC identified by it's id
45
+ * @param id The id of the device, if wrong false will be returned
42
46
  * @param {boolean} desiredState
43
47
  */
44
- static setAc(name, desiredState) {
45
- const d = this.getAc(name);
48
+ static setAc(id, desiredState) {
49
+ const d = this.getAc(id);
46
50
  if (!d) {
47
- log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Daikin Device for name ${name} not found`);
51
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Daikin Device for id ${id} not found`);
48
52
  return false;
49
53
  }
50
54
  if (desiredState) {
@@ -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
  }