hoffmation-base 2.8.9 → 2.9.1

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.
Files changed (27) hide show
  1. package/lib/models/deviceSettings/acSettings.d.ts +5 -0
  2. package/lib/models/deviceSettings/acSettings.js +7 -1
  3. package/lib/models/deviceSettings/handleSettings.d.ts +8 -0
  4. package/lib/models/deviceSettings/handleSettings.js +24 -0
  5. package/lib/models/deviceSettings/victronDeviceSettings.d.ts +4 -0
  6. package/lib/models/deviceSettings/victronDeviceSettings.js +9 -1
  7. package/lib/server/devices/baseDeviceInterfaces/iEnergyManager.d.ts +0 -13
  8. package/lib/server/devices/baseDeviceInterfaces/iEnergyManager.js +0 -28
  9. package/lib/server/devices/groups/Window.d.ts +4 -0
  10. package/lib/server/devices/groups/Window.js +4 -0
  11. package/lib/server/devices/groups/windowGroup.js +16 -0
  12. package/lib/server/devices/hmIPDevices/hmIpGriff.d.ts +2 -0
  13. package/lib/server/devices/hmIPDevices/hmIpGriff.js +11 -3
  14. package/lib/server/devices/jsObject/jsObjectEnergyManager.d.ts +2 -1
  15. package/lib/server/devices/jsObject/jsObjectEnergyManager.js +7 -7
  16. package/lib/server/devices/models/index.d.ts +1 -0
  17. package/lib/server/devices/models/index.js +1 -0
  18. package/lib/server/devices/models/phaseState.d.ts +13 -0
  19. package/lib/server/devices/models/phaseState.js +30 -0
  20. package/lib/server/services/ac/ac-device.js +14 -7
  21. package/lib/server/services/ac/own-daikin-device.js +2 -2
  22. package/lib/server/services/time-callback-service.d.ts +1 -0
  23. package/lib/server/services/time-callback-service.js +3 -0
  24. package/lib/server/services/victron/victron-device.js +12 -4
  25. package/lib/server/services/weather/weather-service.js +3 -1
  26. package/lib/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +4 -4
@@ -21,6 +21,11 @@ export declare class AcSettings extends DeviceSettings {
21
21
  * @type {boolean}
22
22
  */
23
23
  heatingAllowed: boolean;
24
+ /**
25
+ * Whether we should ignore the room temperature and let the AC decide on its own
26
+ * @type {boolean}
27
+ */
28
+ useOwnTemperatureAndAutomatic: boolean;
24
29
  fromPartialObject(data: Partial<AcSettings>): void;
25
30
  protected toJSON(): Partial<AcSettings>;
26
31
  }
@@ -27,9 +27,14 @@ class AcSettings extends deviceSettings_1.DeviceSettings {
27
27
  * @type {boolean}
28
28
  */
29
29
  this.heatingAllowed = false;
30
+ /**
31
+ * Whether we should ignore the room temperature and let the AC decide on its own
32
+ * @type {boolean}
33
+ */
34
+ this.useOwnTemperatureAndAutomatic = false;
30
35
  }
31
36
  fromPartialObject(data) {
32
- var _a, _b, _c, _d, _e, _f, _g;
37
+ var _a, _b, _c, _d, _e, _f, _g, _h;
33
38
  this.minimumHours = (_a = data.minimumHours) !== null && _a !== void 0 ? _a : this.minimumHours;
34
39
  this.minimumMinutes = (_b = data.minimumMinutes) !== null && _b !== void 0 ? _b : this.minimumMinutes;
35
40
  this.maximumHours = (_c = data.maximumHours) !== null && _c !== void 0 ? _c : this.maximumHours;
@@ -37,6 +42,7 @@ class AcSettings extends deviceSettings_1.DeviceSettings {
37
42
  this.stopCoolingTemperatur = (_e = data.stopCoolingTemperatur) !== null && _e !== void 0 ? _e : this.stopCoolingTemperatur;
38
43
  this.stopHeatingTemperatur = (_f = data.stopHeatingTemperatur) !== null && _f !== void 0 ? _f : this.stopHeatingTemperatur;
39
44
  this.heatingAllowed = (_g = data.heatingAllowed) !== null && _g !== void 0 ? _g : this.heatingAllowed;
45
+ this.useOwnTemperatureAndAutomatic = (_h = data.useOwnTemperatureAndAutomatic) !== null && _h !== void 0 ? _h : this.useOwnTemperatureAndAutomatic;
40
46
  super.fromPartialObject(data);
41
47
  }
42
48
  toJSON() {
@@ -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
- services_1.TelegramService.inform(info);
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
- services_1.TelegramService.inform(info);
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
- services_1.TelegramService.inform(`${this.info.room}: ${message}`);
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, PhaseState } from '../baseDeviceInterfaces';
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 baseDeviceInterfaces_1.PhaseState(0, 0);
24
- this._phaseBState = new baseDeviceInterfaces_1.PhaseState(0, 0);
25
- this._phaseCState = new baseDeviceInterfaces_1.PhaseState(0, 0);
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 baseDeviceInterfaces_1.PhaseState(this._powerValuePhaseA, phaseProduction);
137
- this._phaseBState = new baseDeviceInterfaces_1.PhaseState(this._powerValuePhaseB, phaseProduction);
138
- this._phaseCState = new baseDeviceInterfaces_1.PhaseState(this._powerValuePhaseC, phaseProduction);
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
  }
@@ -1,2 +1,3 @@
1
1
  export * from './WindowPosition';
2
2
  export * from './MagnetPosition';
3
+ export * from './phaseState';
@@ -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;
@@ -62,6 +62,9 @@ class AcDevice {
62
62
  return (_a = this.info.allDevicesKey) !== null && _a !== void 0 ? _a : `ac-${this.info.room}-${this.info.customName}`;
63
63
  }
64
64
  isAvailableForExcessEnergy() {
65
+ if (this.settings.useOwnTemperatureAndAutomatic) {
66
+ return false;
67
+ }
65
68
  if (utils_1.Utils.nowMS() < this._blockAutomaticChangeMS) {
66
69
  return false;
67
70
  }
@@ -72,25 +75,29 @@ class AcDevice {
72
75
  }
73
76
  calculateDesiredMode() {
74
77
  var _a, _b;
75
- const temp = this.roomTemperature;
76
- if (temp === undefined || temp === devices_1.UNDEFINED_TEMP_VALUE) {
77
- this.log(models_1.LogLevel.Warn, `Can't calculate AC Mode as we have no room temperature`);
78
- return ac_mode_1.AcMode.Off;
79
- }
80
78
  const acOn = this.on;
81
79
  // Check Turn Off Time
82
80
  if (!utils_1.Utils.timeWithinBorders(this.settings.minimumHours, this.settings.minimumMinutes, this.settings.maximumHours, this.settings.maximumMinutes)) {
83
81
  this.on && this.log(models_1.LogLevel.Info, `We should turn off now, to respect night settings.`);
84
82
  return ac_mode_1.AcMode.Off;
85
83
  }
84
+ if (this.settings.useOwnTemperatureAndAutomatic) {
85
+ // Device is in automatic mode so ignore energy and room temperature
86
+ return settings_service_1.SettingsService.heatMode === config_1.HeatingMode.Sommer ? ac_mode_1.AcMode.Cooling : ac_mode_1.AcMode.Heating;
87
+ }
88
+ const temp = this.roomTemperature;
89
+ if (temp === undefined || temp === devices_1.UNDEFINED_TEMP_VALUE) {
90
+ this.log(models_1.LogLevel.Warn, `Can't calculate AC Mode as we have no room temperature`);
91
+ return ac_mode_1.AcMode.Off;
92
+ }
86
93
  let threshold = acOn ? 0 : 1;
87
94
  let thresholdHeating = acOn ? 0 : 0.5;
88
95
  let desiredMode = ac_mode_1.AcMode.Off;
89
96
  const excessEnergy = (_b = (_a = devices_1.Devices.energymanager) === null || _a === void 0 ? void 0 : _a.excessEnergy) !== null && _b !== void 0 ? _b : -1;
90
97
  if ((acOn ? 200 : 1000) < excessEnergy) {
91
98
  // As there is plenty of energy to spare we plan to overshoot the target by 1 degree
92
- threshold = -1;
93
- thresholdHeating = -1;
99
+ threshold = -0.5;
100
+ thresholdHeating = -0.5;
94
101
  }
95
102
  const coolUntil = this.settings.stopCoolingTemperatur + threshold;
96
103
  const heatUntil = this.settings.stopHeatingTemperatur - thresholdHeating;
@@ -81,10 +81,10 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
81
81
  var _a;
82
82
  let targetTemp = this.desiredTemp;
83
83
  if (this.desiredMode == daikin_controller_1.Mode.HOT) {
84
- targetTemp = 29;
84
+ targetTemp = this.settings.useOwnTemperatureAndAutomatic ? this.settings.stopHeatingTemperatur : 29;
85
85
  }
86
86
  else if (this.desiredMode == daikin_controller_1.Mode.COLD) {
87
- targetTemp = 16;
87
+ targetTemp = this.settings.useOwnTemperatureAndAutomatic ? this.settings.stopCoolingTemperatur : 16;
88
88
  }
89
89
  const changeObject = {
90
90
  power: this.desiredState,
@@ -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 > 400) {
66
+ if (this.excessEnergy > this.settings.excessEnergyTurnOnThreshold) {
66
67
  this.turnOnAdditionalConsumer();
67
68
  }
68
- else if (this.excessEnergy < 200) {
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 = 0;
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
- logger(models_1.LogLevel.Info, `weatherRolloPosition(${normalPos}, ${desiredTemperatur}, ${currentTemperatur}) --> Target: ${result}`);
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() {