hoffmation-base 0.1.0 → 0.1.4

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.
@@ -1,4 +1,4 @@
1
- import { iTemperaturDataPoint } from "../iTemperaturDataPoint";
1
+ import { iTemperaturDataPoint } from '../iTemperaturDataPoint';
2
2
 
3
3
  export class TemperaturDataPoint implements iTemperaturDataPoint {
4
4
  constructor(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hoffmation-base",
3
3
  "description": "Base Libraries and functions for own Hoffmation projects",
4
- "version": "0.1.0",
4
+ "version": "0.1.4",
5
5
  "main": "index.js",
6
6
  "repository": {
7
7
  "type": "git",
@@ -8,7 +8,7 @@ import { IOBrokerConnection } from './connection';
8
8
  import { ConnectionCallbacks } from '../../models/connectionCallbacks';
9
9
  import { RoomBase } from '../../models/rooms/RoomBase';
10
10
  import { Utils } from '../services/utils/utils';
11
- import { SettingsService } from "../services/settings-service";
11
+ import { SettingsService } from '../services/settings-service';
12
12
 
13
13
  export class ioBrokerMain {
14
14
  private static roomConstructors: { [roomName: string]: { new (): RoomBase } } = {};
@@ -0,0 +1,9 @@
1
+ import { OwnSonosDevice } from './sonos-service';
2
+
3
+ export class OwnSonosDevices {
4
+ public static ownDevices: { [name: string]: OwnSonosDevice } = {};
5
+
6
+ public static addDevice(device: OwnSonosDevice) {
7
+ this.ownDevices[device.name] = device;
8
+ }
9
+ }
@@ -13,11 +13,7 @@ export class OwnSonosDevice {
13
13
  public playTestMessage() {
14
14
  SonosService.speakOnDevice(`Ich bin ${this.name}`, this);
15
15
  }
16
- public constructor(
17
- public name: string,
18
- public roomName: string,
19
- public device: SonosDevice | undefined,
20
- ) {};
16
+ public constructor(public name: string, public roomName: string, public device: SonosDevice | undefined) {}
21
17
  }
22
18
 
23
19
  export class SonosService {
@@ -32,7 +28,7 @@ export class SonosService {
32
28
 
33
29
  public static addOwnDevices(
34
30
  snDevices: { [name: string]: OwnSonosDevice },
35
- reinitializationDevice?: OwnSonosDevice
31
+ reinitializationDevice?: OwnSonosDevice,
36
32
  ): void {
37
33
  this.ownDevices = snDevices;
38
34
  this.reinitializationDevice = reinitializationDevice;
@@ -71,7 +67,7 @@ export class SonosService {
71
67
  this.speakOnDevice(
72
68
  `Sonos System initialisiert und bereit für Sprachausgaben.`,
73
69
  this.reinitializationDevice,
74
- 30
70
+ 30,
75
71
  );
76
72
  }
77
73
  })
@@ -83,18 +79,18 @@ export class SonosService {
83
79
  try {
84
80
  for (const deviceName in this.ownDevices) {
85
81
  currentDevice = this.ownDevices[deviceName];
86
- if(currentDevice?.device === undefined) {
82
+ if (currentDevice?.device === undefined) {
87
83
  throw `${currentDevice?.name} is missing`;
88
84
  }
89
85
  await currentDevice.device.GetState();
90
86
  }
91
- if(currentDevice !== undefined) {
87
+ if (currentDevice !== undefined) {
92
88
  ServerLogService.writeLog(LogLevel.Info, `Alle Geräte okay --> Last checked ${currentDevice.name}`);
93
89
  }
94
90
  } catch (e) {
95
91
  ServerLogService.writeLog(
96
92
  LogLevel.Error,
97
- `Atleast one device failed --> Last checked ${(currentDevice?.name ?? "undefined")}`
93
+ `Atleast one device failed --> Last checked ${currentDevice?.name ?? 'undefined'}`,
98
94
  );
99
95
  TelegramService.inform(`Sonos device is failing --> Reinitialize whole system`);
100
96
  this.initialize(true);
@@ -107,14 +103,14 @@ export class SonosService {
107
103
  }
108
104
  PollyService.tts(pMessage, (networkPath: string, duration: number) => {
109
105
  const hours: number = new Date().getHours();
110
- let volume: number = hours < 10 || hours > 22 ? 40 : 80;
106
+ const volume: number = hours < 10 || hours > 22 ? 40 : 80;
111
107
 
112
108
  for (const deviceName in this.ownDevices) {
113
109
  SonosService.playOnDevice(
114
110
  this.ownDevices[deviceName],
115
111
  networkPath,
116
112
  duration,
117
- (volumeOverride > -1) ? volumeOverride : Math.min(volume, this.ownDevices[deviceName].maxPlayOnAllVolume)
113
+ volumeOverride > -1 ? volumeOverride : Math.min(volume, this.ownDevices[deviceName].maxPlayOnAllVolume),
118
114
  );
119
115
  }
120
116
  });
@@ -139,12 +135,14 @@ export class SonosService {
139
135
  notificationFired: (played) => {
140
136
  ServerLogService.writeLog(
141
137
  LogLevel.Trace,
142
- `Sonos Notification ("${mp3Name}") was${played ? '' : "n't"} played in ${ownSnDevice.roomName} (duration: "${specificTimeout}")`,
138
+ `Sonos Notification ("${mp3Name}") was${played ? '' : "n't"} played in ${
139
+ ownSnDevice.roomName
140
+ } (duration: "${specificTimeout}")`,
143
141
  );
144
142
  },
145
143
  };
146
144
  try {
147
- const device: SonosDevice| undefined = ownSnDevice.device;
145
+ const device: SonosDevice | undefined = ownSnDevice.device;
148
146
  if (device === undefined) {
149
147
  ServerLogService.writeLog(LogLevel.Alert, `Sonos Geräte ${ownSnDevice.name} ist nicht initialisiert`);
150
148
  Utils.guardedTimeout(
@@ -156,10 +154,7 @@ export class SonosService {
156
154
  );
157
155
  return;
158
156
  }
159
- ServerLogService.writeLog(
160
- LogLevel.Trace,
161
- `Spiele nun die Ausgabe für "${mp3Name}" auf "${ownSnDevice.name}"`,
162
- );
157
+ ServerLogService.writeLog(LogLevel.Trace, `Spiele nun die Ausgabe für "${mp3Name}" auf "${ownSnDevice.name}"`);
163
158
  device.PlayNotificationTwo(options).then((played) => {
164
159
  ServerLogService.writeLog(
165
160
  LogLevel.Debug,
@@ -1,15 +1,14 @@
1
- import { OwnSonosDevice, SonosService } from "/server/config/private/server/services/Sonos/sonos-service";
2
- import { ServerLogService } from "/server/config/private/server/services/log-service";
3
- import { LogLevel } from "/server/config/private/models/logLevel";
4
- import { TelegramService } from "/server/config/private/server/services/Telegram/telegram-service";
1
+ import { OwnSonosDevice, SonosService } from '../Sonos/sonos-service';
2
+ import { ServerLogService } from '../log-service';
3
+ import { LogLevel } from '../../../models/logLevel';
4
+ import { TelegramService } from '../Telegram/telegram-service';
5
5
 
6
6
  export class MuellTonne {
7
7
  public static oneDay: number = 1000 * 60 * 60 * 24;
8
8
  public nextDate: Date | undefined = undefined;
9
9
  public dates: Date[] = [];
10
10
 
11
- public constructor(public name: string, public ownSonosDevice?: OwnSonosDevice) {
12
- }
11
+ public constructor(public name: string, public ownSonosDevice?: OwnSonosDevice) {}
13
12
 
14
13
  public sortDates(): void {
15
14
  this.dates = this.dates.sort((a, b) => a.getTime() - b.getTime());
@@ -5,8 +5,8 @@ import { LogLevel } from '../../../models/logLevel';
5
5
  import { TimeCallback, TimeCallbackType } from '../../../models/timeCallback';
6
6
  import { iMuellSettings } from '../../config/iConfig';
7
7
  import { Utils } from '../utils/utils';
8
- import { MuellTonne } from "./muell-tonne";
9
- import { OwnSonosDevice } from "/server/config/private/server/services/Sonos/sonos-service";
8
+ import { MuellTonne } from './muell-tonne';
9
+ import { OwnSonosDevice } from '../Sonos/sonos-service';
10
10
 
11
11
  export class MuellService {
12
12
  public static alleTonnen: Array<{ name: string; date: Date }> = [];
@@ -24,6 +24,7 @@ export class MuellService {
24
24
  public static months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
25
25
 
26
26
  public static intialize(config: iMuellSettings, defaultSonosDevice: OwnSonosDevice | undefined): void {
27
+ this.defaultSonosDevice = defaultSonosDevice;
27
28
  this._active = true;
28
29
  this._calendarURL = config.calendarURL;
29
30
  this.updateTimeCallback = new TimeCallback(
@@ -83,7 +84,7 @@ export class MuellService {
83
84
  continue;
84
85
  }
85
86
 
86
- this.alleTonnen.push({name: ev.summary, date: ev.start});
87
+ this.alleTonnen.push({ name: ev.summary, date: ev.start });
87
88
  switch (ev.summary) {
88
89
  case this.gelbeTonne.name:
89
90
  this.gelbeTonne.dates.push(ev.start);
@@ -9,7 +9,7 @@ import { RoomBase } from '../../../models/rooms/RoomBase';
9
9
  import { BasicRoomInfo } from '../../../models/persistence/BasicRoomInfo';
10
10
  import { RoomDetailInfo } from '../../../models/persistence/RoomDetailInfo';
11
11
  import { DailyMovementCount } from '../../../models/persistence/DailyMovementCount';
12
- import { iTemperaturDataPoint } from "../../../models/iTemperaturDataPoint";
12
+ import { iTemperaturDataPoint } from '../../../models/iTemperaturDataPoint';
13
13
 
14
14
  export const TemperatureHistoryCollection = new Mongo.Collection<TemperaturDataPoint>('TemperaturData');
15
15
  export const HeatGroupCollection = new Mongo.Collection<TemperaturDataPoint>('HeatGroupCollection');