hoffmation-base 3.2.7 → 3.2.8

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.
@@ -45,17 +45,28 @@ class VictronDevice extends BaseDevice_1.BaseDevice {
45
45
  }
46
46
  /** @inheritDoc */
47
47
  get acBlocked() {
48
- if (this.settings.hasBattery) {
49
- const hours = new Date().getHours();
50
- if (hours < 6 || hours > 18) {
51
- return this.batteryLevel < this.settings.minimumNightTimeAcBatteryLevel;
52
- }
53
- if (hours < 10 || hours > 16) {
54
- return this.batteryLevel < this.settings.minimumTransientTimeAcBatteryLevel;
55
- }
56
- return this.batteryLevel < this.settings.minimumDayTimeAcBatteryLevel;
48
+ var _a;
49
+ if (!this.settings.hasBattery) {
50
+ return false;
51
+ }
52
+ const hours = new Date().getHours();
53
+ if (hours > 18) {
54
+ return this.batteryLevel < this.settings.minimumNightTimeAcBatteryLevel;
55
+ }
56
+ else if (hours > 16) {
57
+ return this.batteryLevel < this.settings.minimumTransientTimeAcBatteryLevel;
58
+ }
59
+ else if (hours > 5 &&
60
+ hours < 12 &&
61
+ ((_a = services_1.WeatherService.todayCloudiness) !== null && _a !== void 0 ? _a : 99) < 30 &&
62
+ services_1.WeatherService.todayMaxTemp > 25) {
63
+ // During morning hours battery still might be kinda empty but if it gets sunny again, we should go for ac anyways.
64
+ return this.batteryLevel > this.settings.minimumMorningSunnyDayAcBatteryLevel;
65
+ }
66
+ else if (hours < 10) {
67
+ return this.batteryLevel > this.settings.minimumTransientTimeAcBatteryLevel;
57
68
  }
58
- return false;
69
+ return this.batteryLevel < this.settings.minimumDayTimeAcBatteryLevel;
59
70
  }
60
71
  /** @inheritDoc */
61
72
  get batteryLevel() {
@@ -25,6 +25,7 @@ export declare class WeatherService {
25
25
  private static appID?;
26
26
  static addWeatherUpdateCb(name: string, cb: () => void): void;
27
27
  static get todayMaxTemp(): number;
28
+ static get todayCloudiness(): number | undefined;
28
29
  static initialize(config: iWeatherSettings): void;
29
30
  static update(): void;
30
31
  static stopInterval(): void;
@@ -20,6 +20,10 @@ class WeatherService {
20
20
  var _a, _b, _c;
21
21
  return (_c = (_b = (_a = WeatherService.lastResponse) === null || _a === void 0 ? void 0 : _a.daily[0]) === null || _b === void 0 ? void 0 : _b.temp.max) !== null && _c !== void 0 ? _c : interfaces_1.UNDEFINED_TEMP_VALUE;
22
22
  }
23
+ static get todayCloudiness() {
24
+ var _a, _b;
25
+ return (_b = (_a = WeatherService.lastResponse) === null || _a === void 0 ? void 0 : _a.daily[0]) === null || _b === void 0 ? void 0 : _b.clouds;
26
+ }
23
27
  static initialize(config) {
24
28
  this.active = true;
25
29
  this.longitude = config.longitude;
@@ -27,6 +27,11 @@ export declare class VictronDeviceSettings extends DeviceSettings {
27
27
  * The minimum battery level at which the system should be allowed to use AC
28
28
  */
29
29
  minimumDayTimeAcBatteryLevel: number;
30
+ /**
31
+ * The minimum battery level at which the system should be allowed to use AC on expectetly hot/sunny days mornings
32
+ * @type {number}
33
+ */
34
+ minimumMorningSunnyDayAcBatteryLevel: number;
30
35
  /**
31
36
  * If the system has a grid
32
37
  * @default true
@@ -33,6 +33,11 @@ class VictronDeviceSettings extends deviceSettings_1.DeviceSettings {
33
33
  * The minimum battery level at which the system should be allowed to use AC
34
34
  */
35
35
  this.minimumDayTimeAcBatteryLevel = 60;
36
+ /**
37
+ * The minimum battery level at which the system should be allowed to use AC on expectetly hot/sunny days mornings
38
+ * @type {number}
39
+ */
40
+ this.minimumMorningSunnyDayAcBatteryLevel = 30;
36
41
  /**
37
42
  * If the system has a grid
38
43
  * @default true
@@ -68,21 +73,23 @@ class VictronDeviceSettings extends deviceSettings_1.DeviceSettings {
68
73
  this.excessEnergyTurnOffThreshold = 50;
69
74
  }
70
75
  fromPartialObject(data) {
71
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
76
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
72
77
  this.maxBatteryLoadWattage = (_a = data.maxBatteryLoadWattage) !== null && _a !== void 0 ? _a : this.maxBatteryLoadWattage;
73
78
  this.batteryReportingInterval = (_b = data.batteryReportingInterval) !== null && _b !== void 0 ? _b : this.batteryReportingInterval;
74
79
  this.hasBattery = (_c = data.hasBattery) !== null && _c !== void 0 ? _c : this.hasBattery;
75
80
  this.hasGrid = (_d = data.hasGrid) !== null && _d !== void 0 ? _d : this.hasGrid;
76
81
  this.hasSolar = (_e = data.hasSolar) !== null && _e !== void 0 ? _e : this.hasSolar;
77
82
  this.minimumNightTimeAcBatteryLevel = (_f = data.minimumNightTimeAcBatteryLevel) !== null && _f !== void 0 ? _f : this.minimumNightTimeAcBatteryLevel;
83
+ this.minimumMorningSunnyDayAcBatteryLevel =
84
+ (_g = data.minimumMorningSunnyDayAcBatteryLevel) !== null && _g !== void 0 ? _g : this.minimumMorningSunnyDayAcBatteryLevel;
78
85
  this.minimumTransientTimeAcBatteryLevel =
79
- (_g = data.minimumTransientTimeAcBatteryLevel) !== null && _g !== void 0 ? _g : this.minimumTransientTimeAcBatteryLevel;
80
- this.minimumDayTimeAcBatteryLevel = (_h = data.minimumDayTimeAcBatteryLevel) !== null && _h !== void 0 ? _h : this.minimumDayTimeAcBatteryLevel;
81
- this.batteryCapacityWattage = (_j = data.batteryCapacityWattage) !== null && _j !== void 0 ? _j : this.batteryCapacityWattage;
82
- this.normalBaseConsumptionWattage = (_k = data.normalBaseConsumptionWattage) !== null && _k !== void 0 ? _k : this.normalBaseConsumptionWattage;
83
- this.maximumBatteryDischargeWattage = (_l = data.maximumBatteryDischargeWattage) !== null && _l !== void 0 ? _l : this.maximumBatteryDischargeWattage;
84
- this.excessEnergyTurnOnThreshold = (_m = data.excessEnergyTurnOnThreshold) !== null && _m !== void 0 ? _m : this.excessEnergyTurnOnThreshold;
85
- this.excessEnergyTurnOffThreshold = (_o = data.excessEnergyTurnOffThreshold) !== null && _o !== void 0 ? _o : this.excessEnergyTurnOffThreshold;
86
+ (_h = data.minimumTransientTimeAcBatteryLevel) !== null && _h !== void 0 ? _h : this.minimumTransientTimeAcBatteryLevel;
87
+ this.minimumDayTimeAcBatteryLevel = (_j = data.minimumDayTimeAcBatteryLevel) !== null && _j !== void 0 ? _j : this.minimumDayTimeAcBatteryLevel;
88
+ this.batteryCapacityWattage = (_k = data.batteryCapacityWattage) !== null && _k !== void 0 ? _k : this.batteryCapacityWattage;
89
+ this.normalBaseConsumptionWattage = (_l = data.normalBaseConsumptionWattage) !== null && _l !== void 0 ? _l : this.normalBaseConsumptionWattage;
90
+ this.maximumBatteryDischargeWattage = (_m = data.maximumBatteryDischargeWattage) !== null && _m !== void 0 ? _m : this.maximumBatteryDischargeWattage;
91
+ this.excessEnergyTurnOnThreshold = (_o = data.excessEnergyTurnOnThreshold) !== null && _o !== void 0 ? _o : this.excessEnergyTurnOnThreshold;
92
+ this.excessEnergyTurnOffThreshold = (_p = data.excessEnergyTurnOffThreshold) !== null && _p !== void 0 ? _p : this.excessEnergyTurnOffThreshold;
86
93
  super.fromPartialObject(data);
87
94
  }
88
95
  toJSON() {