hoffmation-base 0.1.38-9 → 0.1.41-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.
@@ -3,4 +3,15 @@ export declare class ActuatorSettings extends DeviceSettings {
3
3
  dawnOn: boolean;
4
4
  duskOn: boolean;
5
5
  nightOn: boolean;
6
+ /**
7
+ * Indicates if this device controls e.g. an Eltako, which has it's own Turn Off Time logic.
8
+ * @type {boolean}
9
+ */
10
+ isStromStoss: boolean;
11
+ /**
12
+ * If this is an Actuator controling a time based relais,
13
+ * this indicates the time after which we retrigger the relais.
14
+ * @type {number}
15
+ */
16
+ stromStossResendTime: number;
6
17
  }
@@ -8,6 +8,17 @@ class ActuatorSettings extends deviceSettings_1.DeviceSettings {
8
8
  this.dawnOn = true;
9
9
  this.duskOn = true;
10
10
  this.nightOn = true;
11
+ /**
12
+ * Indicates if this device controls e.g. an Eltako, which has it's own Turn Off Time logic.
13
+ * @type {boolean}
14
+ */
15
+ this.isStromStoss = false;
16
+ /**
17
+ * If this is an Actuator controling a time based relais,
18
+ * this indicates the time after which we retrigger the relais.
19
+ * @type {number}
20
+ */
21
+ this.stromStossResendTime = 180;
11
22
  }
12
23
  }
13
24
  exports.ActuatorSettings = ActuatorSettings;
@@ -1,8 +1,8 @@
1
1
  export declare class EnergyCalculation {
2
2
  startMs: number;
3
- drawnWattage: number;
4
- injectedWattage: number;
5
- selfConsumedWattage: number;
3
+ drawnKwH: number;
4
+ injectedKwH: number;
5
+ selfConsumedKwH: number;
6
6
  costDrawn: number;
7
7
  earnedInjected: number;
8
8
  savedSelfConsume: number;
@@ -4,9 +4,9 @@ exports.EnergyCalculation = void 0;
4
4
  class EnergyCalculation {
5
5
  constructor(startMs) {
6
6
  this.startMs = startMs;
7
- this.drawnWattage = 0;
8
- this.injectedWattage = 0;
9
- this.selfConsumedWattage = 0;
7
+ this.drawnKwH = 0;
8
+ this.injectedKwH = 0;
9
+ this.selfConsumedKwH = 0;
10
10
  this.costDrawn = 0;
11
11
  this.earnedInjected = 0;
12
12
  this.savedSelfConsume = 0;
@@ -1,6 +1,6 @@
1
- import { ZigbeeIkeaSteckdose } from '../zigbee/zigbeeIkeaSteckdose';
2
- import { TimeOfDay } from '../../services/time-callback-service';
3
- import { ZigbeeIlluLedRGBCCT } from '../zigbee/zigbeeIlluLedRGBCCT';
1
+ import { ZigbeeIkeaSteckdose } from '../zigbee';
2
+ import { TimeOfDay } from '../../services';
3
+ import { ZigbeeIlluLedRGBCCT } from '../zigbee';
4
4
  import { BaseGroup } from './base-group';
5
5
  import { iLamp } from '../iLamp';
6
6
  export declare class LampenGroup extends BaseGroup {
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LampenGroup = void 0;
4
- const time_callback_service_1 = require("../../services/time-callback-service");
4
+ const services_1 = require("../../services");
5
5
  const base_group_1 = require("./base-group");
6
6
  const group_type_1 = require("./group-type");
7
7
  const device_cluster_type_1 = require("../device-cluster-type");
8
8
  const device_list_1 = require("../device-list");
9
- const logLevel_1 = require("../../../models/logLevel");
9
+ const models_1 = require("../../../models");
10
10
  class LampenGroup extends base_group_1.BaseGroup {
11
11
  constructor(roomName, lampenIds = [], steckerIds = [], ledIds = []) {
12
12
  super(roomName, group_type_1.GroupType.Light);
@@ -50,21 +50,21 @@ class LampenGroup extends base_group_1.BaseGroup {
50
50
  });
51
51
  }
52
52
  switchTimeConditional(time) {
53
- const darkOutside = time_callback_service_1.TimeCallbackService.darkOutsideOrNight(time);
53
+ const darkOutside = services_1.TimeCallbackService.darkOutsideOrNight(time);
54
54
  let resultLampen = false;
55
55
  let resultSteckdosen = false;
56
56
  if (this.getLED().length > 0) {
57
- this.log(logLevel_1.LogLevel.Trace, `Set LEDs time based for time "${time_callback_service_1.TimeOfDay[time]}"`);
57
+ this.log(models_1.LogLevel.Trace, `Set LEDs time based for time "${services_1.TimeOfDay[time]}"`);
58
58
  this.getLED().forEach((s) => {
59
59
  s.setTimeBased(time);
60
60
  });
61
61
  }
62
62
  else if (this.getStecker().length > 0) {
63
- this.log(logLevel_1.LogLevel.Trace, `Set outlets time based for time "${time_callback_service_1.TimeOfDay[time]}"`);
63
+ this.log(models_1.LogLevel.Trace, `Set outlets time based for time "${services_1.TimeOfDay[time]}"`);
64
64
  resultSteckdosen = darkOutside;
65
65
  }
66
66
  else {
67
- this.log(logLevel_1.LogLevel.Trace, `Set Lamps time based for time "${time_callback_service_1.TimeOfDay[time]}"`);
67
+ this.log(models_1.LogLevel.Trace, `Set Lamps time based for time "${services_1.TimeOfDay[time]}"`);
68
68
  resultLampen = darkOutside;
69
69
  }
70
70
  this.setAllLampen(resultLampen, time);
@@ -74,12 +74,12 @@ class LampenGroup extends base_group_1.BaseGroup {
74
74
  this.getLampen().forEach((s) => {
75
75
  if (!pValue ||
76
76
  time === undefined ||
77
- (time === time_callback_service_1.TimeOfDay.Night && s.settings.nightOn) ||
78
- (time === time_callback_service_1.TimeOfDay.BeforeSunrise && s.settings.dawnOn) ||
79
- (time === time_callback_service_1.TimeOfDay.AfterSunset && s.settings.duskOn)) {
77
+ (time === services_1.TimeOfDay.Night && s.settings.nightOn) ||
78
+ (time === services_1.TimeOfDay.BeforeSunrise && s.settings.dawnOn) ||
79
+ (time === services_1.TimeOfDay.AfterSunset && s.settings.duskOn)) {
80
80
  const timeout = pValue && force ? 30 * 60 * 1000 : -1;
81
81
  if (pValue && time !== undefined) {
82
- s.setTimeBased(time);
82
+ s.setTimeBased(time, timeout, force);
83
83
  }
84
84
  else {
85
85
  s.setLight(pValue, timeout, force);
@@ -91,9 +91,9 @@ class LampenGroup extends base_group_1.BaseGroup {
91
91
  this.getStecker().forEach((s) => {
92
92
  if (!pValue ||
93
93
  time === undefined ||
94
- (time === time_callback_service_1.TimeOfDay.Night && s.settings.nightOn) ||
95
- (time === time_callback_service_1.TimeOfDay.BeforeSunrise && s.settings.dawnOn) ||
96
- (time === time_callback_service_1.TimeOfDay.AfterSunset && s.settings.duskOn)) {
94
+ (time === services_1.TimeOfDay.Night && s.settings.nightOn) ||
95
+ (time === services_1.TimeOfDay.BeforeSunrise && s.settings.dawnOn) ||
96
+ (time === services_1.TimeOfDay.AfterSunset && s.settings.duskOn)) {
97
97
  const timeout = pValue && force ? 30 * 60 * 1000 : -1;
98
98
  s.setStecker(pValue, timeout, force);
99
99
  }
@@ -1,29 +1,20 @@
1
1
  /// <reference types="iobroker" />
2
2
  import { HmIPDevice } from './hmIpDevice';
3
- import { ActuatorSettings } from '../../../models/deviceSettings/actuatorSettings';
3
+ import { ActuatorSettings } from '../../../models';
4
4
  import { DeviceInfo } from '../DeviceInfo';
5
5
  import { iLamp } from '../iLamp';
6
- import { TimeOfDay } from '../../services/time-callback-service';
6
+ import { TimeOfDay } from '../../services';
7
7
  export declare class HmIpLampe extends HmIPDevice implements iLamp {
8
8
  lightOn: boolean;
9
9
  queuedLightValue: boolean | null;
10
- isStromStoss: boolean;
11
10
  settings: ActuatorSettings;
12
11
  private lightOnSwitchID;
13
12
  private _turnOffTimeout;
14
13
  private turnOffTime;
15
14
  constructor(pInfo: DeviceInfo);
16
15
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
17
- /**
18
- * This function thats the light to a specific value
19
- * @param pValue The desired value
20
- * @param timeout A chosen Timeout after which the light should be reset
21
- */
16
+ /** @inheritdoc */
22
17
  setLight(pValue: boolean, timeout?: number, force?: boolean): void;
23
- /**
24
- * Switch the current condition of the light
25
- * @param force Whether this is a forcing action skipping delays and locks
26
- */
27
- toggleLight(force?: boolean): boolean;
28
- setTimeBased(time: TimeOfDay): void;
18
+ toggleLight(time?: TimeOfDay, force?: boolean, calculateTime?: boolean): boolean;
19
+ setTimeBased(time: TimeOfDay, timeout?: number, force?: boolean): void;
29
20
  }
@@ -3,24 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HmIpLampe = void 0;
4
4
  const hmIpDevice_1 = require("./hmIpDevice");
5
5
  const deviceType_1 = require("../deviceType");
6
- const utils_1 = require("../../services/utils/utils");
7
- const actuatorSettings_1 = require("../../../models/deviceSettings/actuatorSettings");
8
- const logLevel_1 = require("../../../models/logLevel");
9
- const time_callback_service_1 = require("../../services/time-callback-service");
6
+ const services_1 = require("../../services");
7
+ const models_1 = require("../../../models");
8
+ const models_2 = require("../../../models");
9
+ const services_2 = require("../../services");
10
10
  class HmIpLampe extends hmIpDevice_1.HmIPDevice {
11
11
  constructor(pInfo) {
12
12
  super(pInfo, deviceType_1.DeviceType.HmIpLampe);
13
13
  this.lightOn = false;
14
14
  this.queuedLightValue = null;
15
- this.isStromStoss = false;
16
- this.settings = new actuatorSettings_1.ActuatorSettings();
15
+ this.settings = new models_1.ActuatorSettings();
17
16
  this.lightOnSwitchID = '';
18
17
  this._turnOffTimeout = undefined;
19
18
  this.turnOffTime = 0;
20
19
  this.lightOnSwitchID = `${this.info.fullID}.2.STATE`;
21
20
  }
22
21
  update(idSplit, state, initial = false) {
23
- this.log(logLevel_1.LogLevel.DeepTrace, `Lampen Update : ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
22
+ this.log(models_2.LogLevel.DeepTrace, `Lampen Update : ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
24
23
  super.update(idSplit, state, initial, true);
25
24
  this.queuedLightValue = null;
26
25
  switch (idSplit[3]) {
@@ -31,31 +30,33 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
31
30
  break;
32
31
  }
33
32
  }
34
- /**
35
- * This function thats the light to a specific value
36
- * @param pValue The desired value
37
- * @param timeout A chosen Timeout after which the light should be reset
38
- */
33
+ /** @inheritdoc */
39
34
  setLight(pValue, timeout = -1, force = false) {
40
35
  if (!force && pValue === this.lightOn && this.queuedLightValue === null) {
41
- this.log(logLevel_1.LogLevel.DeepTrace, `Skip light command as it is already ${pValue}`);
36
+ this.log(models_2.LogLevel.DeepTrace, `Skip light command as it is already ${pValue}`);
42
37
  return;
43
38
  }
44
39
  if (this.lightOnSwitchID === '') {
45
- this.log(logLevel_1.LogLevel.Error, `Keine Switch ID bekannt.`);
40
+ this.log(models_2.LogLevel.Error, `Keine Switch ID bekannt.`);
46
41
  return;
47
42
  }
48
- if (!force && utils_1.Utils.nowMS() < this.turnOffTime) {
49
- this.log(logLevel_1.LogLevel.Debug, `Skip automatic command to ${pValue} as it is locked until ${new Date(this.turnOffTime).toLocaleString()}`);
43
+ if (!force && services_1.Utils.nowMS() < this.turnOffTime) {
44
+ this.log(models_2.LogLevel.Debug, `Skip automatic command to ${pValue} as it is locked until ${new Date(this.turnOffTime).toLocaleString()}`);
50
45
  return;
51
46
  }
52
- this.log(logLevel_1.LogLevel.Debug, `Lampe schalten Wert: ${pValue}`);
47
+ this.log(models_2.LogLevel.Debug, `Lampe schalten Wert: ${pValue}`);
53
48
  this.setState(this.lightOnSwitchID, pValue, undefined, (err) => {
54
- this.log(logLevel_1.LogLevel.Error, `Lampe schalten ergab Fehler: ${err}`);
49
+ this.log(models_2.LogLevel.Error, `Lampe schalten ergab Fehler: ${err}`);
55
50
  });
56
51
  this.queuedLightValue = pValue;
57
- if (this.isStromStoss) {
58
- timeout = 5000;
52
+ if (this.settings.isStromStoss) {
53
+ timeout = 3000;
54
+ services_1.Utils.guardedTimeout(() => {
55
+ var _a;
56
+ if (this.room && ((_a = this.room.PraesenzGroup) === null || _a === void 0 ? void 0 : _a.anyPresent())) {
57
+ this.setLight(true, -1, true);
58
+ }
59
+ }, this.settings.stromStossResendTime * 1000, this);
59
60
  }
60
61
  if (this._turnOffTimeout !== undefined) {
61
62
  clearTimeout(this._turnOffTimeout);
@@ -64,9 +65,9 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
64
65
  if (timeout < 0 || !pValue) {
65
66
  return;
66
67
  }
67
- this.turnOffTime = utils_1.Utils.nowMS() + timeout;
68
- this._turnOffTimeout = utils_1.Utils.guardedTimeout(() => {
69
- this.log(logLevel_1.LogLevel.Debug, `Delayed Turnoff initiated`);
68
+ this.turnOffTime = services_1.Utils.nowMS() + timeout;
69
+ this._turnOffTimeout = services_1.Utils.guardedTimeout(() => {
70
+ this.log(models_2.LogLevel.Debug, `Delayed Turnoff initiated`);
70
71
  this._turnOffTimeout = undefined;
71
72
  if (!this.room) {
72
73
  this.setLight(false, -1, true);
@@ -76,21 +77,25 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
76
77
  }
77
78
  }, timeout, this);
78
79
  }
79
- /**
80
- * Switch the current condition of the light
81
- * @param force Whether this is a forcing action skipping delays and locks
82
- */
83
- toggleLight(force = false) {
80
+ toggleLight(time, force = false, calculateTime = false) {
81
+ var _a;
84
82
  const newVal = this.queuedLightValue !== null ? !this.queuedLightValue : !this.lightOn;
85
83
  const timeout = newVal && force ? 30 * 60 * 1000 : -1;
84
+ if (newVal && time === undefined && calculateTime && this.room !== undefined) {
85
+ time = services_2.TimeCallbackService.dayType((_a = this.room) === null || _a === void 0 ? void 0 : _a.settings.lampOffset);
86
+ }
87
+ if (newVal && time !== undefined) {
88
+ this.setTimeBased(time, timeout, force);
89
+ return true;
90
+ }
86
91
  this.setLight(newVal, timeout, force);
87
92
  return newVal;
88
93
  }
89
- setTimeBased(time) {
90
- if ((time === time_callback_service_1.TimeOfDay.Night && this.settings.nightOn) ||
91
- (time === time_callback_service_1.TimeOfDay.BeforeSunrise && this.settings.dawnOn) ||
92
- (time === time_callback_service_1.TimeOfDay.AfterSunset && this.settings.duskOn)) {
93
- this.setLight(true);
94
+ setTimeBased(time, timeout = -1, force = false) {
95
+ if ((time === services_2.TimeOfDay.Night && this.settings.nightOn) ||
96
+ (time === services_2.TimeOfDay.BeforeSunrise && this.settings.dawnOn) ||
97
+ (time === services_2.TimeOfDay.AfterSunset && this.settings.duskOn)) {
98
+ this.setLight(true, timeout, force);
94
99
  }
95
100
  }
96
101
  }
@@ -6,6 +6,9 @@ export interface iEnergyManager extends IoBrokerBaseDevice {
6
6
  excessEnergy: number;
7
7
  excessEnergyConsumerConsumption: number;
8
8
  totalConsumption: number;
9
+ drawingWattage: number;
10
+ selfConsumingWattage: number;
11
+ injectingWattage: number;
9
12
  addExcessConsumer(device: iExcessEnergyConsumer): void;
10
13
  recalculatePowerSharing(): void;
11
14
  cleanup(): void;
@@ -1,11 +1,18 @@
1
- import { ActuatorSettings } from '../../models/deviceSettings/actuatorSettings';
2
- import { RoomBase } from '../../models/rooms/RoomBase';
3
- import { TimeOfDay } from '../services/time-callback-service';
1
+ import { ActuatorSettings } from '../../models';
2
+ import { RoomBase } from '../../models';
3
+ import { TimeOfDay } from '../services';
4
4
  import { IoBrokerBaseDevice } from './IoBrokerBaseDevice';
5
5
  export interface iLamp extends IoBrokerBaseDevice {
6
6
  settings: ActuatorSettings;
7
7
  lightOn: boolean;
8
8
  room: RoomBase | undefined;
9
- setTimeBased(time: TimeOfDay): void;
9
+ setTimeBased(time: TimeOfDay, timeout: number, force: boolean): void;
10
+ toggleLight(time: TimeOfDay, force: boolean, calculateTime: boolean): void;
11
+ /**
12
+ * This function sets the light to a specific value
13
+ * @param pValue The desired value
14
+ * @param timeout A chosen Timeout after which the light should be reset
15
+ * @param force Wether it is a action based on a user action, to override certain rules
16
+ */
10
17
  setLight(pValue: boolean, timeout: number, force: boolean): void;
11
18
  }
@@ -4,10 +4,25 @@ import { iEnergyManager } from '../iEnergyManager';
4
4
  import { iExcessEnergyConsumer } from '../iExcessEnergyConsumer';
5
5
  import { DeviceInfo } from '../DeviceInfo';
6
6
  export declare class JsObjectEnergyManager extends IoBrokerBaseDevice implements iEnergyManager {
7
+ /**
8
+ * Example:
9
+ * ________________________________________
10
+ * | ExcessEnergy | 500W | -500W | -500W |
11
+ * | Production | 1500W | 500W | 0W |
12
+ * _______________________________________
13
+ * | Consumption | 1000W | 1000W | 500W |
14
+ * | Injecting | 500W | 0W | 0W |
15
+ * | drawing | 0W | 500W | 500W |
16
+ * | selfConsume | 1000W | 500W | 0W |
17
+ * ________________________________________
18
+ **/
7
19
  get excessEnergyConsumerConsumption(): number;
8
20
  get excessEnergy(): number;
9
21
  get baseConsumption(): number;
10
22
  get totalConsumption(): number;
23
+ get injectingWattage(): number;
24
+ get drawingWattage(): number;
25
+ get selfConsumingWattage(): number;
11
26
  get currentProduction(): number;
12
27
  private _currentProduction;
13
28
  private _excessEnergy;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JsObjectEnergyManager = void 0;
4
4
  const IoBrokerBaseDevice_1 = require("../IoBrokerBaseDevice");
5
5
  const deviceType_1 = require("../deviceType");
6
- const logLevel_1 = require("../../../models/logLevel");
7
- const utils_1 = require("../../services/utils/utils");
6
+ const models_1 = require("../../../models");
7
+ const services_1 = require("../../services");
8
8
  const index_1 = require("../../../index");
9
9
  class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
10
10
  constructor(info) {
@@ -14,13 +14,25 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
14
14
  this._excessEnergyConsumerConsumption = 0;
15
15
  this._excessEnergyConsumer = [];
16
16
  this._iDatabaseLoggerInterval = null;
17
- this._lastPersistenceCalculation = utils_1.Utils.nowMS();
18
- this.log(logLevel_1.LogLevel.Info, `Creating Energy Manager Device`);
19
- this._iDatabaseLoggerInterval = utils_1.Utils.guardedInterval(() => {
17
+ this._lastPersistenceCalculation = services_1.Utils.nowMS();
18
+ this.log(models_1.LogLevel.Info, `Creating Energy Manager Device`);
19
+ this._iDatabaseLoggerInterval = services_1.Utils.guardedInterval(() => {
20
20
  this.persist();
21
21
  }, 15 * 60 * 1000, this);
22
- this._nextPersistEntry = new index_1.EnergyCalculation(utils_1.Utils.nowMS());
22
+ this._nextPersistEntry = new index_1.EnergyCalculation(services_1.Utils.nowMS());
23
23
  }
24
+ /**
25
+ * Example:
26
+ * ________________________________________
27
+ * | ExcessEnergy | 500W | -500W | -500W |
28
+ * | Production | 1500W | 500W | 0W |
29
+ * _______________________________________
30
+ * | Consumption | 1000W | 1000W | 500W |
31
+ * | Injecting | 500W | 0W | 0W |
32
+ * | drawing | 0W | 500W | 500W |
33
+ * | selfConsume | 1000W | 500W | 0W |
34
+ * ________________________________________
35
+ **/
24
36
  get excessEnergyConsumerConsumption() {
25
37
  return this._excessEnergyConsumerConsumption;
26
38
  }
@@ -33,6 +45,15 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
33
45
  get totalConsumption() {
34
46
  return this._currentProduction - this._excessEnergy;
35
47
  }
48
+ get injectingWattage() {
49
+ return Math.max(this._excessEnergy, 0);
50
+ }
51
+ get drawingWattage() {
52
+ return Math.min(this._excessEnergy, 0) * -1;
53
+ }
54
+ get selfConsumingWattage() {
55
+ return Math.min(this.totalConsumption, this._currentProduction);
56
+ }
36
57
  get currentProduction() {
37
58
  return this._currentProduction;
38
59
  }
@@ -49,14 +70,14 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
49
70
  // TODO Implement
50
71
  }
51
72
  update(idSplit, state, initial, pOverride = false) {
52
- this.log(logLevel_1.LogLevel.DeepTrace, `EnergyManager: ${initial ? 'Initial ' : ''} update: ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}, override: ${pOverride}`);
73
+ this.log(models_1.LogLevel.DeepTrace, `EnergyManager: ${initial ? 'Initial ' : ''} update: ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}, override: ${pOverride}`);
53
74
  switch (idSplit[3]) {
54
75
  case 'CurrentExcessEnergy':
55
- this.log(logLevel_1.LogLevel.Trace, `Current excess energy update to ${state.val}`);
76
+ this.log(models_1.LogLevel.Trace, `Current excess energy update to ${state.val}`);
56
77
  this.setExcessEnergy(state.val);
57
78
  break;
58
79
  case 'CurrentProduction':
59
- this.log(logLevel_1.LogLevel.Trace, `Current Production Update to ${state.val}`);
80
+ this.log(models_1.LogLevel.Trace, `Current Production Update to ${state.val}`);
60
81
  this._currentProduction = state.val;
61
82
  break;
62
83
  }
@@ -67,34 +88,30 @@ class JsObjectEnergyManager extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
67
88
  this.recalculatePowerSharing();
68
89
  }
69
90
  calculatePersistenceValues() {
70
- const now = utils_1.Utils.nowMS();
91
+ const now = services_1.Utils.nowMS();
71
92
  const duration = now - this._lastPersistenceCalculation;
72
- if (this.excessEnergy < 0) {
73
- this._nextPersistEntry.drawnWattage += utils_1.Utils.kWh(this.excessEnergy * -1, duration);
74
- }
75
- else {
76
- this._nextPersistEntry.injectedWattage += utils_1.Utils.kWh(this.excessEnergy, duration);
77
- this._nextPersistEntry.selfConsumedWattage += utils_1.Utils.kWh(this.totalConsumption, duration);
78
- }
93
+ this._nextPersistEntry.drawnKwH += services_1.Utils.kWh(this.drawingWattage, duration);
94
+ this._nextPersistEntry.injectedKwH += services_1.Utils.kWh(this.injectingWattage, duration);
95
+ this._nextPersistEntry.selfConsumedKwH += services_1.Utils.kWh(this.selfConsumingWattage, duration);
79
96
  this._lastPersistenceCalculation = now;
80
97
  }
81
98
  persist() {
82
99
  var _a;
83
100
  const obj = JSON.parse(JSON.stringify(this._nextPersistEntry));
84
- if (obj.drawnWattage === 0 && obj.injectedWattage === 0 && obj.selfConsumedWattage === 0) {
85
- this.log(logLevel_1.LogLevel.Warn, `Not persisting energy Data, as all values are 0.`);
101
+ if (obj.drawnKwH === 0 && obj.injectedKwH === 0 && obj.selfConsumedKwH === 0) {
102
+ this.log(models_1.LogLevel.Warn, `Not persisting energy Data, as all values are 0.`);
86
103
  return;
87
104
  }
88
105
  this._nextPersistEntry = new index_1.EnergyCalculation(this._lastPersistenceCalculation);
89
106
  obj.endMs = this._lastPersistenceCalculation;
90
- obj.earnedInjected = utils_1.Utils.round(obj.injectedWattage * ((_a = index_1.SettingsService.settings.injectWattagePrice) !== null && _a !== void 0 ? _a : 0.06), 4);
91
- obj.savedSelfConsume = utils_1.Utils.round(obj.selfConsumedWattage * index_1.SettingsService.settings.wattagePrice, 4);
92
- obj.costDrawn = utils_1.Utils.round(obj.selfConsumedWattage * index_1.SettingsService.settings.wattagePrice, 4);
93
- obj.injectedWattage = utils_1.Utils.round(obj.injectedWattage, 4);
94
- obj.selfConsumedWattage = utils_1.Utils.round(obj.selfConsumedWattage, 4);
95
- obj.drawnWattage = utils_1.Utils.round(obj.drawnWattage, 4);
107
+ obj.earnedInjected = services_1.Utils.round(obj.injectedKwH * ((_a = index_1.SettingsService.settings.injectWattagePrice) !== null && _a !== void 0 ? _a : 0.06), 4);
108
+ obj.savedSelfConsume = services_1.Utils.round(obj.selfConsumedKwH * index_1.SettingsService.settings.wattagePrice, 4);
109
+ obj.costDrawn = services_1.Utils.round(obj.drawnKwH * index_1.SettingsService.settings.wattagePrice, 4);
110
+ obj.injectedKwH = services_1.Utils.round(obj.injectedKwH, 4);
111
+ obj.selfConsumedKwH = services_1.Utils.round(obj.selfConsumedKwH, 4);
112
+ obj.drawnKwH = services_1.Utils.round(obj.drawnKwH, 4);
96
113
  index_1.dbo === null || index_1.dbo === void 0 ? void 0 : index_1.dbo.persistEnergyManager(obj);
97
- this.log(logLevel_1.LogLevel.Info, `Persisting energy Manager Data.`);
114
+ this.log(models_1.LogLevel.Info, `Persisting energy Manager Data.`);
98
115
  }
99
116
  }
100
117
  exports.JsObjectEnergyManager = JsObjectEnergyManager;
@@ -18,6 +18,11 @@ export declare class ZigbeeIlluDimmer extends ZigbeeDevice implements iLamp {
18
18
  constructor(pInfo: DeviceInfo);
19
19
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
20
20
  setTimeBased(time: TimeOfDay, timeout?: number, force?: boolean): void;
21
+ /**
22
+ * @inheritDoc
23
+ * @param {number} brightness The desired brightness in percent
24
+ * @param {number} transitionTime The transition time for the brightness, to switch smoothly
25
+ */
21
26
  setLight(pValue: boolean, timeout?: number, force?: boolean, brightness?: number, transitionTime?: number): void;
22
27
  toggleLight(time?: TimeOfDay, force?: boolean, calculateTime?: boolean): boolean;
23
28
  }
@@ -59,6 +59,11 @@ class ZigbeeIlluDimmer extends zigbeeDevice_1.ZigbeeDevice {
59
59
  break;
60
60
  }
61
61
  }
62
+ /**
63
+ * @inheritDoc
64
+ * @param {number} brightness The desired brightness in percent
65
+ * @param {number} transitionTime The transition time for the brightness, to switch smoothly
66
+ */
62
67
  setLight(pValue, timeout = -1, force = false, brightness = -1, transitionTime = -1) {
63
68
  if (this.stateID === '') {
64
69
  this.log(logLevel_1.LogLevel.Error, `Keine State ID bekannt.`);
@@ -2,12 +2,13 @@
2
2
  import { DeviceInfo } from '../DeviceInfo';
3
3
  import { ZigbeeIlluActuator } from './zigbeeIlluActuator';
4
4
  import { iLamp } from '../iLamp';
5
- import { TimeOfDay } from '../../services/time-callback-service';
5
+ import { TimeOfDay } from '../../services';
6
6
  export declare class ZigbeeIlluLampe extends ZigbeeIlluActuator implements iLamp {
7
7
  get lightOn(): boolean;
8
8
  constructor(pInfo: DeviceInfo);
9
9
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
10
+ /** @inheritdoc */
10
11
  setLight(pValue: boolean, timeout?: number, force?: boolean): void;
11
- toggleLight(force?: boolean): boolean;
12
- setTimeBased(time: TimeOfDay): void;
12
+ toggleLight(time?: TimeOfDay, force?: boolean, calculateTime?: boolean): boolean;
13
+ setTimeBased(time: TimeOfDay, timeout?: number, force?: boolean): void;
13
14
  }
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZigbeeIlluLampe = void 0;
4
4
  const deviceType_1 = require("../deviceType");
5
5
  const zigbeeIlluActuator_1 = require("./zigbeeIlluActuator");
6
- const logLevel_1 = require("../../../models/logLevel");
7
- const time_callback_service_1 = require("../../services/time-callback-service");
6
+ const models_1 = require("../../../models");
7
+ const services_1 = require("../../services");
8
+ const services_2 = require("../../services");
8
9
  class ZigbeeIlluLampe extends zigbeeIlluActuator_1.ZigbeeIlluActuator {
9
10
  get lightOn() {
10
11
  return super.actuatorOn;
@@ -16,22 +17,43 @@ class ZigbeeIlluLampe extends zigbeeIlluActuator_1.ZigbeeIlluActuator {
16
17
  super.update(idSplit, state, initial, true);
17
18
  switch (idSplit[3]) {
18
19
  case 'state':
19
- this.log(logLevel_1.LogLevel.Trace, `Lampen Update für ${this.info.customName} auf ${state.val}`);
20
+ this.log(models_1.LogLevel.Trace, `Lampen Update für ${this.info.customName} auf ${state.val}`);
20
21
  break;
21
22
  }
22
23
  }
24
+ /** @inheritdoc */
23
25
  setLight(pValue, timeout = -1, force = false) {
24
- this.log(logLevel_1.LogLevel.Debug, `Lampenaktor schalten Wert: ${pValue}`);
26
+ this.log(models_1.LogLevel.Debug, `Lampenaktor schalten Wert: ${pValue}`);
27
+ if (this.settings.isStromStoss) {
28
+ timeout = 3000;
29
+ services_2.Utils.guardedTimeout(() => {
30
+ var _a;
31
+ if (this.room && ((_a = this.room.PraesenzGroup) === null || _a === void 0 ? void 0 : _a.anyPresent())) {
32
+ this.setLight(true, -1, true);
33
+ }
34
+ }, this.settings.stromStossResendTime * 1000, this);
35
+ }
25
36
  super.setActuator(pValue, timeout, force);
26
37
  }
27
- toggleLight(force = false) {
28
- return super.toggleActuator(force);
38
+ toggleLight(time, force = false, calculateTime = false) {
39
+ var _a;
40
+ const newVal = this.queuedValue !== null ? !this.queuedValue : !this.lightOn;
41
+ const timeout = newVal && force ? 30 * 60 * 1000 : -1;
42
+ if (newVal && time === undefined && calculateTime && this.room !== undefined) {
43
+ time = services_1.TimeCallbackService.dayType((_a = this.room) === null || _a === void 0 ? void 0 : _a.settings.lampOffset);
44
+ }
45
+ if (newVal && time !== undefined) {
46
+ this.setTimeBased(time, timeout, force);
47
+ return true;
48
+ }
49
+ this.setLight(newVal, timeout, force);
50
+ return newVal;
29
51
  }
30
- setTimeBased(time) {
31
- if ((time === time_callback_service_1.TimeOfDay.Night && this.settings.nightOn) ||
32
- (time === time_callback_service_1.TimeOfDay.BeforeSunrise && this.settings.dawnOn) ||
33
- (time === time_callback_service_1.TimeOfDay.AfterSunset && this.settings.duskOn)) {
34
- this.setLight(true);
52
+ setTimeBased(time, timeout = -1, force = false) {
53
+ if ((time === services_1.TimeOfDay.Night && this.settings.nightOn) ||
54
+ (time === services_1.TimeOfDay.BeforeSunrise && this.settings.dawnOn) ||
55
+ (time === services_1.TimeOfDay.AfterSunset && this.settings.duskOn)) {
56
+ this.setLight(true, timeout, force);
35
57
  }
36
58
  }
37
59
  }