hoffmation-base 3.3.1 → 3.3.3
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.
- package/lib/devices/zigbee/BaseDevices/zigbeeMotionSensor.d.ts +1 -1
- package/lib/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +8 -6
- package/lib/models/timeCallback.d.ts +1 -0
- package/lib/models/timeCallback.js +7 -0
- package/lib/services/RoomBase.d.ts +3 -2
- package/lib/services/RoomBase.js +15 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ export declare class ZigbeeMotionSensor extends ZigbeeDevice implements iMotionS
|
|
|
16
16
|
protected _movementDetectedCallback: Array<(action: MotionSensorAction) => void>;
|
|
17
17
|
protected _needsMovementResetFallback: boolean;
|
|
18
18
|
protected _fallBackTimeout: NodeJS.Timeout | undefined;
|
|
19
|
-
protected
|
|
19
|
+
protected _motionDetectedTimestamp: number;
|
|
20
20
|
protected readonly _occupancyStateId: string;
|
|
21
21
|
private _movementDetected;
|
|
22
22
|
constructor(pInfo: IoBrokerDeviceInfo, type: DeviceType);
|
|
@@ -20,7 +20,7 @@ class ZigbeeMotionSensor extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
20
20
|
this._initialized = false;
|
|
21
21
|
this._movementDetectedCallback = [];
|
|
22
22
|
this._needsMovementResetFallback = true;
|
|
23
|
-
this.
|
|
23
|
+
this._motionDetectedTimestamp = 0;
|
|
24
24
|
this._occupancyStateId = 'occupancy';
|
|
25
25
|
this._movementDetected = false;
|
|
26
26
|
this.deviceCapabilities.push(enums_1.DeviceCapability.motionSensor);
|
|
@@ -60,7 +60,10 @@ class ZigbeeMotionSensor extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
60
60
|
// Time since last motion in seconds
|
|
61
61
|
/** @inheritDoc */
|
|
62
62
|
get timeSinceLastMotion() {
|
|
63
|
-
|
|
63
|
+
if (this._motionDetectedTimestamp === 0) {
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
return (utils_1.Utils.nowMS() - this._motionDetectedTimestamp) / 1000;
|
|
64
67
|
}
|
|
65
68
|
/**
|
|
66
69
|
* Adds a callback for when a motion state has changed.
|
|
@@ -83,6 +86,9 @@ class ZigbeeMotionSensor extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
83
86
|
}, 1000, this);
|
|
84
87
|
return;
|
|
85
88
|
}
|
|
89
|
+
else if (newState) {
|
|
90
|
+
this._motionDetectedTimestamp = utils_1.Utils.nowMS();
|
|
91
|
+
}
|
|
86
92
|
if (newState === this._movementDetected) {
|
|
87
93
|
this.log(enums_1.LogLevel.Debug, `Skip movement because state is already ${newState}`, enums_1.LogDebugType.SkipUnchangedMovementState);
|
|
88
94
|
if (newState) {
|
|
@@ -120,10 +126,6 @@ class ZigbeeMotionSensor extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
120
126
|
this.log(enums_1.LogLevel.Trace, `Motion sensor: Update for motion state of ${this.info.customName}: ${state.val}`);
|
|
121
127
|
this.updateMovement(state.val);
|
|
122
128
|
break;
|
|
123
|
-
case 'no_motion':
|
|
124
|
-
this.log(state.val < 100 ? enums_1.LogLevel.Trace : enums_1.LogLevel.DeepTrace, `Motion sensor: Update for time since last motion of ${this.info.customName}: ${state.val}`);
|
|
125
|
-
this._timeSinceLastMotion = state.val;
|
|
126
|
-
break;
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
resetFallbackTimeout() {
|
|
@@ -25,4 +25,5 @@ export declare class TimeCallback implements ITimeCallback {
|
|
|
25
25
|
constructor(name: string, type: TimeCallbackType, cFunction: () => void, minuteOffset: number, hours?: number | undefined, minutes?: number | undefined, sunTimeOffset?: SunTimeOffsets | undefined, cloudOffset?: number | undefined);
|
|
26
26
|
recalcNextToDo(now: Date): void;
|
|
27
27
|
perform(now?: Date): void;
|
|
28
|
+
toJSON(): Partial<TimeCallback>;
|
|
28
29
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.TimeCallback = void 0;
|
|
4
7
|
const enums_1 = require("../enums");
|
|
5
8
|
const services_1 = require("../services");
|
|
6
9
|
const utils_1 = require("../utils");
|
|
7
10
|
const logging_1 = require("../logging");
|
|
11
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
12
|
class TimeCallback {
|
|
9
13
|
get calculationSunrise() {
|
|
10
14
|
var _a;
|
|
@@ -112,5 +116,8 @@ class TimeCallback {
|
|
|
112
116
|
this._calculationSunset = undefined;
|
|
113
117
|
this.cFunction();
|
|
114
118
|
}
|
|
119
|
+
toJSON() {
|
|
120
|
+
return utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['cFunction']));
|
|
121
|
+
}
|
|
115
122
|
}
|
|
116
123
|
exports.TimeCallback = TimeCallback;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseGroup, DeviceCluster, HeatGroup, TasterGroup, WaterGroup } from '../devices';
|
|
2
2
|
import { RoomSetLightTimeBasedCommand } from '../command';
|
|
3
|
-
import { iIdHolder, iLightGroup, iPresenceGroup, iRoomBase, iSmokeGroup, iSpeakerGroup, ITimeCallback, iTrilaterationPoint, iWindowGroup } from '../interfaces';
|
|
3
|
+
import { iIdHolder, iJsonCustomPrepend, iLightGroup, iPresenceGroup, iRoomBase, iSmokeGroup, iSpeakerGroup, ITimeCallback, iTrilaterationPoint, iWindowGroup } from '../interfaces';
|
|
4
4
|
import { GroupType, LogLevel } from '../enums';
|
|
5
5
|
import { RoomInfo, RoomSettingsController } from '../models';
|
|
6
|
-
export declare class RoomBase implements iRoomBase, iIdHolder {
|
|
6
|
+
export declare class RoomBase implements iRoomBase, iIdHolder, iJsonCustomPrepend {
|
|
7
7
|
groupMap: Map<GroupType, BaseGroup>;
|
|
8
8
|
startPoint?: iTrilaterationPoint | undefined;
|
|
9
9
|
endPoint?: iTrilaterationPoint | undefined;
|
|
@@ -49,6 +49,7 @@ export declare class RoomBase implements iRoomBase, iIdHolder {
|
|
|
49
49
|
*/
|
|
50
50
|
setLightTimeBased(c: RoomSetLightTimeBasedCommand): void;
|
|
51
51
|
isNowLightTime(): boolean;
|
|
52
|
+
customPrepend(): Partial<unknown>;
|
|
52
53
|
toJSON(): Partial<iRoomBase & {
|
|
53
54
|
/**
|
|
54
55
|
* The dictionary representation of the group map
|
package/lib/services/RoomBase.js
CHANGED
|
@@ -164,8 +164,22 @@ class RoomBase {
|
|
|
164
164
|
}
|
|
165
165
|
return time_callback_service_1.TimeCallbackService.darkOutsideOrNight(timeOfDay);
|
|
166
166
|
}
|
|
167
|
+
customPrepend() {
|
|
168
|
+
return {
|
|
169
|
+
sunriseShutterCallback: this.sunriseShutterCallback,
|
|
170
|
+
sunsetShutterCallback: this.sunsetShutterCallback,
|
|
171
|
+
sonnenUntergangLichtCallback: this.sonnenUntergangLichtCallback,
|
|
172
|
+
sonnenAufgangLichtCallback: this.sonnenAufgangLichtCallback,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
167
175
|
toJSON() {
|
|
168
|
-
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
177
|
+
const result = utils_1.Utils.jsonFilter(lodash_1.default.omit(this, ['_deviceCluster']));
|
|
178
|
+
result['sunriseShutterCallback'] = this.sunriseShutterCallback;
|
|
179
|
+
result['sunsetShutterCallback'] = this.sunsetShutterCallback;
|
|
180
|
+
result['sonnenUntergangLichtCallback'] = this.sonnenUntergangLichtCallback;
|
|
181
|
+
result['sonnenAufgangLichtCallback'] = this.sonnenAufgangLichtCallback;
|
|
182
|
+
return result;
|
|
169
183
|
}
|
|
170
184
|
log(level, message) {
|
|
171
185
|
logging_1.ServerLogService.writeLog(level, message, {
|