hoffmation-base 2.6.1 → 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 +6 -0
- package/lib/models/temperatureSettings.d.ts +1 -1
- package/lib/models/temperatureSettings.js +4 -4
- package/lib/server/config/iConfig.d.ts +2 -0
- package/lib/server/config/iVictronSettings.d.ts +3 -0
- package/lib/server/config/iVictronSettings.js +2 -0
- package/lib/server/config/index.d.ts +1 -0
- package/lib/server/config/index.js +1 -0
- package/lib/server/devices/devices.js +3 -0
- package/lib/server/services/index.d.ts +1 -0
- package/lib/server/services/index.js +1 -0
- package/lib/server/services/victron-service.d.ts +11 -0
- package/lib/server/services/victron-service.js +29 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -10
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`);
|
|
@@ -7,5 +7,5 @@ export declare class TemperatureSettings {
|
|
|
7
7
|
active: boolean;
|
|
8
8
|
constructor(start: Daytime, end: Daytime, temperature: number, name: string, active?: boolean);
|
|
9
9
|
static getActiveSetting(settings: TemperatureSettings[], date: Date): TemperatureSettings | undefined;
|
|
10
|
-
isNowInRange(date: Date): boolean;
|
|
10
|
+
static isNowInRange(setting: TemperatureSettings, date: Date): boolean;
|
|
11
11
|
}
|
|
@@ -11,18 +11,18 @@ class TemperatureSettings {
|
|
|
11
11
|
}
|
|
12
12
|
static getActiveSetting(settings, date) {
|
|
13
13
|
for (const setting of settings) {
|
|
14
|
-
if (
|
|
14
|
+
if (TemperatureSettings.isNowInRange(setting, date)) {
|
|
15
15
|
return setting;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
isNowInRange(date) {
|
|
19
|
+
static isNowInRange(setting, date) {
|
|
20
20
|
const now = date.getTime();
|
|
21
|
-
const todayStart = new Date(now).setHours(
|
|
21
|
+
const todayStart = new Date(now).setHours(setting.start.hour, setting.start.minute);
|
|
22
22
|
if (now < todayStart) {
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
|
-
const todayEnd = new Date(now).setHours(
|
|
25
|
+
const todayEnd = new Date(now).setHours(setting.end.hour, setting.end.minute);
|
|
26
26
|
return now < todayEnd;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -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
|
}
|
|
@@ -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;
|
|
@@ -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;
|