hoffmation-base 2.6.2 → 2.7.0

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.
package/lib/index.js CHANGED
@@ -93,6 +93,12 @@ class HoffmationBase {
93
93
  server_1.WeatherService.initialize(server_1.SettingsService.settings.weather);
94
94
  }
95
95
  });
96
+ server_1.Utils.guardedNewThread(() => {
97
+ if (server_1.SettingsService.settings.victron) {
98
+ server_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Victron settings detected --> initializing`);
99
+ server_1.VictronService.initialize(server_1.SettingsService.settings.victron);
100
+ }
101
+ });
96
102
  if (server_1.SettingsService.TelegramActive)
97
103
  server_1.TelegramService.publishCommands();
98
104
  server_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Hoffmation-Base Post ioBrokerInitializations finished`);
@@ -18,6 +18,7 @@ import { iBlueIrisSettings } from './iBlueIrisSettings';
18
18
  import { iRestSettings } from './iRestSettings';
19
19
  import { iEspresenseSettings } from './iEspresenseSettings';
20
20
  import { iTibberSettings } from './iTibberSettings';
21
+ import { iVictronSettings } from './iVictronSettings';
21
22
  export interface iConfig {
22
23
  asusConfig?: iAsusConfig;
23
24
  blueIris?: iBlueIrisSettings;
@@ -42,4 +43,5 @@ export interface iConfig {
42
43
  translationSettings: iTranslationSettings;
43
44
  wattagePrice?: number;
44
45
  weather?: iWeatherSettings;
46
+ victron?: iVictronSettings;
45
47
  }
@@ -0,0 +1,3 @@
1
+ export interface iVictronSettings {
2
+ host: string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -21,3 +21,4 @@ export * from './iTelegramSettings';
21
21
  export * from './iTibberSettings';
22
22
  export * from './iTimeSettings';
23
23
  export * from './iTimePair';
24
+ export * from './iVictronSettings';
@@ -37,3 +37,4 @@ __exportStar(require("./iTelegramSettings"), exports);
37
37
  __exportStar(require("./iTibberSettings"), exports);
38
38
  __exportStar(require("./iTimeSettings"), exports);
39
39
  __exportStar(require("./iTimePair"), exports);
40
+ __exportStar(require("./iVictronSettings"), exports);
@@ -224,6 +224,9 @@ class Devices {
224
224
  Devices.alLDevices[fullName] = d;
225
225
  }
226
226
  static createEnergyManager(cDevConf) {
227
+ if (Devices.energymanager !== undefined) {
228
+ return;
229
+ }
227
230
  const devInfo = new IoBrokerDeviceInfo_1.IoBrokerDeviceInfo(cDevConf, true);
228
231
  const fullName = `${Devices.IDENTIFIER_JS}-${devInfo.devID}`;
229
232
  devInfo.allDevicesKey = fullName;
@@ -16,4 +16,5 @@ export * from './news-service';
16
16
  export * from './settings-service';
17
17
  export * from './ShutterService';
18
18
  export * from './tibber-service';
19
+ export * from './victron-service';
19
20
  export * from './time-callback-service';
@@ -32,4 +32,5 @@ __exportStar(require("./news-service"), exports);
32
32
  __exportStar(require("./settings-service"), exports);
33
33
  __exportStar(require("./ShutterService"), exports);
34
34
  __exportStar(require("./tibber-service"), exports);
35
+ __exportStar(require("./victron-service"), exports);
35
36
  __exportStar(require("./time-callback-service"), exports);
@@ -0,0 +1,11 @@
1
+ import { iVictronSettings } from '../config';
2
+ import { VictronDeviceData } from 'victron-mqtt-consumer';
3
+ export declare class VictronService {
4
+ private static _victronConsumer;
5
+ private static _settings;
6
+ static get settings(): iVictronSettings | undefined;
7
+ static get data(): VictronDeviceData | undefined;
8
+ private static _active;
9
+ static get active(): boolean;
10
+ static initialize(settings?: iVictronSettings): void;
11
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VictronService = void 0;
4
+ const victron_mqtt_consumer_1 = require("victron-mqtt-consumer");
5
+ class VictronService {
6
+ static get settings() {
7
+ return this._settings;
8
+ }
9
+ static get data() {
10
+ var _a;
11
+ return (_a = this._victronConsumer) === null || _a === void 0 ? void 0 : _a.data;
12
+ }
13
+ static get active() {
14
+ return this._active;
15
+ }
16
+ static initialize(settings) {
17
+ const newSettings = settings !== null && settings !== void 0 ? settings : this.settings;
18
+ if (newSettings === undefined) {
19
+ this._active = false;
20
+ return;
21
+ }
22
+ const opts = new victron_mqtt_consumer_1.VictronMqttConnectionOptions();
23
+ opts.ip = newSettings.host;
24
+ this._victronConsumer = new victron_mqtt_consumer_1.VictronMqttConsumer(opts);
25
+ }
26
+ }
27
+ exports.VictronService = VictronService;
28
+ VictronService._victronConsumer = undefined;
29
+ VictronService._settings = undefined;