hoffmation-base 2.20.5 → 2.21.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.
@@ -1,6 +1,7 @@
1
1
  import { LogLevel } from './logLevel';
2
+ import { LogDebugType } from '../server';
2
3
  export interface iIdHolder {
3
4
  readonly id: string;
4
5
  readonly customName: string;
5
- log(level: LogLevel, message: string): void;
6
+ log(level: LogLevel, message: string, logDebugType?: LogDebugType): void;
6
7
  }
@@ -1,14 +1,20 @@
1
1
  import { ActuatorSettings } from '../../../models';
2
2
  import { iRoomDevice } from './iRoomDevice';
3
- export interface iActuator extends iRoomDevice {
3
+ import { iTemporaryDisableAutomatic } from './iTemporaryDisableAutomatic';
4
+ export interface iActuator extends iRoomDevice, iTemporaryDisableAutomatic {
4
5
  /**
5
6
  * The settings for this Actuator primarily for controlling its automatic actions
6
7
  */
7
8
  settings: ActuatorSettings;
9
+ targetAutomaticState: boolean;
8
10
  /**
9
11
  * The state value of the device
10
12
  */
11
13
  readonly actuatorOn: boolean;
14
+ /**
15
+ * Queued value for the actuator
16
+ */
17
+ queuedValue: boolean | null;
12
18
  /**
13
19
  * Persisting the current states of this device to the database
14
20
  */
@@ -6,8 +6,10 @@ import { iDachsSettings } from '../../config/iDachsSettings';
6
6
  import { DachsDeviceSettings } from '../../../models/deviceSettings/dachsSettings';
7
7
  import { iFlattenedCompleteResponse } from './interfaces';
8
8
  import { DachsTemperatureSensor } from './dachsTemperatureSensor';
9
+ import { BlockAutomaticHandler } from '../../services/blockAutomaticHandler';
9
10
  export declare class Dachs implements iBaseDevice, iActuator {
10
11
  settings: DachsDeviceSettings;
12
+ readonly blockAutomationHandler: BlockAutomaticHandler;
11
13
  readonly deviceType: DeviceType;
12
14
  readonly deviceCapabilities: DeviceCapability[];
13
15
  readonly warmWaterSensor: DachsTemperatureSensor;
@@ -15,15 +17,18 @@ export declare class Dachs implements iBaseDevice, iActuator {
15
17
  private readonly client;
16
18
  private readonly config;
17
19
  fetchedData: iFlattenedCompleteResponse | undefined;
20
+ queuedValue: boolean | null;
18
21
  private readonly _influxClient;
19
22
  private _dachsOn;
20
23
  private _tempWarmWater;
21
24
  private _tempHeatStorage;
25
+ targetAutomaticState: boolean;
22
26
  get customName(): string;
23
27
  get actuatorOn(): boolean;
24
28
  get tempWarmWater(): number;
25
29
  get tempHeatStorage(): number;
26
30
  constructor(options: iDachsSettings);
31
+ restoreTargetAutomaticValue(): void;
27
32
  protected _info: DeviceInfo;
28
33
  get info(): DeviceInfo;
29
34
  set info(info: DeviceInfo);
@@ -36,6 +41,6 @@ export declare class Dachs implements iBaseDevice, iActuator {
36
41
  loadDeviceSettings(): void;
37
42
  private loadData;
38
43
  persist(): void;
39
- setActuator(pValue: boolean, _timeout?: number, _force?: boolean): void;
44
+ setActuator(pValue: boolean, timeout?: number, force?: boolean): void;
40
45
  toggleActuator(_force: boolean): boolean;
41
46
  }
@@ -12,6 +12,7 @@ const lodash_1 = __importDefault(require("lodash"));
12
12
  const dachsSettings_1 = require("../../../models/deviceSettings/dachsSettings");
13
13
  const lib_1 = require("./lib");
14
14
  const dachsTemperatureSensor_1 = require("./dachsTemperatureSensor");
15
+ const blockAutomaticHandler_1 = require("../../services/blockAutomaticHandler");
15
16
  class Dachs {
16
17
  get customName() {
17
18
  return this.info.customName;
@@ -29,9 +30,11 @@ class Dachs {
29
30
  this.settings = new dachsSettings_1.DachsDeviceSettings();
30
31
  this.deviceType = devices_1.DeviceType.Dachs;
31
32
  this.deviceCapabilities = [];
33
+ this.queuedValue = null;
32
34
  this._dachsOn = false;
33
35
  this._tempWarmWater = 0;
34
36
  this._tempHeatStorage = 0;
37
+ this.targetAutomaticState = false;
35
38
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.actuator);
36
39
  this._info = new devices_1.DeviceInfo();
37
40
  this._info.fullName = `Dachs`;
@@ -53,6 +56,11 @@ class Dachs {
53
56
  this.warmWaterSensor = new dachsTemperatureSensor_1.DachsTemperatureSensor(this.config.roomName, 'ww', 'Water Temperature');
54
57
  this.heatStorageTempSensor = new dachsTemperatureSensor_1.DachsTemperatureSensor(this.config.roomName, 'hs', 'Heat Storage Temperature');
55
58
  services_1.Utils.guardedInterval(this.loadData, this.config.refreshInterval, this);
59
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
60
+ }
61
+ restoreTargetAutomaticValue() {
62
+ this.log(models_1.LogLevel.Debug, `Restore Target Automatic value`);
63
+ this.setActuator(this.targetAutomaticState);
56
64
  }
57
65
  get info() {
58
66
  return this._info;
@@ -93,6 +101,7 @@ class Dachs {
93
101
  loadData() {
94
102
  this.client.fetchAllKeys().then((data) => {
95
103
  var _a, _b;
104
+ this.queuedValue = null;
96
105
  this.fetchedData = data;
97
106
  if (this._influxClient === undefined) {
98
107
  return;
@@ -118,12 +127,17 @@ class Dachs {
118
127
  var _a;
119
128
  (_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistActuator(this);
120
129
  }
121
- setActuator(pValue, _timeout, _force) {
130
+ setActuator(pValue, timeout, force) {
122
131
  if (!pValue || this._dachsOn) {
123
132
  // Dachs can only be turned on, not off
124
133
  return;
125
134
  }
135
+ const dontBlock = devices_1.LampUtils.checkUnBlock(this, force, pValue);
136
+ if (devices_1.LampUtils.checkBlockActive(this, force, pValue)) {
137
+ return;
138
+ }
126
139
  this.log(models_1.LogLevel.Debug, `Starting Dachs`);
140
+ this.queuedValue = pValue;
127
141
  this.client
128
142
  .setKeys({
129
143
  'Stromf_Ew.Anforderung_GLT.bAktiv': '1',
@@ -145,6 +159,9 @@ class Dachs {
145
159
  .catch((error) => {
146
160
  this.log(models_1.LogLevel.Error, `Error while turning on Dachs: ${error}`);
147
161
  });
162
+ if (timeout !== undefined && timeout > -1 && !dontBlock) {
163
+ this.blockAutomationHandler.disableAutomatic(timeout, models_1.CollisionSolving.overrideIfGreater);
164
+ }
148
165
  }
149
166
  toggleActuator(_force) {
150
167
  if (!this._dachsOn) {
@@ -5,11 +5,11 @@ import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
5
5
  import { BlockAutomaticHandler } from '../../services/blockAutomaticHandler';
6
6
  export declare class HmIpLampe extends HmIPDevice implements iLamp, iTemporaryDisableAutomatic {
7
7
  lightOn: boolean;
8
- queuedLightValue: boolean | null;
9
8
  settings: ActuatorSettings;
10
9
  private lightOnSwitchID;
11
10
  readonly blockAutomationHandler: BlockAutomaticHandler;
12
- private _targetAutomaticState;
11
+ queuedValue: boolean | null;
12
+ targetAutomaticState: boolean;
13
13
  constructor(pInfo: IoBrokerDeviceInfo);
14
14
  get actuatorOn(): boolean;
15
15
  restoreTargetAutomaticValue(): void;
@@ -7,14 +7,15 @@ const services_1 = require("../../services");
7
7
  const models_1 = require("../../../models");
8
8
  const DeviceCapability_1 = require("../DeviceCapability");
9
9
  const blockAutomaticHandler_1 = require("../../services/blockAutomaticHandler");
10
+ const sharedFunctions_1 = require("../sharedFunctions");
10
11
  class HmIpLampe extends hmIpDevice_1.HmIPDevice {
11
12
  constructor(pInfo) {
12
13
  super(pInfo, deviceType_1.DeviceType.HmIpLampe);
13
14
  this.lightOn = false;
14
- this.queuedLightValue = null;
15
15
  this.settings = new models_1.ActuatorSettings();
16
16
  this.lightOnSwitchID = '';
17
- this._targetAutomaticState = false;
17
+ this.queuedValue = null;
18
+ this.targetAutomaticState = false;
18
19
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.lamp);
19
20
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.blockAutomatic);
20
21
  this.lightOnSwitchID = `${this.info.fullID}.2.STATE`;
@@ -25,12 +26,12 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
25
26
  }
26
27
  restoreTargetAutomaticValue() {
27
28
  this.log(models_1.LogLevel.Debug, `Restore Target Automatic value`);
28
- this.setActuator(this._targetAutomaticState);
29
+ this.setActuator(this.targetAutomaticState);
29
30
  }
30
31
  update(idSplit, state, initial = false) {
31
32
  this.log(models_1.LogLevel.DeepTrace, `Lampen Update : ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
33
+ this.queuedValue = null;
32
34
  super.update(idSplit, state, initial, true);
33
- this.queuedLightValue = null;
34
35
  switch (idSplit[3]) {
35
36
  case '1':
36
37
  if (idSplit[4] === 'STATE') {
@@ -48,13 +49,10 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
48
49
  }
49
50
  /** @inheritdoc */
50
51
  setLight(pValue, timeout = -1, force = false) {
51
- if (!force && this.blockAutomationHandler.automaticBlockActive) {
52
- this.log(models_1.LogLevel.Debug, `Skip automatic command to ${pValue} as it is locked until ${new Date(this.blockAutomationHandler.automaticBlockedUntil).toLocaleTimeString()}`);
53
- this._targetAutomaticState = pValue;
52
+ if (sharedFunctions_1.LampUtils.checkBlockActive(this, force, pValue)) {
54
53
  return;
55
54
  }
56
- if (!force && pValue === this.lightOn && this.queuedLightValue === null) {
57
- this.log(models_1.LogLevel.DeepTrace, `Skip light command as it is already ${pValue}`, services_1.LogDebugType.SkipUnchangedActuatorCommand);
55
+ if (sharedFunctions_1.LampUtils.checkUnchanged(this, force, pValue)) {
58
56
  return;
59
57
  }
60
58
  if (this.lightOnSwitchID === '') {
@@ -62,18 +60,13 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
62
60
  return;
63
61
  }
64
62
  this.log(models_1.LogLevel.Debug, `Set Light Acutator to "${pValue}"`, services_1.LogDebugType.SetActuator);
63
+ this.queuedValue = pValue;
65
64
  this.setState(this.lightOnSwitchID, pValue, undefined, (err) => {
66
65
  this.log(models_1.LogLevel.Error, `Lampe schalten ergab Fehler: ${err}`);
67
66
  });
68
- this.queuedLightValue = pValue;
69
- if (this.settings.isStromStoss) {
67
+ if (this.settings.isStromStoss && pValue) {
70
68
  timeout = 3000;
71
- services_1.Utils.guardedTimeout(() => {
72
- var _a;
73
- if ((_a = this.room.PraesenzGroup) === null || _a === void 0 ? void 0 : _a.anyPresent()) {
74
- this.setLight(true, -1, true);
75
- }
76
- }, this.settings.stromStossResendTime * 1000, this);
69
+ sharedFunctions_1.LampUtils.stromStossOn(this);
77
70
  }
78
71
  if (timeout < 0 || !pValue) {
79
72
  return;
@@ -83,24 +76,10 @@ class HmIpLampe extends hmIpDevice_1.HmIPDevice {
83
76
  }
84
77
  }
85
78
  toggleLight(time, force = false, calculateTime = false) {
86
- const newVal = this.queuedLightValue !== null ? !this.queuedLightValue : !this.lightOn;
87
- const timeout = newVal && force ? 30 * 60 * 1000 : -1;
88
- if (newVal && time === undefined && calculateTime) {
89
- time = services_1.TimeCallbackService.dayType(this.room.settings.lampOffset);
90
- }
91
- if (newVal && time !== undefined) {
92
- this.setTimeBased(time, timeout, force);
93
- return true;
94
- }
95
- this.setLight(newVal, timeout, force);
96
- return newVal;
79
+ return sharedFunctions_1.LampUtils.toggleLight(this, time, force, calculateTime);
97
80
  }
98
81
  setTimeBased(time, timeout = -1, force = false) {
99
- if ((time === models_1.TimeOfDay.Night && this.settings.nightOn) ||
100
- (time === models_1.TimeOfDay.BeforeSunrise && this.settings.dawnOn) ||
101
- (time === models_1.TimeOfDay.AfterSunset && this.settings.duskOn)) {
102
- this.setLight(true, timeout, force);
103
- }
82
+ sharedFunctions_1.LampUtils.setTimeBased(this, time, timeout, force);
104
83
  }
105
84
  persist() {
106
85
  var _a;
@@ -7,6 +7,7 @@ export * from './hmIPDevices/index';
7
7
  export * from './jsObject/index';
8
8
  export * from './models/index';
9
9
  export * from './scene/index';
10
+ export * from './sharedFunctions/index';
10
11
  export * from './shelly/index';
11
12
  export * from './tuya/index';
12
13
  export * from './zigbee/index';
@@ -23,6 +23,7 @@ __exportStar(require("./hmIPDevices/index"), exports);
23
23
  __exportStar(require("./jsObject/index"), exports);
24
24
  __exportStar(require("./models/index"), exports);
25
25
  __exportStar(require("./scene/index"), exports);
26
+ __exportStar(require("./sharedFunctions/index"), exports);
26
27
  __exportStar(require("./shelly/index"), exports);
27
28
  __exportStar(require("./tuya/index"), exports);
28
29
  __exportStar(require("./zigbee/index"), exports);
@@ -0,0 +1 @@
1
+ export * from './lampUtils';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lampUtils"), exports);
@@ -0,0 +1,10 @@
1
+ import { iActuator, iLamp } from '../baseDeviceInterfaces';
2
+ import { TimeOfDay } from '../../../models';
3
+ export declare class LampUtils {
4
+ static stromStossOn(lamp: iLamp): void;
5
+ static setTimeBased(device: iLamp, time: TimeOfDay, timeout: number, force: boolean): void;
6
+ static checkUnBlock(device: iActuator, force: boolean | undefined, pValue: boolean): boolean;
7
+ static toggleLight(device: iLamp, time: TimeOfDay | undefined, force: boolean, calculateTime: boolean): boolean;
8
+ static checkBlockActive(device: iActuator, force: boolean | undefined, pValue: boolean): boolean;
9
+ static checkUnchanged(device: iActuator, force: boolean, pValue: boolean): boolean;
10
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LampUtils = void 0;
4
+ const services_1 = require("../../services");
5
+ const models_1 = require("../../../models");
6
+ class LampUtils {
7
+ static stromStossOn(lamp) {
8
+ services_1.Utils.guardedTimeout(() => {
9
+ var _a, _b;
10
+ if ((_b = (_a = lamp.room) === null || _a === void 0 ? void 0 : _a.PraesenzGroup) === null || _b === void 0 ? void 0 : _b.anyPresent()) {
11
+ lamp.setLight(true, -1, true);
12
+ }
13
+ }, lamp.settings.stromStossResendTime * 1000, this);
14
+ services_1.Utils.guardedTimeout(() => {
15
+ lamp.setLight(false, -1, true);
16
+ }, 3000, this);
17
+ }
18
+ static setTimeBased(device, time, timeout, force) {
19
+ if ((time === models_1.TimeOfDay.Night && device.settings.nightOn) ||
20
+ (time === models_1.TimeOfDay.BeforeSunrise && device.settings.dawnOn) ||
21
+ (time === models_1.TimeOfDay.AfterSunset && device.settings.duskOn)) {
22
+ device.setLight(true, timeout, force);
23
+ }
24
+ }
25
+ static checkUnBlock(device, force, pValue) {
26
+ let dontBlock = false;
27
+ if (force &&
28
+ device.settings.resetToAutomaticOnForceOffAfterForceOn &&
29
+ !pValue &&
30
+ device.blockAutomationHandler.automaticBlockActive) {
31
+ dontBlock = true;
32
+ device.log(models_1.LogLevel.Debug, `Reset Automatic Block as we are turning off manually after a force on`);
33
+ device.blockAutomationHandler.liftAutomaticBlock();
34
+ }
35
+ return dontBlock;
36
+ }
37
+ static toggleLight(device, time, force, calculateTime) {
38
+ var _a;
39
+ const newVal = device.queuedValue !== null ? !device.queuedValue : !device.lightOn;
40
+ const timeout = newVal && force ? 30 * 60 * 1000 : -1;
41
+ if (newVal && time === undefined && calculateTime && device.room !== undefined) {
42
+ time = services_1.TimeCallbackService.dayType((_a = device.room) === null || _a === void 0 ? void 0 : _a.settings.lampOffset);
43
+ }
44
+ if (newVal && time !== undefined) {
45
+ device.setTimeBased(time, timeout, force);
46
+ return true;
47
+ }
48
+ device.setLight(newVal, timeout, force);
49
+ return newVal;
50
+ }
51
+ static checkBlockActive(device, force, pValue) {
52
+ if (!force && device.blockAutomationHandler.automaticBlockActive) {
53
+ device.log(models_1.LogLevel.Debug, `Skip automatic command to ${pValue} as it is locked until ${new Date(device.blockAutomationHandler.automaticBlockedUntil).toLocaleTimeString()}`);
54
+ device.targetAutomaticState = pValue;
55
+ return true;
56
+ }
57
+ return false;
58
+ }
59
+ static checkUnchanged(device, force, pValue) {
60
+ if (!force && pValue === device.actuatorOn && device.queuedValue === null) {
61
+ device.log(models_1.LogLevel.DeepTrace, `Skip light command as it is already ${pValue}`, services_1.LogDebugType.SkipUnchangedActuatorCommand);
62
+ return true;
63
+ }
64
+ return false;
65
+ }
66
+ }
67
+ exports.LampUtils = LampUtils;
@@ -2,25 +2,28 @@ import { IoBrokerBaseDevice } from './IoBrokerBaseDevice';
2
2
  import { TimeOfDay, WledSettings } from '../../models';
3
3
  import { IoBrokerDeviceInfo } from './IoBrokerDeviceInfo';
4
4
  import { iDimmableLamp } from './baseDeviceInterfaces/iDimmableLamp';
5
+ import { BlockAutomaticHandler } from '../services/blockAutomaticHandler';
5
6
  export declare class WledDevice extends IoBrokerBaseDevice implements iDimmableLamp {
6
7
  on: boolean;
7
8
  brightness: number;
8
- linkQuality: number;
9
9
  battery: number;
10
- voltage: string;
10
+ queuedValue: boolean | null;
11
11
  settings: WledSettings;
12
+ readonly blockAutomationHandler: BlockAutomaticHandler;
13
+ targetAutomaticState: boolean;
12
14
  private readonly _onID;
13
15
  private readonly _presetID;
14
16
  private readonly _brightnessID;
15
17
  constructor(pInfo: IoBrokerDeviceInfo);
16
18
  get actuatorOn(): boolean;
17
19
  get lightOn(): boolean;
20
+ restoreTargetAutomaticValue(): void;
18
21
  update(idSplit: string[], state: ioBroker.State, initial?: boolean, _pOverride?: boolean): void;
19
- setLight(pValue: boolean, _timeout?: number, _force?: boolean, brightness?: number, _transitionTime?: number): void;
20
- setWled(pValue: boolean, brightness?: number, preset?: number): void;
22
+ setLight(pValue: boolean, timeout?: number, force?: boolean, brightness?: number, _transitionTime?: number): void;
23
+ setWled(pValue: boolean, brightness?: number, preset?: number, timeout?: number, force?: boolean): void;
21
24
  setTimeBased(time: TimeOfDay): void;
22
25
  persist(): void;
23
26
  setActuator(pValue: boolean, _timeout?: number, _force?: boolean): void;
24
27
  toggleActuator(_force: boolean): boolean;
25
- toggleLight(time?: TimeOfDay, _force?: boolean, calculateTime?: boolean): boolean;
28
+ toggleLight(time?: TimeOfDay, force?: boolean, calculateTime?: boolean): boolean;
26
29
  }
@@ -5,18 +5,21 @@ const IoBrokerBaseDevice_1 = require("./IoBrokerBaseDevice");
5
5
  const deviceType_1 = require("./deviceType");
6
6
  const services_1 = require("../services");
7
7
  const models_1 = require("../../models");
8
+ const blockAutomaticHandler_1 = require("../services/blockAutomaticHandler");
9
+ const sharedFunctions_1 = require("./sharedFunctions");
8
10
  class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
9
11
  constructor(pInfo) {
10
12
  super(pInfo, deviceType_1.DeviceType.WledDevice);
11
13
  this.on = false;
12
14
  this.brightness = -1;
13
- this.linkQuality = 0;
14
15
  this.battery = -1;
15
- this.voltage = '';
16
+ this.queuedValue = null;
16
17
  this.settings = new models_1.WledSettings();
18
+ this.targetAutomaticState = false;
17
19
  this._onID = `${this.info.fullID}.on`;
18
20
  this._presetID = `${this.info.fullID}.ps`;
19
21
  this._brightnessID = `${this.info.fullID}.bri`;
22
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
20
23
  }
21
24
  get actuatorOn() {
22
25
  return this.on;
@@ -24,7 +27,12 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
24
27
  get lightOn() {
25
28
  return this.on;
26
29
  }
30
+ restoreTargetAutomaticValue() {
31
+ this.log(models_1.LogLevel.Debug, `Restore Target Automatic value`);
32
+ this.setActuator(this.targetAutomaticState);
33
+ }
27
34
  update(idSplit, state, initial = false, _pOverride = false) {
35
+ this.queuedValue = null;
28
36
  services_1.ServerLogService.writeLog(models_1.LogLevel.DeepTrace, `Wled: ${initial ? 'Initiales ' : ''}Update für "${this.info.customName}": ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
29
37
  switch (idSplit[3]) {
30
38
  case 'on':
@@ -35,10 +43,10 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
35
43
  break;
36
44
  }
37
45
  }
38
- setLight(pValue, _timeout, _force, brightness, _transitionTime) {
39
- this.setWled(pValue, brightness);
46
+ setLight(pValue, timeout, force, brightness, _transitionTime) {
47
+ this.setWled(pValue, brightness, undefined, timeout, force);
40
48
  }
41
- setWled(pValue, brightness = -1, preset) {
49
+ setWled(pValue, brightness = -1, preset, timeout, force) {
42
50
  if (this._onID === '') {
43
51
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `Keine On ID für "${this.info.customName}" bekannt.`);
44
52
  return;
@@ -47,10 +55,15 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
47
55
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `Keine Connection für "${this.info.customName}" bekannt.`);
48
56
  return;
49
57
  }
58
+ const dontBlock = sharedFunctions_1.LampUtils.checkUnBlock(this, force, pValue);
59
+ if (sharedFunctions_1.LampUtils.checkBlockActive(this, force, pValue)) {
60
+ return;
61
+ }
50
62
  if (pValue && brightness !== -1 && this.brightness < 10) {
51
63
  brightness = 10;
52
64
  }
53
65
  services_1.ServerLogService.writeLog(models_1.LogLevel.Debug, `WLED Schalten: "${this.info.customName}" An: ${pValue}\tHelligkeit: ${brightness}%`);
66
+ this.queuedValue = pValue;
54
67
  this.setState(this._onID, pValue, undefined, (err) => {
55
68
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `WLED schalten ergab Fehler: ${err}`);
56
69
  });
@@ -64,6 +77,9 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
64
77
  services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `Dimmer Helligkeit schalten ergab Fehler: ${err}`);
65
78
  });
66
79
  }
80
+ if (timeout !== undefined && timeout > -1 && !dontBlock) {
81
+ this.blockAutomationHandler.disableAutomatic(timeout, models_1.CollisionSolving.overrideIfGreater);
82
+ }
67
83
  }
68
84
  setTimeBased(time) {
69
85
  this.log(models_1.LogLevel.Debug, `Wled setTimeBased ${time}`);
@@ -101,17 +117,8 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
101
117
  this.setLight(!this.on);
102
118
  return this.on;
103
119
  }
104
- toggleLight(time, _force = false, calculateTime = false) {
105
- const newVal = !this.lightOn;
106
- if (newVal && time === undefined && calculateTime) {
107
- time = services_1.TimeCallbackService.dayType(this.room.settings.lampOffset);
108
- }
109
- if (newVal && time !== undefined) {
110
- this.setTimeBased(time);
111
- return true;
112
- }
113
- this.setLight(newVal);
114
- return newVal;
120
+ toggleLight(time, force = false, calculateTime = false) {
121
+ return sharedFunctions_1.LampUtils.toggleLight(this, time, force, calculateTime);
115
122
  }
116
123
  }
117
124
  exports.WledDevice = WledDevice;
@@ -1,16 +1,16 @@
1
1
  import { ActuatorSettings } from '../../../../models';
2
2
  import { DeviceType } from '../../deviceType';
3
3
  import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
4
- import { iActuator, iTemporaryDisableAutomatic } from '../../baseDeviceInterfaces';
4
+ import { iActuator } from '../../baseDeviceInterfaces';
5
5
  import { ZigbeeDevice } from './zigbeeDevice';
6
6
  import { BlockAutomaticHandler } from '../../../services/blockAutomaticHandler';
7
- export declare class ZigbeeActuator extends ZigbeeDevice implements iActuator, iTemporaryDisableAutomatic {
7
+ export declare class ZigbeeActuator extends ZigbeeDevice implements iActuator {
8
8
  private _actuatorOn;
9
9
  readonly blockAutomationHandler: BlockAutomaticHandler;
10
- private _targetAutomaticState;
10
+ targetAutomaticState: boolean;
11
11
  settings: ActuatorSettings;
12
12
  protected readonly actuatorOnSwitchID: string;
13
- protected queuedValue: boolean | null;
13
+ queuedValue: boolean | null;
14
14
  get actuatorOn(): boolean;
15
15
  constructor(pInfo: IoBrokerDeviceInfo, type: DeviceType, actuatorOnSwitchID: string);
16
16
  restoreTargetAutomaticValue(): void;
@@ -6,6 +6,7 @@ const models_1 = require("../../../../models");
6
6
  const zigbeeDevice_1 = require("./zigbeeDevice");
7
7
  const DeviceCapability_1 = require("../../DeviceCapability");
8
8
  const blockAutomaticHandler_1 = require("../../../services/blockAutomaticHandler");
9
+ const sharedFunctions_1 = require("../../sharedFunctions");
9
10
  class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
10
11
  get actuatorOn() {
11
12
  return this._actuatorOn;
@@ -13,7 +14,7 @@ class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
13
14
  constructor(pInfo, type, actuatorOnSwitchID) {
14
15
  super(pInfo, type);
15
16
  this._actuatorOn = false;
16
- this._targetAutomaticState = false;
17
+ this.targetAutomaticState = false;
17
18
  this.settings = new models_1.ActuatorSettings();
18
19
  this.queuedValue = null;
19
20
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.actuator);
@@ -23,7 +24,7 @@ class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
23
24
  }
24
25
  restoreTargetAutomaticValue() {
25
26
  this.log(models_1.LogLevel.Debug, `Restore Target Automatic value`);
26
- this.setActuator(this._targetAutomaticState);
27
+ this.setActuator(this.targetAutomaticState);
27
28
  }
28
29
  update(idSplit, state, initial = false, handledByChildObject = false) {
29
30
  if (!handledByChildObject) {
@@ -46,22 +47,11 @@ class ZigbeeActuator extends zigbeeDevice_1.ZigbeeDevice {
46
47
  this.log(models_1.LogLevel.Error, `Keine Switch ID bekannt.`);
47
48
  return;
48
49
  }
49
- let dontBlock = false;
50
- if (force &&
51
- this.settings.resetToAutomaticOnForceOffAfterForceOn &&
52
- !pValue &&
53
- this.blockAutomationHandler.automaticBlockActive) {
54
- dontBlock = true;
55
- this.log(models_1.LogLevel.Debug, `Reset Automatic Block as we are turning off manually after a force on`);
56
- this.blockAutomationHandler.liftAutomaticBlock();
57
- }
58
- if (!force && this.blockAutomationHandler.automaticBlockActive) {
59
- this.log(models_1.LogLevel.Debug, `Skip automatic command to ${pValue} as it is locked until ${new Date(this.blockAutomationHandler.automaticBlockedUntil).toLocaleTimeString()}`);
60
- this._targetAutomaticState = pValue;
50
+ const dontBlock = sharedFunctions_1.LampUtils.checkUnBlock(this, force, pValue);
51
+ if (sharedFunctions_1.LampUtils.checkBlockActive(this, force, pValue)) {
61
52
  return;
62
53
  }
63
- if (!force && pValue === this._actuatorOn && this.queuedValue === null) {
64
- this.log(models_1.LogLevel.Debug, `Skip actuator command as it is already ${pValue}`, services_1.LogDebugType.SkipUnchangedActuatorCommand);
54
+ if (sharedFunctions_1.LampUtils.checkUnchanged(this, force, pValue)) {
65
55
  return;
66
56
  }
67
57
  this.log(models_1.LogLevel.Debug, `Set Acutator to "${pValue}"`, services_1.LogDebugType.SetActuator);
@@ -9,22 +9,22 @@ export declare abstract class ZigbeeDimmer extends ZigbeeDevice implements iDimm
9
9
  readonly blockAutomationHandler: BlockAutomaticHandler;
10
10
  queuedValue: boolean | null;
11
11
  settings: DimmerSettings;
12
- protected _brightness: number;
12
+ targetAutomaticState: boolean;
13
13
  protected _lastPersist: number;
14
- protected _lightOn: boolean;
15
- protected _transitionTime: number;
16
- protected _targetAutomaticState: boolean;
17
14
  protected abstract readonly _stateIdBrightness: string;
18
15
  protected abstract readonly _stateIdState: string;
19
16
  protected abstract readonly _stateIdTransitionTime: string;
20
17
  protected abstract readonly _stateNameBrightness: string;
21
18
  protected abstract readonly _stateNameState: string;
22
19
  protected abstract readonly _stateNameTransitionTime: string;
23
- get lightOn(): boolean;
20
+ protected constructor(pInfo: IoBrokerDeviceInfo, deviceType: DeviceType);
21
+ protected _brightness: number;
24
22
  get brightness(): number;
23
+ protected _lightOn: boolean;
24
+ get lightOn(): boolean;
25
+ protected _transitionTime: number;
25
26
  get transitionTime(): number;
26
27
  get actuatorOn(): boolean;
27
- protected constructor(pInfo: IoBrokerDeviceInfo, deviceType: DeviceType);
28
28
  restoreTargetAutomaticValue(): void;
29
29
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
30
30
  setTimeBased(time: TimeOfDay, timeout?: number, force?: boolean): void;