hoffmation-base 3.0.0-alpha.47 → 3.0.0-alpha.48

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.
@@ -13,6 +13,10 @@ export interface iEnergyManager extends iBaseDevice, iDisposable {
13
13
  * For devices with {@link DeviceCapability.energyManager} capability.
14
14
  */
15
15
  excessEnergy: number;
16
+ /**
17
+ * Whether the Energy Manager actively blocks AC
18
+ */
19
+ readonly acBlocked: boolean;
16
20
  /**
17
21
  * The total wattaage being injected into the grid at the moment of last calculation.
18
22
  */
@@ -23,6 +23,8 @@ export declare class JsObjectEnergyManager extends IoBrokerBaseDevice implements
23
23
  get drawingWattage(): number;
24
24
  get selfConsumingWattage(): number;
25
25
  get excessEnergy(): number;
26
+ /** @inheritDoc */
27
+ get acBlocked(): boolean;
26
28
  private _excessEnergyConsumerConsumption;
27
29
  /**
28
30
  * Example:
@@ -58,6 +58,10 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
58
58
  get excessEnergy() {
59
59
  return this._powerValuePhaseA + this._powerValuePhaseB + this._powerValuePhaseC;
60
60
  }
61
+ /** @inheritDoc */
62
+ get acBlocked() {
63
+ return this.excessEnergy < 200;
64
+ }
61
65
  /**
62
66
  * Example:
63
67
  * ________________________________________
@@ -136,7 +136,7 @@ class AcDevice {
136
136
  }
137
137
  /** @inheritDoc */
138
138
  calculateDesiredMode() {
139
- var _a, _b, _c;
139
+ var _a, _b, _c, _d;
140
140
  const acOn = this.on;
141
141
  const heatGroup = (_a = this.room) === null || _a === void 0 ? void 0 : _a.HeatGroup;
142
142
  if (!heatGroup) {
@@ -148,6 +148,9 @@ class AcDevice {
148
148
  acOn && this.log(models_1.LogLevel.Info, 'We should turn off now, as manual disable force is set.');
149
149
  return ac_mode_1.AcMode.Off;
150
150
  }
151
+ if ((_b = devices_1.Devices.energymanager) === null || _b === void 0 ? void 0 : _b.acBlocked) {
152
+ return ac_mode_1.AcMode.Off;
153
+ }
151
154
  // Check Turn Off Time
152
155
  if (!utils_1.Utils.timeWithinBorders(this.settings.minimumHours, this.settings.minimumMinutes, this.settings.maximumHours, this.settings.maximumMinutes)) {
153
156
  acOn && this.log(models_1.LogLevel.Info, 'We should turn off now, to respect night settings.');
@@ -178,7 +181,7 @@ class AcDevice {
178
181
  let threshold = acOn ? 0.5 : 1.5;
179
182
  let thresholdHeating = acOn ? 0.5 : 1.5;
180
183
  let desiredMode = ac_mode_1.AcMode.Off;
181
- const excessEnergy = (_c = (_b = devices_1.Devices.energymanager) === null || _b === void 0 ? void 0 : _b.excessEnergy) !== null && _c !== void 0 ? _c : -1;
184
+ const excessEnergy = (_d = (_c = devices_1.Devices.energymanager) === null || _c === void 0 ? void 0 : _c.excessEnergy) !== null && _d !== void 0 ? _d : -1;
182
185
  if ((acOn ? 200 : 1000) < excessEnergy) {
183
186
  // As there is plenty of energy to spare we plan to overshoot the target by 1 degree
184
187
  threshold = -0.5;
@@ -3,13 +3,14 @@ import { BatteryLevelChangeAction, LogLevel, VictronDeviceSettings } from '../..
3
3
  import { LogDebugType } from '../log-service';
4
4
  import { VictronDeviceData, VictronMqttConnectionOptions, VictronMqttConsumer } from 'victron-mqtt-consumer';
5
5
  export declare class VictronDevice implements iEnergyManager, iBatteryDevice {
6
- private readonly _victronConsumer;
7
6
  /** @inheritDoc */
8
7
  readonly deviceCapabilities: DeviceCapability[];
9
8
  /** @inheritDoc */
10
9
  deviceType: DeviceType;
11
10
  /** @inheritDoc */
12
11
  readonly settings: VictronDeviceSettings;
12
+ protected _info: DeviceInfo;
13
+ private readonly _victronConsumer;
13
14
  private _excessEnergyConsumer;
14
15
  private blockDeviceChangeTime;
15
16
  private _lastDeviceChange;
@@ -20,27 +21,28 @@ export declare class VictronDevice implements iEnergyManager, iBatteryDevice {
20
21
  private _lastBatteryPersist;
21
22
  private _lastBatteryLevel;
22
23
  private _batteryLevelCallbacks;
24
+ private _excessEnergy;
23
25
  constructor(opts: VictronMqttConnectionOptions);
24
26
  /** @inheritDoc */
27
+ get acBlocked(): boolean;
28
+ /** @inheritDoc */
25
29
  get lastBatteryPersist(): number;
26
- protected _info: DeviceInfo;
27
30
  get info(): DeviceInfo;
28
31
  /** @inheritDoc */
29
32
  get battery(): number;
30
33
  get victronConsumer(): VictronMqttConsumer;
31
34
  get data(): VictronDeviceData;
32
- private _excessEnergy;
33
35
  get excessEnergy(): number;
34
36
  get name(): string;
35
37
  get customName(): string;
36
38
  get id(): string;
37
- /** @inheritDoc */
38
- addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
39
- addExcessConsumer(device: iExcessEnergyConsumer): void;
40
39
  get injectingWattage(): number;
41
40
  get drawingWattage(): number;
42
41
  get selfConsumingWattage(): number;
43
42
  /** @inheritDoc */
43
+ addBatteryLevelCallback(pCallback: (action: BatteryLevelChangeAction) => void): void;
44
+ addExcessConsumer(device: iExcessEnergyConsumer): void;
45
+ /** @inheritDoc */
44
46
  dispose(): void;
45
47
  getReport(): string;
46
48
  recalculatePowerSharing(): void;
@@ -45,6 +45,20 @@ class VictronDevice {
45
45
  this._nextPersistEntry = new models_1.EnergyCalculation(utils_1.Utils.nowMS());
46
46
  }
47
47
  /** @inheritDoc */
48
+ get acBlocked() {
49
+ if (this.settings.hasBattery) {
50
+ const hours = new Date().getHours();
51
+ if (hours < 6 || hours > 18) {
52
+ return this.battery < 70;
53
+ }
54
+ if (hours < 10 || hours > 16) {
55
+ return this.battery < 60;
56
+ }
57
+ return this.battery < 50;
58
+ }
59
+ return false;
60
+ }
61
+ /** @inheritDoc */
48
62
  get lastBatteryPersist() {
49
63
  return this._lastBatteryPersist;
50
64
  }
@@ -79,13 +93,6 @@ class VictronDevice {
79
93
  var _a;
80
94
  return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `victron-${this.info.room}-${this.info.customName}`;
81
95
  }
82
- /** @inheritDoc */
83
- addBatteryLevelCallback(pCallback) {
84
- this._batteryLevelCallbacks.push(pCallback);
85
- }
86
- addExcessConsumer(device) {
87
- this._excessEnergyConsumer.push(device);
88
- }
89
96
  get injectingWattage() {
90
97
  var _a;
91
98
  return Math.min((_a = this.victronConsumer.data.grid.power) !== null && _a !== void 0 ? _a : 0, 0) * -1;
@@ -99,6 +106,13 @@ class VictronDevice {
99
106
  return Math.max((_a = this.victronConsumer.data.system.power) !== null && _a !== void 0 ? _a : 0, 0) - this.drawingWattage;
100
107
  }
101
108
  /** @inheritDoc */
109
+ addBatteryLevelCallback(pCallback) {
110
+ this._batteryLevelCallbacks.push(pCallback);
111
+ }
112
+ addExcessConsumer(device) {
113
+ this._excessEnergyConsumer.push(device);
114
+ }
115
+ /** @inheritDoc */
102
116
  dispose() {
103
117
  this._victronConsumer.disconnect();
104
118
  if (this._iDatabaseLoggerInterval !== null) {