hoffmation-base 2.8.9 → 2.9.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/models/deviceSettings/handleSettings.d.ts +8 -0
- package/lib/models/deviceSettings/handleSettings.js +24 -0
- package/lib/models/deviceSettings/victronDeviceSettings.d.ts +4 -0
- package/lib/models/deviceSettings/victronDeviceSettings.js +9 -1
- package/lib/server/devices/baseDeviceInterfaces/iEnergyManager.d.ts +0 -13
- package/lib/server/devices/baseDeviceInterfaces/iEnergyManager.js +0 -28
- package/lib/server/devices/groups/Window.d.ts +4 -0
- package/lib/server/devices/groups/Window.js +4 -0
- package/lib/server/devices/groups/windowGroup.js +16 -0
- package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +2 -0
- package/lib/server/devices/hmIPDevices/hmIpGriff.js +11 -3
- package/lib/server/devices/jsObject/jsObjectEnergyManager.d.ts +2 -1
- package/lib/server/devices/jsObject/jsObjectEnergyManager.js +7 -7
- package/lib/server/devices/models/index.d.ts +1 -0
- package/lib/server/devices/models/index.js +1 -0
- package/lib/server/devices/models/phaseState.d.ts +13 -0
- package/lib/server/devices/models/phaseState.js +30 -0
- package/lib/server/services/time-callback-service.d.ts +1 -0
- package/lib/server/services/time-callback-service.js +3 -0
- package/lib/server/services/victron/victron-device.js +12 -4
- package/lib/server/services/weather/weather-service.js +3 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DeviceSettings } from './deviceSettings';
|
|
2
|
+
export declare class HandleSettings extends DeviceSettings {
|
|
3
|
+
informOnOpen: boolean;
|
|
4
|
+
informNotHelping: boolean;
|
|
5
|
+
informIsHelping: boolean;
|
|
6
|
+
fromPartialObject(data: Partial<HandleSettings>): void;
|
|
7
|
+
protected toJSON(): Partial<HandleSettings>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HandleSettings = void 0;
|
|
4
|
+
const server_1 = require("../../server");
|
|
5
|
+
const deviceSettings_1 = require("./deviceSettings");
|
|
6
|
+
class HandleSettings extends deviceSettings_1.DeviceSettings {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.informOnOpen = true;
|
|
10
|
+
this.informNotHelping = true;
|
|
11
|
+
this.informIsHelping = true;
|
|
12
|
+
}
|
|
13
|
+
fromPartialObject(data) {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
this.informOnOpen = (_a = data.informOnOpen) !== null && _a !== void 0 ? _a : this.informOnOpen;
|
|
16
|
+
this.informNotHelping = (_b = data.informNotHelping) !== null && _b !== void 0 ? _b : this.informNotHelping;
|
|
17
|
+
this.informIsHelping = (_c = data.informIsHelping) !== null && _c !== void 0 ? _c : this.informIsHelping;
|
|
18
|
+
super.fromPartialObject(data);
|
|
19
|
+
}
|
|
20
|
+
toJSON() {
|
|
21
|
+
return server_1.Utils.jsonFilter(this);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.HandleSettings = HandleSettings;
|
|
@@ -5,6 +5,10 @@ export declare class VictronDeviceSettings extends DeviceSettings {
|
|
|
5
5
|
hasGrid: boolean;
|
|
6
6
|
hasSolar: boolean;
|
|
7
7
|
batteryCapacityWattage: number;
|
|
8
|
+
normalBaseConsumptionWattage: number;
|
|
9
|
+
maximumBatteryDischargeWattage: number;
|
|
10
|
+
excessEnergyTurnOnThreshold: number;
|
|
11
|
+
excessEnergyTurnOffThreshold: number;
|
|
8
12
|
fromPartialObject(data: Partial<VictronDeviceSettings>): void;
|
|
9
13
|
protected toJSON(): Partial<VictronDeviceSettings>;
|
|
10
14
|
}
|
|
@@ -11,14 +11,22 @@ class VictronDeviceSettings extends deviceSettings_1.DeviceSettings {
|
|
|
11
11
|
this.hasGrid = true;
|
|
12
12
|
this.hasSolar = true;
|
|
13
13
|
this.batteryCapacityWattage = 10000;
|
|
14
|
+
this.normalBaseConsumptionWattage = 600;
|
|
15
|
+
this.maximumBatteryDischargeWattage = 3000;
|
|
16
|
+
this.excessEnergyTurnOnThreshold = 500;
|
|
17
|
+
this.excessEnergyTurnOffThreshold = 50;
|
|
14
18
|
}
|
|
15
19
|
fromPartialObject(data) {
|
|
16
|
-
var _a, _b, _c, _d, _e;
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
17
21
|
this.maxBatteryLoadWattage = (_a = data.maxBatteryLoadWattage) !== null && _a !== void 0 ? _a : this.maxBatteryLoadWattage;
|
|
18
22
|
this.hasBattery = (_b = data.hasBattery) !== null && _b !== void 0 ? _b : this.hasBattery;
|
|
19
23
|
this.hasGrid = (_c = data.hasGrid) !== null && _c !== void 0 ? _c : this.hasGrid;
|
|
20
24
|
this.hasSolar = (_d = data.hasSolar) !== null && _d !== void 0 ? _d : this.hasSolar;
|
|
21
25
|
this.batteryCapacityWattage = (_e = data.batteryCapacityWattage) !== null && _e !== void 0 ? _e : this.batteryCapacityWattage;
|
|
26
|
+
this.normalBaseConsumptionWattage = (_f = data.normalBaseConsumptionWattage) !== null && _f !== void 0 ? _f : this.normalBaseConsumptionWattage;
|
|
27
|
+
this.maximumBatteryDischargeWattage = (_g = data.maximumBatteryDischargeWattage) !== null && _g !== void 0 ? _g : this.maximumBatteryDischargeWattage;
|
|
28
|
+
this.excessEnergyTurnOnThreshold = (_h = data.excessEnergyTurnOnThreshold) !== null && _h !== void 0 ? _h : this.excessEnergyTurnOnThreshold;
|
|
29
|
+
this.excessEnergyTurnOffThreshold = (_j = data.excessEnergyTurnOffThreshold) !== null && _j !== void 0 ? _j : this.excessEnergyTurnOffThreshold;
|
|
22
30
|
super.fromPartialObject(data);
|
|
23
31
|
}
|
|
24
32
|
toJSON() {
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import { iExcessEnergyConsumer } from './iExcessEnergyConsumer';
|
|
2
2
|
import { iBaseDevice } from './iBaseDevice';
|
|
3
|
-
export declare class PhaseState {
|
|
4
|
-
private readonly _meterValue;
|
|
5
|
-
private readonly _production;
|
|
6
|
-
private readonly _injectingWattage;
|
|
7
|
-
private readonly _drawingWattage;
|
|
8
|
-
private readonly _selfConsumingWattage;
|
|
9
|
-
private readonly _totalConsumption;
|
|
10
|
-
constructor(_meterValue: number, _production: number);
|
|
11
|
-
get selfConsumingWattage(): number;
|
|
12
|
-
get drawingWattage(): number;
|
|
13
|
-
get injectingWattage(): number;
|
|
14
|
-
get totalConsumptionWattage(): number;
|
|
15
|
-
}
|
|
16
3
|
export interface iEnergyManager extends iBaseDevice {
|
|
17
4
|
excessEnergy: number;
|
|
18
5
|
addExcessConsumer(device: iExcessEnergyConsumer): void;
|
|
@@ -1,30 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PhaseState = void 0;
|
|
4
|
-
class PhaseState {
|
|
5
|
-
constructor(_meterValue, _production) {
|
|
6
|
-
this._meterValue = _meterValue;
|
|
7
|
-
this._production = _production;
|
|
8
|
-
this._injectingWattage = 0;
|
|
9
|
-
this._drawingWattage = 0;
|
|
10
|
-
this._selfConsumingWattage = 0;
|
|
11
|
-
this._totalConsumption = 0;
|
|
12
|
-
this._injectingWattage = Math.max(0, this._meterValue);
|
|
13
|
-
this._selfConsumingWattage = this._production - Math.max(0, this._meterValue);
|
|
14
|
-
this._drawingWattage = Math.min(0, this._meterValue) * -1;
|
|
15
|
-
this._totalConsumption = this._production - this._meterValue;
|
|
16
|
-
}
|
|
17
|
-
get selfConsumingWattage() {
|
|
18
|
-
return this._selfConsumingWattage;
|
|
19
|
-
}
|
|
20
|
-
get drawingWattage() {
|
|
21
|
-
return this._drawingWattage;
|
|
22
|
-
}
|
|
23
|
-
get injectingWattage() {
|
|
24
|
-
return this._injectingWattage;
|
|
25
|
-
}
|
|
26
|
-
get totalConsumptionWattage() {
|
|
27
|
-
return this._totalConsumption;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.PhaseState = PhaseState;
|
|
@@ -5,6 +5,10 @@ import { iShutter, iVibrationSensor } from '../baseDeviceInterfaces';
|
|
|
5
5
|
import { BaseGroup } from './base-group';
|
|
6
6
|
import { ZigbeeMagnetContact } from '../zigbee';
|
|
7
7
|
export declare class Window extends BaseGroup {
|
|
8
|
+
readonly handleIds: string[];
|
|
9
|
+
readonly vibrationIds: string[];
|
|
10
|
+
readonly shutterIds: string[];
|
|
11
|
+
readonly magnetIds: string[];
|
|
8
12
|
noRolloOnSunrise: boolean;
|
|
9
13
|
desiredPosition: number;
|
|
10
14
|
settings: WindowSettings;
|
|
@@ -11,6 +11,10 @@ const device_list_1 = require("../device-list");
|
|
|
11
11
|
class Window extends base_group_1.BaseGroup {
|
|
12
12
|
constructor(roomName, handleIds = [], vibrationIds = [], shutterIds = [], magnetIds = [], noRolloOnSunrise = false) {
|
|
13
13
|
super(roomName, group_type_1.GroupType.Window);
|
|
14
|
+
this.handleIds = handleIds;
|
|
15
|
+
this.vibrationIds = vibrationIds;
|
|
16
|
+
this.shutterIds = shutterIds;
|
|
17
|
+
this.magnetIds = magnetIds;
|
|
14
18
|
this.noRolloOnSunrise = noRolloOnSunrise;
|
|
15
19
|
this.desiredPosition = 0;
|
|
16
20
|
this.settings = new models_2.WindowSettings();
|
|
@@ -6,10 +6,26 @@ const services_1 = require("../../services");
|
|
|
6
6
|
const models_2 = require("../models");
|
|
7
7
|
const base_group_1 = require("./base-group");
|
|
8
8
|
const group_type_1 = require("./group-type");
|
|
9
|
+
const device_list_1 = require("../device-list");
|
|
10
|
+
const device_cluster_type_1 = require("../device-cluster-type");
|
|
9
11
|
class WindowGroup extends base_group_1.BaseGroup {
|
|
10
12
|
constructor(roomName, windows) {
|
|
11
13
|
super(roomName, group_type_1.GroupType.WindowGroup);
|
|
12
14
|
this.windows = windows;
|
|
15
|
+
const shutterIds = [];
|
|
16
|
+
const handleIds = [];
|
|
17
|
+
const vibrationIds = [];
|
|
18
|
+
const magnetIds = [];
|
|
19
|
+
windows.forEach((window) => {
|
|
20
|
+
shutterIds.push(...window.shutterIds);
|
|
21
|
+
handleIds.push(...window.handleIds);
|
|
22
|
+
vibrationIds.push(...window.vibrationIds);
|
|
23
|
+
magnetIds.push(...window.magnetIds);
|
|
24
|
+
});
|
|
25
|
+
this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.Handle, new device_list_1.DeviceList(handleIds));
|
|
26
|
+
this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.Vibration, new device_list_1.DeviceList(vibrationIds));
|
|
27
|
+
this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.Shutter, new device_list_1.DeviceList(shutterIds));
|
|
28
|
+
this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.MagnetContact, new device_list_1.DeviceList(magnetIds));
|
|
13
29
|
}
|
|
14
30
|
allRolloDown(initial = false, savePosition = false) {
|
|
15
31
|
this.windows.forEach((f) => {
|
|
@@ -6,7 +6,9 @@ import { IoBrokerBaseDevice } from '../IoBrokerBaseDevice';
|
|
|
6
6
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
7
7
|
import { HmIPDevice } from './hmIpDevice';
|
|
8
8
|
import { iBatteryDevice, iHandleSensor } from '../baseDeviceInterfaces';
|
|
9
|
+
import { HandleSettings } from '../../../models/deviceSettings/handleSettings';
|
|
9
10
|
export declare class HmIpGriff extends HmIPDevice implements iHandleSensor, iBatteryDevice, iDisposable {
|
|
11
|
+
settings: HandleSettings;
|
|
10
12
|
private _battery;
|
|
11
13
|
private _lastBatteryPersist;
|
|
12
14
|
private _lastHandlePersist;
|
|
@@ -11,6 +11,7 @@ const models_2 = require("../../../models");
|
|
|
11
11
|
const lodash_1 = __importDefault(require("lodash"));
|
|
12
12
|
const hmIpDevice_1 = require("./hmIpDevice");
|
|
13
13
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
14
|
+
const handleSettings_1 = require("../../../models/deviceSettings/handleSettings");
|
|
14
15
|
class HmIpGriff extends hmIpDevice_1.HmIPDevice {
|
|
15
16
|
get lastBatteryPersist() {
|
|
16
17
|
return this._lastBatteryPersist;
|
|
@@ -20,6 +21,7 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
|
|
|
20
21
|
}
|
|
21
22
|
constructor(pInfo) {
|
|
22
23
|
super(pInfo, deviceType_1.DeviceType.HmIpGriff);
|
|
24
|
+
this.settings = new handleSettings_1.HandleSettings();
|
|
23
25
|
this._battery = -99;
|
|
24
26
|
this._lastBatteryPersist = 0;
|
|
25
27
|
this._lastHandlePersist = 0;
|
|
@@ -116,14 +118,18 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
|
|
|
116
118
|
if (!wouldHelp && this._helpingRoomTemp) {
|
|
117
119
|
const info = `Window should be closed, as it doesn't help reaching target temperature.`;
|
|
118
120
|
this.log(models_2.LogLevel.Info, info);
|
|
119
|
-
|
|
121
|
+
if (this.settings.informNotHelping) {
|
|
122
|
+
services_1.TelegramService.inform(info);
|
|
123
|
+
}
|
|
120
124
|
this._helpingRoomTemp = false;
|
|
121
125
|
}
|
|
122
126
|
else if (wouldHelp && !this._helpingRoomTemp) {
|
|
123
127
|
this._helpingRoomTemp = true;
|
|
124
128
|
const info = `Das Fenster hilft der Innentemperatur ihr Ziel von ${desiredTemp} zu erreichen. Draußen sind es ${outSideTemp}. Du wirst informiert wenn es nicht mehr hilft.`;
|
|
125
129
|
this.log(models_2.LogLevel.Info, info);
|
|
126
|
-
|
|
130
|
+
if (this.settings.informIsHelping) {
|
|
131
|
+
services_1.TelegramService.inform(info);
|
|
132
|
+
}
|
|
127
133
|
return;
|
|
128
134
|
}
|
|
129
135
|
else if (wouldHelp && this._helpingRoomTemp) {
|
|
@@ -139,7 +145,9 @@ class HmIpGriff extends hmIpDevice_1.HmIPDevice {
|
|
|
139
145
|
case 120:
|
|
140
146
|
case 240:
|
|
141
147
|
this.log(models_2.LogLevel.Info, message);
|
|
142
|
-
|
|
148
|
+
if (this.settings.informOnOpen) {
|
|
149
|
+
services_1.TelegramService.inform(`${this.info.room}: ${message}`);
|
|
150
|
+
}
|
|
143
151
|
break;
|
|
144
152
|
default:
|
|
145
153
|
this.log(models_2.LogLevel.Trace, message);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="iobroker" />
|
|
2
2
|
import { IoBrokerBaseDevice } from '../IoBrokerBaseDevice';
|
|
3
|
-
import { iEnergyManager, iExcessEnergyConsumer
|
|
3
|
+
import { iEnergyManager, iExcessEnergyConsumer } from '../baseDeviceInterfaces';
|
|
4
4
|
import { iDisposable } from '../../services';
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
|
+
import { PhaseState } from '../models';
|
|
6
7
|
export declare class JsObjectEnergyManager extends IoBrokerBaseDevice implements iEnergyManager, iDisposable {
|
|
7
8
|
private _excessEnergyConsumer;
|
|
8
9
|
private _iCalculationInterval;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsObjectEnergyManager = void 0;
|
|
4
4
|
const IoBrokerBaseDevice_1 = require("../IoBrokerBaseDevice");
|
|
5
|
-
const baseDeviceInterfaces_1 = require("../baseDeviceInterfaces");
|
|
6
5
|
const deviceType_1 = require("../deviceType");
|
|
7
6
|
const models_1 = require("../../../models");
|
|
8
7
|
const services_1 = require("../../services");
|
|
9
8
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
9
|
+
const models_2 = require("../models");
|
|
10
10
|
class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
11
11
|
constructor(info) {
|
|
12
12
|
super(info, deviceType_1.DeviceType.JsEnergyManager);
|
|
@@ -20,9 +20,9 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
20
20
|
this.blockDeviceChangeTime = -1;
|
|
21
21
|
this._currentProduction = -1;
|
|
22
22
|
this._excessEnergyConsumerConsumption = 0;
|
|
23
|
-
this._phaseAState = new
|
|
24
|
-
this._phaseBState = new
|
|
25
|
-
this._phaseCState = new
|
|
23
|
+
this._phaseAState = new models_2.PhaseState(0, 0);
|
|
24
|
+
this._phaseBState = new models_2.PhaseState(0, 0);
|
|
25
|
+
this._phaseCState = new models_2.PhaseState(0, 0);
|
|
26
26
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.energyManager);
|
|
27
27
|
this.log(models_1.LogLevel.Info, `Creating Energy Manager Device`);
|
|
28
28
|
this._iCalculationInterval = services_1.Utils.guardedInterval(() => {
|
|
@@ -133,9 +133,9 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
133
133
|
}
|
|
134
134
|
calculateExcessEnergy() {
|
|
135
135
|
const phaseProduction = this._currentProduction / 3.0;
|
|
136
|
-
this._phaseAState = new
|
|
137
|
-
this._phaseBState = new
|
|
138
|
-
this._phaseCState = new
|
|
136
|
+
this._phaseAState = new models_2.PhaseState(this._powerValuePhaseA, phaseProduction);
|
|
137
|
+
this._phaseBState = new models_2.PhaseState(this._powerValuePhaseB, phaseProduction);
|
|
138
|
+
this._phaseCState = new models_2.PhaseState(this._powerValuePhaseC, phaseProduction);
|
|
139
139
|
this.calculatePersistenceValues();
|
|
140
140
|
this.recalculatePowerSharing();
|
|
141
141
|
}
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./WindowPosition"), exports);
|
|
18
18
|
__exportStar(require("./MagnetPosition"), exports);
|
|
19
|
+
__exportStar(require("./phaseState"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class PhaseState {
|
|
2
|
+
private readonly _meterValue;
|
|
3
|
+
private readonly _production;
|
|
4
|
+
private readonly _injectingWattage;
|
|
5
|
+
private readonly _drawingWattage;
|
|
6
|
+
private readonly _selfConsumingWattage;
|
|
7
|
+
private readonly _totalConsumption;
|
|
8
|
+
constructor(_meterValue: number, _production: number);
|
|
9
|
+
get selfConsumingWattage(): number;
|
|
10
|
+
get drawingWattage(): number;
|
|
11
|
+
get injectingWattage(): number;
|
|
12
|
+
get totalConsumptionWattage(): number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PhaseState = void 0;
|
|
4
|
+
class PhaseState {
|
|
5
|
+
constructor(_meterValue, _production) {
|
|
6
|
+
this._meterValue = _meterValue;
|
|
7
|
+
this._production = _production;
|
|
8
|
+
this._injectingWattage = 0;
|
|
9
|
+
this._drawingWattage = 0;
|
|
10
|
+
this._selfConsumingWattage = 0;
|
|
11
|
+
this._totalConsumption = 0;
|
|
12
|
+
this._injectingWattage = Math.max(0, this._meterValue);
|
|
13
|
+
this._selfConsumingWattage = this._production - Math.max(0, this._meterValue);
|
|
14
|
+
this._drawingWattage = Math.min(0, this._meterValue) * -1;
|
|
15
|
+
this._totalConsumption = this._production - this._meterValue;
|
|
16
|
+
}
|
|
17
|
+
get selfConsumingWattage() {
|
|
18
|
+
return this._selfConsumingWattage;
|
|
19
|
+
}
|
|
20
|
+
get drawingWattage() {
|
|
21
|
+
return this._drawingWattage;
|
|
22
|
+
}
|
|
23
|
+
get injectingWattage() {
|
|
24
|
+
return this._injectingWattage;
|
|
25
|
+
}
|
|
26
|
+
get totalConsumptionWattage() {
|
|
27
|
+
return this._totalConsumption;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.PhaseState = PhaseState;
|
|
@@ -33,4 +33,5 @@ export declare class TimeCallbackService {
|
|
|
33
33
|
static updateSunRise(pDay?: Date, lat?: number, long?: number): void;
|
|
34
34
|
static updateSunSet(pDay?: Date, lat?: number, long?: number): void;
|
|
35
35
|
static getSunsetForDate(pDay?: Date, lat?: number, long?: number): Date;
|
|
36
|
+
static hoursTilSunset(): number;
|
|
36
37
|
}
|
|
@@ -177,6 +177,9 @@ Next Sunset: ${TimeCallbackService._nextSunSet.toLocaleString('de-DE')}`);
|
|
|
177
177
|
static getSunsetForDate(pDay = new Date(), lat, long) {
|
|
178
178
|
return (0, sunrise_sunset_js_1.getSunset)(lat !== null && lat !== void 0 ? lat : settings_service_1.SettingsService.latitude, long !== null && long !== void 0 ? long : settings_service_1.SettingsService.longitude, pDay);
|
|
179
179
|
}
|
|
180
|
+
static hoursTilSunset() {
|
|
181
|
+
return (this.nextSunSet.getTime() - utils_1.Utils.nowMS()) / 1000 / 60;
|
|
182
|
+
}
|
|
180
183
|
}
|
|
181
184
|
TimeCallbackService._callbacks = new Map();
|
|
182
185
|
TimeCallbackService._lastCheck = new Date(0);
|
|
@@ -7,6 +7,7 @@ const models_1 = require("../../../models");
|
|
|
7
7
|
const DeviceCapability_1 = require("../../devices/DeviceCapability");
|
|
8
8
|
const log_service_1 = require("../log-service");
|
|
9
9
|
const victron_mqtt_consumer_1 = require("victron-mqtt-consumer");
|
|
10
|
+
const time_callback_service_1 = require("../time-callback-service");
|
|
10
11
|
class VictronDevice {
|
|
11
12
|
constructor(opts) {
|
|
12
13
|
this.deviceCapabilities = [DeviceCapability_1.DeviceCapability.energyManager];
|
|
@@ -62,10 +63,10 @@ class VictronDevice {
|
|
|
62
63
|
if (utils_1.Utils.nowMS() < this.blockDeviceChangeTime) {
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
|
-
if (this.excessEnergy >
|
|
66
|
+
if (this.excessEnergy > this.settings.excessEnergyTurnOnThreshold) {
|
|
66
67
|
this.turnOnAdditionalConsumer();
|
|
67
68
|
}
|
|
68
|
-
else if (this.excessEnergy <
|
|
69
|
+
else if (this.excessEnergy < this.settings.excessEnergyTurnOffThreshold) {
|
|
69
70
|
this.turnOffAdditionalConsumer();
|
|
70
71
|
}
|
|
71
72
|
}
|
|
@@ -104,20 +105,27 @@ class VictronDevice {
|
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
107
|
// Step 1: Calculate battery need
|
|
108
|
+
const hoursTilSunset = time_callback_service_1.TimeCallbackService.hoursTilSunset();
|
|
107
109
|
let neededBatteryWattage = 0;
|
|
108
110
|
if (this.settings.hasBattery) {
|
|
109
111
|
if (this.data.battery.soc == null) {
|
|
110
112
|
this.log(models_1.LogLevel.Debug, `No battery data available from Victron device.`);
|
|
111
113
|
return;
|
|
112
114
|
}
|
|
113
|
-
neededBatteryWattage = (1 - this.data.battery.soc) * this.settings.batteryCapacityWattage;
|
|
115
|
+
neededBatteryWattage = ((1 - this.data.battery.soc) * this.settings.batteryCapacityWattage) / hoursTilSunset;
|
|
114
116
|
}
|
|
115
117
|
// Step 2: Calculate expected solar output
|
|
116
118
|
const solarOutput = (_a = this.data.pvInverter.power) !== null && _a !== void 0 ? _a : 0;
|
|
117
119
|
// Step 3: Calculate expected base consumption
|
|
118
|
-
const baseConsumption =
|
|
120
|
+
const baseConsumption = this.settings.normalBaseConsumptionWattage;
|
|
119
121
|
// Step 4: Combine to get currently excess energy
|
|
120
122
|
this._excessEnergy = solarOutput - neededBatteryWattage - baseConsumption;
|
|
123
|
+
// Whilst calculated spare energy is more precise, we don't mind using the battery as a buffer, if it is full enough.
|
|
124
|
+
if (this.data.battery.dcPower !== null &&
|
|
125
|
+
this.data.battery.soc !== null &&
|
|
126
|
+
this.data.battery.soc > (hoursTilSunset > 4 ? 0.7 : 0.8)) {
|
|
127
|
+
this._excessEnergy = this.settings.maximumBatteryDischargeWattage - Math.max(this.data.battery.dcPower, 0);
|
|
128
|
+
}
|
|
121
129
|
}
|
|
122
130
|
turnOnAdditionalConsumer() {
|
|
123
131
|
const result = utils_1.EnergyManagerUtils.turnOnAdditionalConsumer(this._excessEnergyConsumer, this._lastDeviceChange);
|
|
@@ -152,7 +152,9 @@ class WeatherService {
|
|
|
152
152
|
else if (this.willOutsideBeWarmer(26, logger)) {
|
|
153
153
|
result = 30;
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
if (result !== normalPos) {
|
|
156
|
+
logger(models_1.LogLevel.Info, `weatherRolloPosition(${normalPos}, ${desiredTemperatur}, ${currentTemperatur}) --> Target: ${result}`);
|
|
157
|
+
}
|
|
156
158
|
return result;
|
|
157
159
|
}
|
|
158
160
|
static getCurrentCloudiness() {
|