hoffmation-base 1.1.2 → 1.1.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/models/deviceSettings/wledSettings.d.ts +2 -2
- package/lib/models/deviceSettings/wledSettings.js +2 -2
- package/lib/server/devices/baseDeviceInterfaces/iButtonSwitch.d.ts +2 -1
- package/lib/server/devices/baseDeviceInterfaces/iShutter.d.ts +1 -0
- package/lib/server/devices/groups/lampenGroup.js +1 -1
- package/lib/server/devices/hmIPDevices/hmIpRoll.d.ts +1 -0
- package/lib/server/devices/hmIPDevices/hmIpRoll.js +5 -0
- package/lib/server/devices/hmIPDevices/hmIpTaster.d.ts +2 -1
- package/lib/server/devices/hmIPDevices/hmIpTaster.js +19 -7
- package/lib/server/devices/hmIPDevices/hmIpWippe.d.ts +2 -1
- package/lib/server/devices/hmIPDevices/hmIpWippe.js +14 -4
- package/lib/server/devices/wledDevice.d.ts +10 -2
- package/lib/server/devices/wledDevice.js +38 -5
- package/lib/server/devices/zigbee/BaseDevices/zigbeeShutter.d.ts +1 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeShutter.js +5 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeSwitch.d.ts +2 -1
- package/lib/server/devices/zigbee/BaseDevices/zigbeeSwitch.js +5 -0
- package/lib/server/devices/zigbee/zigbeeAqaraOpple3Switch.js +17 -11
- package/lib/server/services/dbo/iPersist.d.ts +3 -1
- package/lib/server/services/dbo/postgreSqlPersist.d.ts +3 -1
- package/lib/server/services/dbo/postgreSqlPersist.js +48 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class WledSettings extends
|
|
1
|
+
import { DimmerSettings } from './dimmerSettings';
|
|
2
|
+
export declare class WledSettings extends DimmerSettings {
|
|
3
3
|
dayOn: boolean;
|
|
4
4
|
dayBrightness: number;
|
|
5
5
|
dawnOn: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WledSettings = void 0;
|
|
4
|
-
const
|
|
5
|
-
class WledSettings extends
|
|
4
|
+
const dimmerSettings_1 = require("./dimmerSettings");
|
|
5
|
+
class WledSettings extends dimmerSettings_1.DimmerSettings {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
8
|
this.dayOn = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button } from '../button';
|
|
1
|
+
import { Button, ButtonPressType } from '../button';
|
|
2
2
|
import { iRoomDevice } from './iRoomDevice';
|
|
3
3
|
export interface iButtonSwitch extends iRoomDevice {
|
|
4
4
|
buttonTopLeft: Button | undefined;
|
|
@@ -9,5 +9,6 @@ export interface iButtonSwitch extends iRoomDevice {
|
|
|
9
9
|
buttonBotRight: Button | undefined;
|
|
10
10
|
buttonBot: Button | undefined;
|
|
11
11
|
buttonTop: Button | undefined;
|
|
12
|
+
persist(buttonName: string, pressType: ButtonPressType): void;
|
|
12
13
|
getButtonAssignment(): string;
|
|
13
14
|
}
|
|
@@ -17,6 +17,7 @@ export declare class HmIpRoll extends HmIPDevice implements iShutter {
|
|
|
17
17
|
get fenster(): Fenster | undefined;
|
|
18
18
|
set fenster(value: Fenster | undefined);
|
|
19
19
|
get desiredFensterLevel(): number;
|
|
20
|
+
persist(): void;
|
|
20
21
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
21
22
|
setLevel(pPosition: number, initial?: boolean, skipOpenWarning?: boolean): void;
|
|
22
23
|
toJSON(): Partial<IoBrokerBaseDevice>;
|
|
@@ -36,6 +36,7 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
|
|
|
36
36
|
var _a;
|
|
37
37
|
(_a = this._fenster) === null || _a === void 0 ? void 0 : _a.rolloPositionChange(value);
|
|
38
38
|
}, this);
|
|
39
|
+
this.persist();
|
|
39
40
|
}
|
|
40
41
|
this._currentLevel = value;
|
|
41
42
|
}
|
|
@@ -51,6 +52,10 @@ class HmIpRoll extends hmIpDevice_1.HmIPDevice {
|
|
|
51
52
|
}
|
|
52
53
|
return this._fenster.desiredPosition;
|
|
53
54
|
}
|
|
55
|
+
persist() {
|
|
56
|
+
var _a;
|
|
57
|
+
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistShutter(this);
|
|
58
|
+
}
|
|
54
59
|
update(idSplit, state, initial = false) {
|
|
55
60
|
this.log(models_2.LogLevel.DeepTrace, `Rollo Update : ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
|
|
56
61
|
super.update(idSplit, state, initial, true);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="iobroker" />
|
|
2
2
|
import { HmIPDevice } from './hmIpDevice';
|
|
3
3
|
import { iBatteryDevice, iButtonSwitch } from '../baseDeviceInterfaces';
|
|
4
|
-
import { Button } from '../button';
|
|
4
|
+
import { Button, ButtonPressType } from '../button';
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
6
|
export declare class HmIpTaster extends HmIPDevice implements iButtonSwitch, iBatteryDevice {
|
|
7
7
|
private static readonly BUTTON_CAPABILLITIES;
|
|
@@ -15,6 +15,7 @@ export declare class HmIpTaster extends HmIPDevice implements iButtonSwitch, iBa
|
|
|
15
15
|
buttonTop: undefined;
|
|
16
16
|
battery: number;
|
|
17
17
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
18
|
+
persist(buttonName: string, pressType: ButtonPressType): void;
|
|
18
19
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
19
20
|
getButtonAssignment(): string;
|
|
20
21
|
}
|
|
@@ -6,20 +6,25 @@ const deviceType_1 = require("../deviceType");
|
|
|
6
6
|
const button_1 = require("../button");
|
|
7
7
|
const models_1 = require("../../../models");
|
|
8
8
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
9
|
+
const services_1 = require("../../services");
|
|
9
10
|
class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
10
11
|
constructor(pInfo) {
|
|
11
12
|
super(pInfo, deviceType_1.DeviceType.HmIpTaster);
|
|
13
|
+
this.buttonBot = undefined;
|
|
14
|
+
this.buttonTop = undefined;
|
|
15
|
+
this.battery = -99;
|
|
16
|
+
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.buttonSwitch);
|
|
17
|
+
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
12
18
|
this.buttonTopLeft = new button_1.Button('TopLeft', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
13
19
|
this.buttonMidLeft = new button_1.Button('MidLeft', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
14
20
|
this.buttonBotLeft = new button_1.Button('BotLeft', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
15
21
|
this.buttonTopRight = new button_1.Button('TopRight', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
16
22
|
this.buttonMidRight = new button_1.Button('MidRight', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
17
23
|
this.buttonBotRight = new button_1.Button('BotRight', HmIpTaster.BUTTON_CAPABILLITIES);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
24
|
+
}
|
|
25
|
+
persist(buttonName, pressType) {
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistSwitchInput(this, pressType, buttonName);
|
|
23
28
|
}
|
|
24
29
|
update(idSplit, state, initial = false) {
|
|
25
30
|
this.log(models_1.LogLevel.DeepTrace, `Taster Update: JSON: ${JSON.stringify(state)}ID: ${idSplit.join('.')}`);
|
|
@@ -55,17 +60,24 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
55
60
|
if (cTaste === undefined) {
|
|
56
61
|
return;
|
|
57
62
|
}
|
|
63
|
+
const boolVal = state.val;
|
|
58
64
|
switch (idSplit[4]) {
|
|
59
65
|
case 'PRESS_SHORT':
|
|
60
66
|
if (!initial) {
|
|
61
67
|
// Tasten beim Starten ignorieren
|
|
62
|
-
|
|
68
|
+
if (boolVal) {
|
|
69
|
+
this.persist(cTaste.name, button_1.ButtonPressType.short);
|
|
70
|
+
}
|
|
71
|
+
cTaste.updateState(button_1.ButtonPressType.short, boolVal);
|
|
63
72
|
}
|
|
64
73
|
break;
|
|
65
74
|
case 'PRESS_LONG':
|
|
66
75
|
if (!initial) {
|
|
67
76
|
// Tasten beim Starten ignorieren
|
|
68
|
-
|
|
77
|
+
if (boolVal) {
|
|
78
|
+
this.persist(cTaste.name, button_1.ButtonPressType.long);
|
|
79
|
+
}
|
|
80
|
+
cTaste.updateState(button_1.ButtonPressType.long, boolVal);
|
|
69
81
|
}
|
|
70
82
|
break;
|
|
71
83
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="iobroker" />
|
|
2
2
|
import { HmIPDevice } from './hmIpDevice';
|
|
3
|
-
import { Button } from '../button';
|
|
3
|
+
import { Button, ButtonPressType } from '../button';
|
|
4
4
|
import { iButtonSwitch } from '../baseDeviceInterfaces';
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
6
|
export declare class HmIpWippe extends HmIPDevice implements iButtonSwitch {
|
|
@@ -15,5 +15,6 @@ export declare class HmIpWippe extends HmIPDevice implements iButtonSwitch {
|
|
|
15
15
|
buttonTop: Button;
|
|
16
16
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
17
17
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
18
|
+
persist(buttonName: string, pressType: ButtonPressType): void;
|
|
18
19
|
getButtonAssignment(): string;
|
|
19
20
|
}
|
|
@@ -6,6 +6,7 @@ const deviceType_1 = require("../deviceType");
|
|
|
6
6
|
const button_1 = require("../button");
|
|
7
7
|
const models_1 = require("../../../models");
|
|
8
8
|
const DeviceCapability_1 = require("../DeviceCapability");
|
|
9
|
+
const services_1 = require("../../services");
|
|
9
10
|
class HmIpWippe extends hmIpDevice_1.HmIPDevice {
|
|
10
11
|
constructor(pInfo) {
|
|
11
12
|
super(pInfo, deviceType_1.DeviceType.HmIpWippe);
|
|
@@ -28,23 +29,32 @@ class HmIpWippe extends hmIpDevice_1.HmIPDevice {
|
|
|
28
29
|
if (cTaste === undefined) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
32
|
+
const boolVal = state.val;
|
|
31
33
|
switch (idSplit[4]) {
|
|
32
34
|
case 'PRESS_SHORT':
|
|
33
35
|
if (!initial) {
|
|
34
36
|
// Tasten beim Starten ignorieren
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
if (boolVal) {
|
|
38
|
+
this.persist(cTaste.name, button_1.ButtonPressType.short);
|
|
39
|
+
}
|
|
40
|
+
cTaste.updateState(button_1.ButtonPressType.short, boolVal);
|
|
37
41
|
}
|
|
38
42
|
break;
|
|
39
43
|
case 'PRESS_LONG':
|
|
40
44
|
if (!initial) {
|
|
41
45
|
// Tasten beim Starten ignorieren
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
if (boolVal) {
|
|
47
|
+
this.persist(cTaste.name, button_1.ButtonPressType.long);
|
|
48
|
+
}
|
|
49
|
+
cTaste.updateState(button_1.ButtonPressType.long, boolVal);
|
|
44
50
|
}
|
|
45
51
|
break;
|
|
46
52
|
}
|
|
47
53
|
}
|
|
54
|
+
persist(buttonName, pressType) {
|
|
55
|
+
var _a;
|
|
56
|
+
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistSwitchInput(this, pressType, buttonName);
|
|
57
|
+
}
|
|
48
58
|
getButtonAssignment() {
|
|
49
59
|
const result = [`Button: ${this.info.customName}`];
|
|
50
60
|
for (const taste of [this.buttonTop, this.buttonBot]) {
|
|
@@ -3,7 +3,8 @@ import { IoBrokerBaseDevice } from './IoBrokerBaseDevice';
|
|
|
3
3
|
import { TimeOfDay } from '../../models';
|
|
4
4
|
import { WledSettings } from '../../models/deviceSettings/wledSettings';
|
|
5
5
|
import { IoBrokerDeviceInfo } from './IoBrokerDeviceInfo';
|
|
6
|
-
|
|
6
|
+
import { iDimmableLamp } from './baseDeviceInterfaces/iDimmableLamp';
|
|
7
|
+
export declare class WledDevice extends IoBrokerBaseDevice implements iDimmableLamp {
|
|
7
8
|
on: boolean;
|
|
8
9
|
brightness: number;
|
|
9
10
|
linkQuality: number;
|
|
@@ -14,7 +15,14 @@ export declare class WledDevice extends IoBrokerBaseDevice {
|
|
|
14
15
|
private readonly _presetID;
|
|
15
16
|
private readonly _brightnessID;
|
|
16
17
|
constructor(pInfo: IoBrokerDeviceInfo);
|
|
18
|
+
get actuatorOn(): boolean;
|
|
19
|
+
get lightOn(): boolean;
|
|
17
20
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean, _pOverride?: boolean): void;
|
|
18
|
-
setLight(pValue: boolean, brightness?: number,
|
|
21
|
+
setLight(pValue: boolean, _timeout?: number, _force?: boolean, brightness?: number, _transitionTime?: number): void;
|
|
22
|
+
setWled(pValue: boolean, brightness?: number, preset?: number): void;
|
|
19
23
|
setTimeBased(time: TimeOfDay): void;
|
|
24
|
+
persist(): void;
|
|
25
|
+
setActuator(pValue: boolean, _timeout?: number, _force?: boolean): void;
|
|
26
|
+
toggleActuator(_force: boolean): boolean;
|
|
27
|
+
toggleLight(time?: TimeOfDay, _force?: boolean, calculateTime?: boolean): boolean;
|
|
20
28
|
}
|
|
@@ -19,6 +19,12 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
19
19
|
this._presetID = `${this.info.fullID}.ps`;
|
|
20
20
|
this._brightnessID = `${this.info.fullID}.bri`;
|
|
21
21
|
}
|
|
22
|
+
get actuatorOn() {
|
|
23
|
+
return this.on;
|
|
24
|
+
}
|
|
25
|
+
get lightOn() {
|
|
26
|
+
return this.on;
|
|
27
|
+
}
|
|
22
28
|
update(idSplit, state, initial = false, _pOverride = false) {
|
|
23
29
|
services_1.ServerLogService.writeLog(models_1.LogLevel.DeepTrace, `Wled: ${initial ? 'Initiales ' : ''}Update für "${this.info.customName}": ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
|
|
24
30
|
switch (idSplit[3]) {
|
|
@@ -30,7 +36,10 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
30
36
|
break;
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
|
-
setLight(pValue,
|
|
39
|
+
setLight(pValue, _timeout, _force, brightness, _transitionTime) {
|
|
40
|
+
this.setWled(pValue, brightness);
|
|
41
|
+
}
|
|
42
|
+
setWled(pValue, brightness = -1, preset) {
|
|
34
43
|
if (this._onID === '') {
|
|
35
44
|
services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `Keine On ID für "${this.info.customName}" bekannt.`);
|
|
36
45
|
return;
|
|
@@ -62,25 +71,49 @@ class WledDevice extends IoBrokerBaseDevice_1.IoBrokerBaseDevice {
|
|
|
62
71
|
switch (time) {
|
|
63
72
|
case models_1.TimeOfDay.Night:
|
|
64
73
|
if (this.settings.nightOn) {
|
|
65
|
-
this.
|
|
74
|
+
this.setWled(true, this.settings.nightBrightness, this.settings.nightPreset);
|
|
66
75
|
}
|
|
67
76
|
break;
|
|
68
77
|
case models_1.TimeOfDay.AfterSunset:
|
|
69
78
|
if (this.settings.duskOn) {
|
|
70
|
-
this.
|
|
79
|
+
this.setWled(true, this.settings.duskBrightness, this.settings.duskPreset);
|
|
71
80
|
}
|
|
72
81
|
break;
|
|
73
82
|
case models_1.TimeOfDay.BeforeSunrise:
|
|
74
83
|
if (this.settings.dawnOn) {
|
|
75
|
-
this.
|
|
84
|
+
this.setWled(true, this.settings.dawnBrightness, this.settings.dawnPreset);
|
|
76
85
|
}
|
|
77
86
|
break;
|
|
78
87
|
case models_1.TimeOfDay.Daylight:
|
|
79
88
|
if (this.settings.dayOn) {
|
|
80
|
-
this.
|
|
89
|
+
this.setWled(true, this.settings.dayBrightness, this.settings.dayPreset);
|
|
81
90
|
}
|
|
82
91
|
break;
|
|
83
92
|
}
|
|
84
93
|
}
|
|
94
|
+
persist() {
|
|
95
|
+
var _a;
|
|
96
|
+
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistActuator(this);
|
|
97
|
+
}
|
|
98
|
+
setActuator(pValue, _timeout, _force) {
|
|
99
|
+
this.setLight(pValue);
|
|
100
|
+
}
|
|
101
|
+
toggleActuator(_force) {
|
|
102
|
+
this.setLight(!this.on);
|
|
103
|
+
return this.on;
|
|
104
|
+
}
|
|
105
|
+
toggleLight(time, _force = false, calculateTime = false) {
|
|
106
|
+
var _a;
|
|
107
|
+
const newVal = !this.lightOn;
|
|
108
|
+
if (newVal && time === undefined && calculateTime && this.room !== undefined) {
|
|
109
|
+
time = services_1.TimeCallbackService.dayType((_a = this.room) === null || _a === void 0 ? void 0 : _a.settings.lampOffset);
|
|
110
|
+
}
|
|
111
|
+
if (newVal && time !== undefined) {
|
|
112
|
+
this.setTimeBased(time);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
this.setLight(newVal);
|
|
116
|
+
return newVal;
|
|
117
|
+
}
|
|
85
118
|
}
|
|
86
119
|
exports.WledDevice = WledDevice;
|
|
@@ -22,6 +22,7 @@ export declare class ZigbeeShutter extends ZigbeeDevice implements iShutter {
|
|
|
22
22
|
get fenster(): Fenster | undefined;
|
|
23
23
|
set fenster(value: Fenster | undefined);
|
|
24
24
|
get desiredFensterLevel(): number;
|
|
25
|
+
persist(): void;
|
|
25
26
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverride?: boolean): void;
|
|
26
27
|
setLevel(pPosition: number, initial?: boolean, skipOpenWarning?: boolean): void;
|
|
27
28
|
toJSON(): Partial<IoBrokerBaseDevice>;
|
|
@@ -45,6 +45,7 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
45
45
|
var _a;
|
|
46
46
|
(_a = this._fenster) === null || _a === void 0 ? void 0 : _a.rolloPositionChange(value);
|
|
47
47
|
}, this);
|
|
48
|
+
this.persist();
|
|
48
49
|
}
|
|
49
50
|
this._currentLevel = value;
|
|
50
51
|
}
|
|
@@ -60,6 +61,10 @@ class ZigbeeShutter extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
60
61
|
}
|
|
61
62
|
return this._fenster.desiredPosition;
|
|
62
63
|
}
|
|
64
|
+
persist() {
|
|
65
|
+
var _a;
|
|
66
|
+
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistShutter(this);
|
|
67
|
+
}
|
|
63
68
|
update(idSplit, state, initial = false, pOverride = false) {
|
|
64
69
|
super.update(idSplit, state, initial, pOverride);
|
|
65
70
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { iButtonSwitch } from '../../baseDeviceInterfaces';
|
|
3
3
|
import { ZigbeeDevice } from './zigbeeDevice';
|
|
4
4
|
import { DeviceType } from '../../deviceType';
|
|
5
|
-
import { Button } from '../../button';
|
|
5
|
+
import { Button, ButtonPressType } from '../../button';
|
|
6
6
|
import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
7
7
|
export declare abstract class ZigbeeSwitch extends ZigbeeDevice implements iButtonSwitch {
|
|
8
8
|
battery: number;
|
|
@@ -15,6 +15,7 @@ export declare abstract class ZigbeeSwitch extends ZigbeeDevice implements iButt
|
|
|
15
15
|
abstract buttonTopLeft: Button | undefined;
|
|
16
16
|
abstract buttonTopRight: Button | undefined;
|
|
17
17
|
constructor(pInfo: IoBrokerDeviceInfo, deviceType: DeviceType);
|
|
18
|
+
persist(buttonName: string, pressType: ButtonPressType): void;
|
|
18
19
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverrride?: boolean): void;
|
|
19
20
|
abstract getButtonAssignment(): string;
|
|
20
21
|
}
|
|
@@ -4,12 +4,17 @@ exports.ZigbeeSwitch = void 0;
|
|
|
4
4
|
const zigbeeDevice_1 = require("./zigbeeDevice");
|
|
5
5
|
const DeviceCapability_1 = require("../../DeviceCapability");
|
|
6
6
|
const models_1 = require("../../../../models");
|
|
7
|
+
const services_1 = require("../../../services");
|
|
7
8
|
class ZigbeeSwitch extends zigbeeDevice_1.ZigbeeDevice {
|
|
8
9
|
constructor(pInfo, deviceType) {
|
|
9
10
|
super(pInfo, deviceType);
|
|
10
11
|
this.battery = -99;
|
|
11
12
|
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.batteryDriven);
|
|
12
13
|
}
|
|
14
|
+
persist(buttonName, pressType) {
|
|
15
|
+
var _a;
|
|
16
|
+
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistSwitchInput(this, pressType, buttonName);
|
|
17
|
+
}
|
|
13
18
|
update(idSplit, state, initial = false, pOverrride = false) {
|
|
14
19
|
super.update(idSplit, state, initial, pOverrride);
|
|
15
20
|
switch (idSplit[3]) {
|
|
@@ -77,23 +77,29 @@ class ZigbeeAqaraOpple3Switch extends BaseDevices_1.ZigbeeSwitch {
|
|
|
77
77
|
this.log(models_1.LogLevel.Error, `Unknown index: ${index} for button, Aqara Opple 3 has only 6 buttons.`);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
+
let pressType = undefined;
|
|
80
81
|
switch (parts[2]) {
|
|
81
82
|
case 'click':
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
pressType = button_1.ButtonPressType.short;
|
|
84
|
+
break;
|
|
84
85
|
case 'hold':
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
pressType = button_1.ButtonPressType.long;
|
|
87
|
+
break;
|
|
87
88
|
case 'double':
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
pressType = button_1.ButtonPressType.double;
|
|
90
|
+
break;
|
|
90
91
|
case 'triple':
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
pressType = button_1.ButtonPressType.triple;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (pressType == undefined) {
|
|
96
|
+
this.log(models_1.LogLevel.Error, `Unknown pressType: "${parts[2]}" for button, Aqara Opple 3 has only types "click, hold, double, triple".`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (val) {
|
|
100
|
+
this.persist(taste.name, pressType);
|
|
96
101
|
}
|
|
102
|
+
taste.updateState(pressType, val);
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
exports.ZigbeeAqaraOpple3Switch = ZigbeeAqaraOpple3Switch;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { iAcDevice, iActuator, iBaseDevice, iHeater, iMotionSensor, IoBrokerBaseDevice } from '../../devices';
|
|
1
|
+
import { ButtonPressType, iAcDevice, iActuator, iBaseDevice, iButtonSwitch, iHeater, iMotionSensor, IoBrokerBaseDevice, iShutter } from '../../devices';
|
|
2
2
|
import { CountToday, CurrentIlluminationDataPoint, EnergyCalculation, RoomBase, ShutterCalibration, TemperaturDataPoint } from '../../../models';
|
|
3
3
|
export interface iPersist {
|
|
4
4
|
initialized: boolean;
|
|
@@ -13,6 +13,8 @@ export interface iPersist {
|
|
|
13
13
|
persistEnergyManager(energyData: EnergyCalculation): void;
|
|
14
14
|
persistAC(device: iAcDevice): void;
|
|
15
15
|
persistActuator(device: iActuator): void;
|
|
16
|
+
persistSwitchInput(device: iButtonSwitch, pressType: ButtonPressType, buttonName: string): void;
|
|
16
17
|
persistMotionSensor(device: iMotionSensor): void;
|
|
18
|
+
persistShutter(device: iShutter): void;
|
|
17
19
|
readTemperaturDataPoint(hzGrp: iHeater, limit: number): Promise<TemperaturDataPoint[]>;
|
|
18
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { iPersist } from './iPersist';
|
|
2
2
|
import { CountToday, CurrentIlluminationDataPoint, EnergyCalculation, RoomBase, ShutterCalibration, TemperaturDataPoint } from '../../../models';
|
|
3
|
-
import { iAcDevice, iActuator, iBaseDevice, iHeater, iMotionSensor, IoBrokerBaseDevice } from '../../devices';
|
|
3
|
+
import { ButtonPressType, iAcDevice, iActuator, iBaseDevice, iButtonSwitch, iHeater, iMotionSensor, IoBrokerBaseDevice, iShutter } from '../../devices';
|
|
4
4
|
import { iPersistenceSettings } from '../../config';
|
|
5
5
|
export declare class PostgreSqlPersist implements iPersist {
|
|
6
6
|
initialized: boolean;
|
|
@@ -14,7 +14,9 @@ export declare class PostgreSqlPersist implements iPersist {
|
|
|
14
14
|
initialize(): Promise<void>;
|
|
15
15
|
persistAC(device: iAcDevice): void;
|
|
16
16
|
persistActuator(device: iActuator): void;
|
|
17
|
+
persistSwitchInput(device: iButtonSwitch, pressType: ButtonPressType, buttonName: string): void;
|
|
17
18
|
persistMotionSensor(device: iMotionSensor): void;
|
|
19
|
+
persistShutter(device: iShutter): void;
|
|
18
20
|
persistCurrentIllumination(data: CurrentIlluminationDataPoint): void;
|
|
19
21
|
persistShutterCalibration(_data: ShutterCalibration): void;
|
|
20
22
|
readTemperaturDataPoint(heater: iHeater, limit: number): Promise<TemperaturDataPoint[]>;
|
|
@@ -124,6 +124,25 @@ create table "CurrentIllumination"
|
|
|
124
124
|
alter table "CurrentIllumination"
|
|
125
125
|
owner to postgres;
|
|
126
126
|
END IF;
|
|
127
|
+
|
|
128
|
+
IF (SELECT to_regclass('hoffmation_schema."ButtonSwitchPresses"') IS NULL) Then
|
|
129
|
+
create table if not exists hoffmation_schema."ButtonSwitchPresses"
|
|
130
|
+
(
|
|
131
|
+
"deviceID" varchar(60) not null
|
|
132
|
+
constraint "ButtonSwitchPresses_DeviceInfo_null_fk"
|
|
133
|
+
references hoffmation_schema."DeviceInfo"
|
|
134
|
+
on delete set null,
|
|
135
|
+
"pressType" int,
|
|
136
|
+
"buttonName" varchar(30),
|
|
137
|
+
date timestamp not null,
|
|
138
|
+
constraint buttonswitchpresses_pk
|
|
139
|
+
primary key ("deviceID", "pressType", date)
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
alter table hoffmation_schema."ButtonSwitchPresses"
|
|
143
|
+
owner to postgres;
|
|
144
|
+
END IF;
|
|
145
|
+
|
|
127
146
|
IF (SELECT to_regclass('hoffmation_schema."EnergyCalculation"') IS NULL) Then
|
|
128
147
|
create table "EnergyCalculation"
|
|
129
148
|
(
|
|
@@ -207,6 +226,23 @@ IF (SELECT to_regclass('hoffmation_schema."MotionSensorDeviceData"') IS NULL) Th
|
|
|
207
226
|
alter table hoffmation_schema."MotionSensorDeviceData"
|
|
208
227
|
owner to postgres;
|
|
209
228
|
END IF;
|
|
229
|
+
|
|
230
|
+
IF (SELECT to_regclass('hoffmation_schema."ShutterDeviceData"') IS NULL) Then
|
|
231
|
+
create table if not exists hoffmation_schema."ShutterDeviceData"
|
|
232
|
+
(
|
|
233
|
+
"deviceID" varchar(60) not null
|
|
234
|
+
constraint "ShutterDeviceData_DeviceInfo_null_fk"
|
|
235
|
+
references hoffmation_schema."DeviceInfo"
|
|
236
|
+
on delete set null,
|
|
237
|
+
"position" double precision,
|
|
238
|
+
date timestamp not null,
|
|
239
|
+
constraint shutterdevicedata_pk
|
|
240
|
+
primary key ("deviceID", date)
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
alter table hoffmation_schema."ShutterDeviceData"
|
|
244
|
+
owner to postgres;
|
|
245
|
+
END IF;
|
|
210
246
|
|
|
211
247
|
IF (SELECT to_regclass('hoffmation_schema."TemperaturData"') IS NULL) Then
|
|
212
248
|
create table "TemperaturData"
|
|
@@ -243,12 +279,24 @@ values ('${device.id}', ${device.on}, '${new Date().toISOString()}', ${device.te
|
|
|
243
279
|
this.query(`
|
|
244
280
|
insert into hoffmation_schema."ActuatorDeviceData" ("deviceID", "on", "date", "percentage")
|
|
245
281
|
values ('${device.id}', ${device.actuatorOn}, '${new Date().toISOString()}', ${percentage !== null && percentage !== void 0 ? percentage : 'null'});
|
|
282
|
+
`);
|
|
283
|
+
}
|
|
284
|
+
persistSwitchInput(device, pressType, buttonName) {
|
|
285
|
+
this.query(`
|
|
286
|
+
insert into hoffmation_schema."ButtonSwitchPresses" ("deviceID", "pressType", "buttonName", "date")
|
|
287
|
+
values ('${device.id}', ${pressType}, '${buttonName}', '${new Date().toISOString()}');
|
|
246
288
|
`);
|
|
247
289
|
}
|
|
248
290
|
persistMotionSensor(device) {
|
|
249
291
|
this.query(`
|
|
250
292
|
insert into hoffmation_schema."MotionSensorDeviceData" ("deviceID", "movementDetected", "date")
|
|
251
293
|
values ('${device.id}', ${device.movementDetected}, '${new Date().toISOString()}');
|
|
294
|
+
`);
|
|
295
|
+
}
|
|
296
|
+
persistShutter(device) {
|
|
297
|
+
this.query(`
|
|
298
|
+
insert into hoffmation_schema."ShutterDeviceData" ("deviceID", "position", "date")
|
|
299
|
+
values ('${device.id}', ${device.currentLevel}, '${new Date().toISOString()}');
|
|
252
300
|
`);
|
|
253
301
|
}
|
|
254
302
|
persistCurrentIllumination(data) {
|