hoffmation-base 3.0.0-alpha.53 → 3.0.0-alpha.54
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/server/devices/device-cluster.js +3 -3
- package/lib/server/devices/deviceType.d.ts +1 -0
- package/lib/server/devices/deviceType.js +1 -0
- package/lib/server/devices/devices.js +4 -0
- package/lib/server/devices/shelly/shellyActuator.d.ts +33 -0
- package/lib/server/devices/shelly/shellyActuator.js +84 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -34,6 +34,7 @@ class DeviceCluster {
|
|
|
34
34
|
break;
|
|
35
35
|
case deviceType_1.DeviceType.Camera:
|
|
36
36
|
clusterTypes.push(device_cluster_type_1.DeviceClusterType.Camera);
|
|
37
|
+
clusterTypes.push(device_cluster_type_1.DeviceClusterType.MotionDetection);
|
|
37
38
|
break;
|
|
38
39
|
case deviceType_1.DeviceType.HmIpLampe:
|
|
39
40
|
case deviceType_1.DeviceType.ZigbeeIlluDimmer:
|
|
@@ -76,6 +77,7 @@ class DeviceCluster {
|
|
|
76
77
|
clusterTypes.push(device_cluster_type_1.DeviceClusterType.MotionDetection);
|
|
77
78
|
break;
|
|
78
79
|
case deviceType_1.DeviceType.ZigbeeIkeaSteckdose:
|
|
80
|
+
case deviceType_1.DeviceType.ZigbeeBlitzShp:
|
|
79
81
|
clusterTypes.push(device_cluster_type_1.DeviceClusterType.Outlets);
|
|
80
82
|
break;
|
|
81
83
|
case deviceType_1.DeviceType.ZigbeeIlluLedRGBCCT:
|
|
@@ -93,9 +95,6 @@ class DeviceCluster {
|
|
|
93
95
|
case deviceType_1.DeviceType.ZigbeeAquaraWater:
|
|
94
96
|
clusterTypes.push(device_cluster_type_1.DeviceClusterType.WaterDetectors);
|
|
95
97
|
break;
|
|
96
|
-
case deviceType_1.DeviceType.ZigbeeBlitzShp:
|
|
97
|
-
clusterTypes.push(device_cluster_type_1.DeviceClusterType.Outlets);
|
|
98
|
-
break;
|
|
99
98
|
case deviceType_1.DeviceType.WledDevice:
|
|
100
99
|
clusterTypes.push(device_cluster_type_1.DeviceClusterType.WLED);
|
|
101
100
|
break;
|
|
@@ -105,6 +104,7 @@ class DeviceCluster {
|
|
|
105
104
|
case deviceType_1.DeviceType.HmIpHeizung: // Setting/Controlling via HM-Ip Heizgruppe
|
|
106
105
|
case deviceType_1.DeviceType.unknown:
|
|
107
106
|
case deviceType_1.DeviceType.HmIpAccessPoint: // You can't really do stuff with it.
|
|
107
|
+
case deviceType_1.DeviceType.ShellyActuator: // Dependent on use case
|
|
108
108
|
break;
|
|
109
109
|
}
|
|
110
110
|
for (const type of clusterTypes) {
|
|
@@ -45,6 +45,7 @@ var DeviceType;
|
|
|
45
45
|
DeviceType[DeviceType["JsEnergyManager"] = 301] = "JsEnergyManager";
|
|
46
46
|
DeviceType[DeviceType["RoomScene"] = 401] = "RoomScene";
|
|
47
47
|
DeviceType[DeviceType["ShellyTrv"] = 402] = "ShellyTrv";
|
|
48
|
+
DeviceType[DeviceType["ShellyActuator"] = 403] = "ShellyActuator";
|
|
48
49
|
DeviceType[DeviceType["TuyaGarageDoorOpener"] = 501] = "TuyaGarageDoorOpener";
|
|
49
50
|
DeviceType[DeviceType["WledDevice"] = 1001] = "WledDevice";
|
|
50
51
|
DeviceType[DeviceType["GoveeLed"] = 1002] = "GoveeLed";
|
|
@@ -12,6 +12,7 @@ const wledDevice_1 = require("./wledDevice");
|
|
|
12
12
|
const DeviceCapability_1 = require("./DeviceCapability");
|
|
13
13
|
const shelly_1 = require("./shelly");
|
|
14
14
|
const tuya_1 = require("./tuya");
|
|
15
|
+
const shellyActuator_1 = require("./shelly/shellyActuator");
|
|
15
16
|
class Devices {
|
|
16
17
|
constructor(pDeviceData, pRoomImportEnforcer, config) {
|
|
17
18
|
var _a;
|
|
@@ -104,6 +105,9 @@ class Devices {
|
|
|
104
105
|
case 'Trv':
|
|
105
106
|
d = new shelly_1.ShellyTrv(shellyInfo);
|
|
106
107
|
break;
|
|
108
|
+
case 'Actuator':
|
|
109
|
+
d = new shellyActuator_1.ShellyActuator(shellyInfo);
|
|
110
|
+
break;
|
|
107
111
|
default:
|
|
108
112
|
services_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `No shelly Device Type for ${shellyInfo.deviceType} defined`);
|
|
109
113
|
d = new shelly_1.ShellyDevice(shellyInfo, deviceType_1.DeviceType.unknown);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ShellyDevice } from './shellyDevice';
|
|
2
|
+
import { iActuator } from '../baseDeviceInterfaces';
|
|
3
|
+
import { BlockAutomaticHandler } from '../../services/blockAutomaticHandler';
|
|
4
|
+
import { ActuatorSetStateCommand, ActuatorSettings, ActuatorToggleCommand, ActuatorWriteStateToDeviceCommand, RestoreTargetAutomaticValueCommand } from '../../../models';
|
|
5
|
+
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
|
+
export declare class ShellyActuator extends ShellyDevice implements iActuator {
|
|
7
|
+
/** @inheritDoc */
|
|
8
|
+
readonly blockAutomationHandler: BlockAutomaticHandler;
|
|
9
|
+
/** @inheritDoc */
|
|
10
|
+
targetAutomaticState: boolean;
|
|
11
|
+
/** @inheritDoc */
|
|
12
|
+
settings: ActuatorSettings;
|
|
13
|
+
/** @inheritDoc */
|
|
14
|
+
queuedValue: boolean | null;
|
|
15
|
+
private _lastPersist;
|
|
16
|
+
private readonly _actuatorOnStateId;
|
|
17
|
+
private _actuatorOn;
|
|
18
|
+
constructor(pInfo: IoBrokerDeviceInfo);
|
|
19
|
+
/** @inheritDoc */
|
|
20
|
+
get actuatorOn(): boolean;
|
|
21
|
+
/** @inheritDoc */
|
|
22
|
+
restoreTargetAutomaticValue(c: RestoreTargetAutomaticValueCommand): void;
|
|
23
|
+
/** @inheritDoc */
|
|
24
|
+
update(idSplit: string[], state: ioBroker.State, initial?: boolean, handledByChildObject?: boolean): void;
|
|
25
|
+
/** @inheritDoc */
|
|
26
|
+
setActuator(command: ActuatorSetStateCommand): void;
|
|
27
|
+
/** @inheritDoc */
|
|
28
|
+
persist(): void;
|
|
29
|
+
/** @inheritDoc */
|
|
30
|
+
toggleActuator(command: ActuatorToggleCommand): boolean;
|
|
31
|
+
/** @inheritDoc */
|
|
32
|
+
writeActuatorStateToDevice(c: ActuatorWriteStateToDeviceCommand): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShellyActuator = void 0;
|
|
4
|
+
const shellyDevice_1 = require("./shellyDevice");
|
|
5
|
+
const blockAutomaticHandler_1 = require("../../services/blockAutomaticHandler");
|
|
6
|
+
const models_1 = require("../../../models");
|
|
7
|
+
const deviceType_1 = require("../deviceType");
|
|
8
|
+
const DeviceCapability_1 = require("../DeviceCapability");
|
|
9
|
+
const sharedFunctions_1 = require("../sharedFunctions");
|
|
10
|
+
const services_1 = require("../../services");
|
|
11
|
+
class ShellyActuator extends shellyDevice_1.ShellyDevice {
|
|
12
|
+
constructor(pInfo) {
|
|
13
|
+
super(pInfo, deviceType_1.DeviceType.ShellyActuator);
|
|
14
|
+
/** @inheritDoc */
|
|
15
|
+
this.targetAutomaticState = false;
|
|
16
|
+
/** @inheritDoc */
|
|
17
|
+
this.settings = new models_1.ActuatorSettings();
|
|
18
|
+
/** @inheritDoc */
|
|
19
|
+
this.queuedValue = null;
|
|
20
|
+
this._lastPersist = 0;
|
|
21
|
+
this._actuatorOn = false;
|
|
22
|
+
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.actuator);
|
|
23
|
+
this.deviceCapabilities.push(DeviceCapability_1.DeviceCapability.blockAutomatic);
|
|
24
|
+
this._actuatorOnStateId = `${this.info.fullID}.Relay0.Switch`;
|
|
25
|
+
this.blockAutomationHandler = new blockAutomaticHandler_1.BlockAutomaticHandler(this.restoreTargetAutomaticValue.bind(this), this.log.bind(this));
|
|
26
|
+
}
|
|
27
|
+
/** @inheritDoc */
|
|
28
|
+
get actuatorOn() {
|
|
29
|
+
return this._actuatorOn;
|
|
30
|
+
}
|
|
31
|
+
/** @inheritDoc */
|
|
32
|
+
restoreTargetAutomaticValue(c) {
|
|
33
|
+
this.setActuator(new models_1.ActuatorSetStateCommand(c, this.targetAutomaticState));
|
|
34
|
+
}
|
|
35
|
+
/** @inheritDoc */
|
|
36
|
+
update(idSplit, state, initial = false, handledByChildObject = false) {
|
|
37
|
+
if (!handledByChildObject) {
|
|
38
|
+
this.log(models_1.LogLevel.DeepTrace, `Aktuator Update: ID: ${idSplit.join('.')} JSON: ${JSON.stringify(state)}`);
|
|
39
|
+
}
|
|
40
|
+
this.queuedValue = null;
|
|
41
|
+
super.update(idSplit, state, initial, true);
|
|
42
|
+
if (idSplit[3] === 'Relay0') {
|
|
43
|
+
if (idSplit[4] === 'Switch') {
|
|
44
|
+
this._actuatorOn = state.val;
|
|
45
|
+
if (!initial) {
|
|
46
|
+
this.persist();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** @inheritDoc */
|
|
52
|
+
setActuator(command) {
|
|
53
|
+
if (this._actuatorOnStateId === '') {
|
|
54
|
+
this.log(models_1.LogLevel.Error, 'Keine Switch ID bekannt.');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
sharedFunctions_1.LampUtils.setActuator(this, command);
|
|
58
|
+
}
|
|
59
|
+
/** @inheritDoc */
|
|
60
|
+
persist() {
|
|
61
|
+
var _a;
|
|
62
|
+
const now = services_1.Utils.nowMS();
|
|
63
|
+
if (this._lastPersist + 1000 > now) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistActuator(this);
|
|
67
|
+
this._lastPersist = now;
|
|
68
|
+
}
|
|
69
|
+
/** @inheritDoc */
|
|
70
|
+
toggleActuator(command) {
|
|
71
|
+
const newVal = this.queuedValue !== null ? !this.queuedValue : !this._actuatorOn;
|
|
72
|
+
const setStateCommand = models_1.ActuatorSetStateCommand.byActuatorAndToggleCommand(this, command);
|
|
73
|
+
this.setActuator(setStateCommand);
|
|
74
|
+
return newVal;
|
|
75
|
+
}
|
|
76
|
+
/** @inheritDoc */
|
|
77
|
+
writeActuatorStateToDevice(c) {
|
|
78
|
+
this.log(models_1.LogLevel.Debug, c.logMessage, services_1.LogDebugType.SetActuator);
|
|
79
|
+
this.setState(this._actuatorOnStateId, c.stateValue, undefined, (err) => {
|
|
80
|
+
this.log(models_1.LogLevel.Error, `Lampe schalten ergab Fehler: ${err}`);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.ShellyActuator = ShellyActuator;
|