homebridge-tydom 0.23.8 → 0.23.9
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,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateOutlet = exports.setupOutlet = void 0;
|
|
4
|
-
const definitions_1 = require("hap-nodejs/dist/lib/definitions");
|
|
5
4
|
const lodash_1 = require("lodash");
|
|
6
5
|
const tydom_1 = require("../helpers/tydom");
|
|
7
6
|
const utils_1 = require("../utils");
|
|
@@ -10,7 +9,7 @@ const accessory_1 = require("../helpers/accessory");
|
|
|
10
9
|
const setupOutlet = (accessory, controller) => {
|
|
11
10
|
const { context } = accessory;
|
|
12
11
|
const { client } = controller;
|
|
13
|
-
const { On } = hap_1.Characteristic;
|
|
12
|
+
const { On, OutletInUse } = hap_1.Characteristic;
|
|
14
13
|
const { deviceId, endpointId } = context;
|
|
15
14
|
(0, accessory_1.setupAccessoryInformationService)(accessory, controller);
|
|
16
15
|
(0, accessory_1.setupAccessoryIdentifyHandler)(accessory, controller);
|
|
@@ -49,14 +48,14 @@ const setupOutlet = (accessory, controller) => {
|
|
|
49
48
|
}
|
|
50
49
|
});
|
|
51
50
|
service
|
|
52
|
-
.getCharacteristic(
|
|
51
|
+
.getCharacteristic(OutletInUse)
|
|
53
52
|
.on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
|
|
54
|
-
(0, utils_1.debugGet)(
|
|
53
|
+
(0, utils_1.debugGet)(OutletInUse, service);
|
|
55
54
|
try {
|
|
56
55
|
const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
|
|
57
56
|
const energyInstantTotElecP = (0, tydom_1.getTydomDataPropValue)(data, 'energyInstantTotElecP');
|
|
58
57
|
const nextValue = energyInstantTotElecP > 0;
|
|
59
|
-
(0, utils_1.debugGetResult)(
|
|
58
|
+
(0, utils_1.debugGetResult)(OutletInUse, service, nextValue);
|
|
60
59
|
callback(null, nextValue);
|
|
61
60
|
}
|
|
62
61
|
catch (err) {
|
|
@@ -68,7 +67,7 @@ exports.setupOutlet = setupOutlet;
|
|
|
68
67
|
const updateOutlet = (accessory, _controller, updates) => {
|
|
69
68
|
updates.forEach((update) => {
|
|
70
69
|
const { name, value } = update;
|
|
71
|
-
const { On } = hap_1.Characteristic;
|
|
70
|
+
const { On, OutletInUse } = hap_1.Characteristic;
|
|
72
71
|
switch (name) {
|
|
73
72
|
case 'level': {
|
|
74
73
|
const service = (0, accessory_1.getAccessoryService)(accessory, hap_1.Service.Outlet);
|
|
@@ -80,8 +79,8 @@ const updateOutlet = (accessory, _controller, updates) => {
|
|
|
80
79
|
case 'energyInstantTotElecP': {
|
|
81
80
|
const service = (0, accessory_1.getAccessoryService)(accessory, hap_1.Service.Outlet);
|
|
82
81
|
const nextValue = (0, lodash_1.toNumber)(value) > 0;
|
|
83
|
-
(0, utils_1.debugSetUpdate)(
|
|
84
|
-
service.updateCharacteristic(
|
|
82
|
+
(0, utils_1.debugSetUpdate)(OutletInUse, service, nextValue);
|
|
83
|
+
service.updateCharacteristic(OutletInUse, nextValue);
|
|
85
84
|
return;
|
|
86
85
|
}
|
|
87
86
|
default:
|