hoffmation-base 3.0.0 → 3.0.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.
|
@@ -20,9 +20,13 @@ export declare class TemperatureSensor implements iJsonOmitKeys {
|
|
|
20
20
|
private readonly _persistTemperatureSensorInterval;
|
|
21
21
|
private _temperature;
|
|
22
22
|
private _temperaturCallbacks;
|
|
23
|
+
/**
|
|
24
|
+
* The last time the temperature sensor was seen.
|
|
25
|
+
*/
|
|
26
|
+
lastSeen: number;
|
|
23
27
|
constructor(_device: iTemperatureSensor);
|
|
24
|
-
set temperature(val: number);
|
|
25
28
|
get temperature(): number;
|
|
29
|
+
set temperature(val: number);
|
|
26
30
|
/**
|
|
27
31
|
* Persists the current temperature sensor information to the database
|
|
28
32
|
*/
|
|
@@ -27,8 +27,20 @@ class TemperatureSensor {
|
|
|
27
27
|
}, 5 * 60 * 1000, this, false);
|
|
28
28
|
this._temperature = baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
|
|
29
29
|
this._temperaturCallbacks = [];
|
|
30
|
+
/**
|
|
31
|
+
* The last time the temperature sensor was seen.
|
|
32
|
+
*/
|
|
33
|
+
this.lastSeen = 0;
|
|
34
|
+
}
|
|
35
|
+
get temperature() {
|
|
36
|
+
if (services_1.Utils.nowMS() - this.lastSeen > 60 * 60 * 1000) {
|
|
37
|
+
// Temperature sensor hasn't been seen in an hour --> Don't to trust it
|
|
38
|
+
return baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE;
|
|
39
|
+
}
|
|
40
|
+
return this._temperature;
|
|
30
41
|
}
|
|
31
42
|
set temperature(val) {
|
|
43
|
+
this.lastSeen = services_1.Utils.nowMS();
|
|
32
44
|
let correctedValue = val;
|
|
33
45
|
if (this.outdoorTemperatureCorrectionCoefficient !== 0 && services_1.WeatherService.currentTemp !== baseDeviceInterfaces_1.UNDEFINED_TEMP_VALUE) {
|
|
34
46
|
correctedValue = val + this.outdoorTemperatureCorrectionCoefficient * (21 - services_1.WeatherService.currentTemp);
|
|
@@ -38,9 +50,6 @@ class TemperatureSensor {
|
|
|
38
50
|
cb(new models_1.TemperatureSensorChangeAction(this._device, correctedValue));
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
|
-
get temperature() {
|
|
42
|
-
return this._temperature;
|
|
43
|
-
}
|
|
44
53
|
/**
|
|
45
54
|
* Persists the current temperature sensor information to the database
|
|
46
55
|
*/
|
|
@@ -40,12 +40,13 @@ class ZigbeeMotionSensor extends index_1.ZigbeeDevice {
|
|
|
40
40
|
}
|
|
41
41
|
/** @inheritDoc */
|
|
42
42
|
get movementDetected() {
|
|
43
|
-
if (!this.available) {
|
|
44
|
-
// If the device is not available, there is no active movement
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
if (!this.available || services_1.Utils.nowMS() - this.lastUpdate.getTime() > 3600000) {
|
|
44
|
+
// If the device is not available or has not been updated for more than an hour, there is no active movement
|
|
45
|
+
if (this._movementDetected) {
|
|
46
|
+
// The device must have gone offline whilst occupancy was detected -> reset
|
|
47
|
+
this.log(models_1.LogLevel.Error, 'Zigbee Motion Sensor went offline, resetting movement state');
|
|
48
|
+
this.updateMovement(false);
|
|
49
|
+
}
|
|
49
50
|
return false;
|
|
50
51
|
}
|
|
51
52
|
return this._movementDetected;
|