hoffmation-base 2.10.1 → 2.10.2

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,19 +1,20 @@
1
- /// <reference types="node" />
2
1
  /// <reference types="iobroker" />
3
2
  import { DimmerSettings, TimeOfDay } from '../../../../models';
4
3
  import { DeviceType } from '../../deviceType';
5
4
  import { ZigbeeDevice } from './index';
6
5
  import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
7
6
  import { iDimmableLamp } from '../../baseDeviceInterfaces/iDimmableLamp';
8
- export declare abstract class ZigbeeDimmer extends ZigbeeDevice implements iDimmableLamp {
7
+ import { iTemporaryDisableAutomatic } from '../../baseDeviceInterfaces';
8
+ import { BlockAutomaticHandler } from '../../../services/blockAutomaticHandler';
9
+ export declare abstract class ZigbeeDimmer extends ZigbeeDevice implements iDimmableLamp, iTemporaryDisableAutomatic {
10
+ readonly blockAutomationHandler: BlockAutomaticHandler;
9
11
  queuedValue: boolean | null;
10
12
  settings: DimmerSettings;
11
13
  protected _brightness: number;
12
14
  protected _lastPersist: number;
13
15
  protected _lightOn: boolean;
14
16
  protected _transitionTime: number;
15
- protected _turnOffTime: number;
16
- protected _turnOffTimeout: NodeJS.Timeout | undefined;
17
+ protected _targetAutomaticState: boolean;
17
18
  protected abstract readonly _stateIdBrightness: string;
18
19
  protected abstract readonly _stateIdState: string;
19
20
  protected abstract readonly _stateIdTransitionTime: string;
@@ -25,6 +26,7 @@ export declare abstract class ZigbeeDimmer extends ZigbeeDevice implements iDimm
25
26
  get transitionTime(): number;
26
27
  get actuatorOn(): boolean;
27
28
  protected constructor(pInfo: IoBrokerDeviceInfo, deviceType: DeviceType);
29
+ restoreTargetAutomaticValue(): void;
28
30
  update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
29
31
  setTimeBased(time: TimeOfDay, timeout?: number, force?: boolean): void;
30
32
  setActuator(pValue: boolean, timeout?: number, force?: boolean): void;
@@ -5,6 +5,7 @@ const models_1 = require("../../../../models");
5
5
  const services_1 = require("../../../services");
6
6
  const index_1 = require("./index");
7
7
  const DeviceCapability_1 = require("../../DeviceCapability");
8
+ const blockAutomaticHandler_1 = require("../../../services/blockAutomaticHandler");
8
9
  class ZigbeeDimmer extends index_1.ZigbeeDevice {
9
10
  get lightOn() {
10
11
  return this._lightOn;
@@ -26,10 +27,15 @@ class ZigbeeDimmer extends index_1.ZigbeeDevice {
26
27
  this._lastPersist = 0;
27
28
  this._lightOn = false;
28
29
  this._transitionTime = 0;
29
- this._turnOffTime = 0;
30
- this._turnOffTimeout = undefined;
30
+ this._targetAutomaticState = false;
31
31
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.lamp);
32
32
  this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.dimmablelamp);
33
+ this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.blockAutomatic);
34
+ this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this));
35
+ }
36
+ restoreTargetAutomaticValue() {
37
+ this.log(models_1.LogLevel.Debug, `Restore Target Automatic value`);
38
+ this.setActuator(this._targetAutomaticState);
33
39
  }
34
40
  update(idSplit, state, initial = false) {
35
41
  this.queuedValue = null;
@@ -98,8 +104,9 @@ class ZigbeeDimmer extends index_1.ZigbeeDevice {
98
104
  }
99
105
  });
100
106
  }
101
- if (!force && services_1.Utils.nowMS() < this._turnOffTime) {
102
- this.log(models_1.LogLevel.Debug, `Skip automatic command to ${pValue} as it is locked until ${new Date(this._turnOffTime).toLocaleTimeString()}`);
107
+ if (!force && this.blockAutomationHandler.automaticBlockActive) {
108
+ this.log(models_1.LogLevel.Debug, `Skip automatic command to ${pValue} as it is locked until ${new Date(this.blockAutomationHandler.automaticBlockedUntil).toLocaleTimeString()}`);
109
+ this._targetAutomaticState = pValue;
103
110
  return;
104
111
  }
105
112
  if (pValue && brightness === -1 && this.brightness < 10) {
@@ -121,24 +128,9 @@ class ZigbeeDimmer extends index_1.ZigbeeDevice {
121
128
  this.setState(this._stateIdBrightness, brightness);
122
129
  }
123
130
  }
124
- if (this._turnOffTimeout !== undefined) {
125
- clearTimeout(this._turnOffTimeout);
126
- this._turnOffTimeout = undefined;
127
- }
128
- if (timeout < 0 || !pValue) {
129
- return;
131
+ if (timeout > -1) {
132
+ this.blockAutomationHandler.disableAutomatic(timeout, models_1.CollisionSolving.overrideIfGreater);
130
133
  }
131
- this._turnOffTime = services_1.Utils.nowMS() + timeout;
132
- this._turnOffTimeout = services_1.Utils.guardedTimeout(() => {
133
- this.log(models_1.LogLevel.Debug, `Delayed Turnoff initiated`);
134
- this._turnOffTimeout = undefined;
135
- if (!this.room) {
136
- this.setLight(false, -1, true);
137
- }
138
- else {
139
- this.room.setLightTimeBased(true);
140
- }
141
- }, timeout, this);
142
134
  }
143
135
  persist() {
144
136
  var _a;