homebridge-tydom 0.22.0 → 0.23.0

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/README.md CHANGED
@@ -230,6 +230,18 @@ You can also use the following environment variables (base64 encoded values)
230
230
  | HOMEBRIDGE_TYDOM_PASSWORD | Tydom password |
231
231
  | HOMEBRIDGE_TYDOM_PIN | Tyxal+ pin |
232
232
 
233
+ ### Help
234
+
235
+ If you open a new issue, please provide a dump of your tydom configuration using node-tydom-client:
236
+
237
+ ```sh
238
+ npx tydom-client request /configs/file /devices/data /devices/meta /devices/cmeta --file tydom_output.json --username 001A25XXXXXX --password XXXXXX
239
+ ```
240
+
241
+ Will create the file `tydom_output.json` to upload, you can use [https://gist.github.com](gist.github.com).
242
+
243
+ An homebridge log with [debug enabled](https://github.com/mgcrea/homebridge-tydom#debug) while using the tydom official app (to trace working requests) can also help a lot.
244
+
233
245
  ### Debug
234
246
 
235
247
  This library uses [debug](https://www.npmjs.com/package/debug) to provide high verbosity logs, just pass the following environment:
@@ -0,0 +1,3 @@
1
+ import type { PlatformAccessory } from 'homebridge';
2
+ import TydomController from '../controller';
3
+ export declare const setupBasicGarageDoorOpener: (accessory: PlatformAccessory, controller: TydomController) => void;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupBasicGarageDoorOpener = void 0;
4
+ const hap_1 = require("../config/hap");
5
+ const accessory_1 = require("../helpers/accessory");
6
+ const debug_1 = require("../utils/debug");
7
+ const setupBasicGarageDoorOpener = (accessory, controller) => {
8
+ const { context } = accessory;
9
+ const { client } = controller;
10
+ const { deviceId, endpointId } = context;
11
+ (0, accessory_1.setupAccessoryInformationService)(accessory, controller);
12
+ (0, accessory_1.setupAccessoryIdentifyHandler)(accessory, controller);
13
+ // Add the actual accessory Service
14
+ const service = (0, accessory_1.addAccessoryService)(accessory, hap_1.Service.Switch, `${accessory.displayName}`, true);
15
+ // State
16
+ // const state = {
17
+ // isOn: false
18
+ // };
19
+ service
20
+ .getCharacteristic(hap_1.Characteristic.On)
21
+ // .on(CharacteristicEventTypes.GET, async (callback: NodeCallback<CharacteristicValue>) => {
22
+ // callback(null, state.isOn);
23
+ // })
24
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
25
+ (0, debug_1.debugSet)(hap_1.Characteristic.On, service, value);
26
+ if (!value) {
27
+ callback();
28
+ return;
29
+ }
30
+ try {
31
+ await client.put(`/devices/${deviceId}/endpoints/${endpointId}/data`, [
32
+ {
33
+ name: 'levelCmd',
34
+ value: 'TOGGLE'
35
+ }
36
+ ]);
37
+ (0, debug_1.debugSetResult)(hap_1.Characteristic.On, service, value);
38
+ callback();
39
+ setTimeout(() => {
40
+ service.updateCharacteristic(hap_1.Characteristic.On, false);
41
+ }, 1000);
42
+ }
43
+ catch (err) {
44
+ callback(err);
45
+ }
46
+ })
47
+ .updateValue(false);
48
+ };
49
+ exports.setupBasicGarageDoorOpener = setupBasicGarageDoorOpener;
@@ -16,7 +16,7 @@ const setupContactSensor = (accessory, controller) => {
16
16
  const service = (0, accessory_1.addAccessoryService)(accessory, hap_1.Service.ContactSensor, `${accessory.displayName}`, true);
17
17
  service
18
18
  .getCharacteristic(ContactSensorState)
19
- .on("get" /* GET */, async (callback) => {
19
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
20
20
  (0, debug_1.debugGet)(ContactSensorState, service);
21
21
  try {
22
22
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -1,3 +1,5 @@
1
1
  import type { PlatformAccessory } from 'homebridge';
2
2
  import TydomController from '../controller';
3
+ import { TydomAccessoryUpdateType } from '../helpers/accessory';
3
4
  export declare const setupGarageDoorOpener: (accessory: PlatformAccessory, controller: TydomController) => void;
5
+ export declare const updateGarageDoorOpener: (accessory: PlatformAccessory, _controller: TydomController, updates: Record<string, unknown>[], type: TydomAccessoryUpdateType) => void;
@@ -1,49 +1,198 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupGarageDoorOpener = void 0;
3
+ exports.updateGarageDoorOpener = exports.setupGarageDoorOpener = void 0;
4
4
  const hap_1 = require("../config/hap");
5
5
  const accessory_1 = require("../helpers/accessory");
6
+ const basic_1 = require("../utils/basic");
7
+ const chalk_1 = require("../utils/chalk");
6
8
  const debug_1 = require("../utils/debug");
7
9
  const setupGarageDoorOpener = (accessory, controller) => {
8
10
  const { context } = accessory;
9
11
  const { client } = controller;
10
- const { deviceId, endpointId } = context;
12
+ const { CurrentDoorState, TargetDoorState } = hap_1.Characteristic;
13
+ const GARAGE_DOOR_DELAY = 15 * 1000;
14
+ const { deviceId, endpointId, state } = context;
15
+ const assignState = (update) => {
16
+ Object.assign(state, update);
17
+ };
18
+ const assignCurrentDoorState = (currentDoorState) => {
19
+ Object.assign(state, { currentDoorState });
20
+ service.updateCharacteristic(CurrentDoorState, currentDoorState);
21
+ };
22
+ const toggleGarageDoor = async () => await client.put(`/devices/${deviceId}/endpoints/${endpointId}/data`, [
23
+ {
24
+ name: 'levelCmd',
25
+ value: 'TOGGLE'
26
+ }
27
+ ]);
11
28
  (0, accessory_1.setupAccessoryInformationService)(accessory, controller);
12
29
  (0, accessory_1.setupAccessoryIdentifyHandler)(accessory, controller);
30
+ assignState({
31
+ currentDoorState: CurrentDoorState.CLOSED,
32
+ targetDoorState: TargetDoorState.CLOSED,
33
+ lastUpdatedAt: 0,
34
+ computedPosition: 0 // 0 <-> GARAGE_DOOR_DELAY
35
+ });
36
+ const getNextCurrentDoorState = (targetDoorState) => {
37
+ switch (state.currentDoorState) {
38
+ case CurrentDoorState.OPEN: {
39
+ switch (targetDoorState) {
40
+ case TargetDoorState.CLOSED:
41
+ return CurrentDoorState.OPENING;
42
+ case TargetDoorState.OPEN:
43
+ return CurrentDoorState.OPEN;
44
+ }
45
+ break;
46
+ }
47
+ case CurrentDoorState.CLOSED: {
48
+ switch (targetDoorState) {
49
+ case TargetDoorState.CLOSED:
50
+ return CurrentDoorState.CLOSED;
51
+ case TargetDoorState.OPEN:
52
+ return CurrentDoorState.CLOSING;
53
+ }
54
+ break;
55
+ }
56
+ case CurrentDoorState.CLOSING:
57
+ case CurrentDoorState.OPENING: {
58
+ return CurrentDoorState.STOPPED;
59
+ }
60
+ case CurrentDoorState.STOPPED: {
61
+ switch (targetDoorState) {
62
+ case TargetDoorState.CLOSED:
63
+ return CurrentDoorState.CLOSING;
64
+ case TargetDoorState.OPEN:
65
+ return CurrentDoorState.OPENING;
66
+ }
67
+ break;
68
+ }
69
+ }
70
+ return CurrentDoorState.CLOSED;
71
+ };
72
+ const computeCurrentPosition = () => {
73
+ const { lastUpdatedAt, computedPosition: lastComputedPosition, currentDoorState } = state;
74
+ const elapsed = lastUpdatedAt - Date.now();
75
+ switch (currentDoorState) {
76
+ case CurrentDoorState.STOPPED: {
77
+ return lastComputedPosition;
78
+ }
79
+ case CurrentDoorState.OPEN: {
80
+ return 100;
81
+ }
82
+ case CurrentDoorState.CLOSED: {
83
+ return 0;
84
+ }
85
+ case CurrentDoorState.OPENING: {
86
+ return Math.min(100, lastComputedPosition + elapsed / GARAGE_DOOR_DELAY);
87
+ }
88
+ case CurrentDoorState.CLOSING: {
89
+ return Math.max(0, lastComputedPosition - elapsed / GARAGE_DOOR_DELAY);
90
+ }
91
+ }
92
+ return 0;
93
+ };
13
94
  // Add the actual accessory Service
14
- const service = (0, accessory_1.addAccessoryService)(accessory, hap_1.Service.Switch, `${accessory.displayName}`, true);
15
- // State
16
- // const state = {
17
- // isOn: false
18
- // };
95
+ const service = (0, accessory_1.addAccessoryService)(accessory, hap_1.Service.GarageDoorOpener, `${accessory.displayName}`, true);
19
96
  service
20
- .getCharacteristic(hap_1.Characteristic.On)
21
- // .on(CharacteristicEventTypes.GET, async (callback: NodeCallback<CharacteristicValue>) => {
22
- // callback(null, state.isOn);
23
- // })
24
- .on("set" /* SET */, async (value, callback) => {
25
- (0, debug_1.debugSet)(hap_1.Characteristic.On, service, value);
97
+ .getCharacteristic(CurrentDoorState)
98
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
99
+ (0, debug_1.debugGet)(CurrentDoorState, service);
100
+ try {
101
+ const nextValue = state.currentDoorState;
102
+ (0, debug_1.debugGetResult)(CurrentDoorState, service, nextValue);
103
+ callback(null, nextValue);
104
+ }
105
+ catch (err) {
106
+ callback(err);
107
+ }
108
+ })
109
+ .getValue();
110
+ service
111
+ .getCharacteristic(TargetDoorState)
112
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
113
+ (0, debug_1.debugGet)(TargetDoorState, service);
114
+ try {
115
+ const nextValue = state.targetDoorState;
116
+ (0, debug_1.debugGetResult)(TargetDoorState, service, nextValue);
117
+ callback(null, nextValue);
118
+ }
119
+ catch (err) {
120
+ callback(err);
121
+ }
122
+ })
123
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
124
+ (0, debug_1.debugSet)(TargetDoorState, service, value);
26
125
  if (!value) {
27
126
  callback();
28
127
  return;
29
128
  }
30
129
  try {
31
- await client.put(`/devices/${deviceId}/endpoints/${endpointId}/data`, [
32
- {
33
- name: 'levelCmd',
34
- value: 'TOGGLE'
35
- }
36
- ]);
37
- (0, debug_1.debugSetResult)(hap_1.Characteristic.On, service, value);
130
+ (0, debug_1.debugSetResult)(TargetDoorState, service, value);
131
+ const targetDoorState = (0, basic_1.asNumber)(value);
132
+ assignState({
133
+ targetDoorState: targetDoorState,
134
+ lastUpdatedAt: Date.now(),
135
+ computedPosition: computeCurrentPosition()
136
+ });
137
+ let nextCurrentDoorState = getNextCurrentDoorState(targetDoorState);
138
+ if (nextCurrentDoorState === state.currentDoorState) {
139
+ (0, debug_1.debug)(`nextCurrentDoorState=${(0, chalk_1.chalkNumber)(nextCurrentDoorState)} === state.currentDoorState`);
140
+ callback();
141
+ return;
142
+ }
143
+ await toggleGarageDoor();
144
+ assignCurrentDoorState(nextCurrentDoorState);
38
145
  callback();
39
- setTimeout(() => {
40
- service.updateCharacteristic(hap_1.Characteristic.On, false);
41
- }, 1000);
146
+ // Handle Stopped state, if we are stopped, wait one second and trigger again to reverse course
147
+ // eg. Stopped -> Closing if target is Closed
148
+ if (nextCurrentDoorState === CurrentDoorState.STOPPED) {
149
+ await (0, basic_1.waitFor)(1000);
150
+ assignState({
151
+ targetDoorState: targetDoorState,
152
+ lastUpdatedAt: Date.now(),
153
+ computedPosition: computeCurrentPosition()
154
+ });
155
+ nextCurrentDoorState = getNextCurrentDoorState(targetDoorState);
156
+ await toggleGarageDoor();
157
+ assignCurrentDoorState(nextCurrentDoorState);
158
+ }
159
+ // Finally update pending states
160
+ switch (nextCurrentDoorState) {
161
+ case CurrentDoorState.OPENING:
162
+ await (0, basic_1.waitFor)((100 - state.computedPosition) * GARAGE_DOOR_DELAY);
163
+ assignCurrentDoorState(CurrentDoorState.OPEN);
164
+ break;
165
+ case CurrentDoorState.CLOSING:
166
+ await (0, basic_1.waitFor)(state.computedPosition * GARAGE_DOOR_DELAY);
167
+ assignCurrentDoorState(CurrentDoorState.CLOSED);
168
+ break;
169
+ }
42
170
  }
43
171
  catch (err) {
44
172
  callback(err);
45
173
  }
46
174
  })
47
- .updateValue(false);
175
+ .getValue();
48
176
  };
49
177
  exports.setupGarageDoorOpener = setupGarageDoorOpener;
178
+ const updateGarageDoorOpener = (accessory, _controller, updates, type) => {
179
+ const { context } = accessory;
180
+ // const {state} = context as TydomAccessoryContext<State>;
181
+ // Process command updates
182
+ if (type === 'cdata') {
183
+ updates.forEach((update) => {
184
+ const { values } = update;
185
+ const { event } = values;
186
+ (0, debug_1.debug)(`New ${(0, chalk_1.chalkKeyword)('GarageDoorOpener')} event=${(0, chalk_1.chalkJson)(event)}`);
187
+ });
188
+ return;
189
+ }
190
+ updates.forEach((update) => {
191
+ const { name, value } = update;
192
+ switch (name) {
193
+ default:
194
+ return;
195
+ }
196
+ });
197
+ };
198
+ exports.updateGarageDoorOpener = updateGarageDoorOpener;
@@ -42,7 +42,7 @@ const setupLightbulb = (accessory, controller) => {
42
42
  }, 15, { leading: true, trailing: true });
43
43
  service
44
44
  .getCharacteristic(hap_1.Characteristic.On)
45
- .on("get" /* GET */, async (callback) => {
45
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
46
46
  (0, debug_1.debugGet)(On, service);
47
47
  try {
48
48
  const data = (await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId }));
@@ -55,7 +55,7 @@ const setupLightbulb = (accessory, controller) => {
55
55
  callback(err);
56
56
  }
57
57
  })
58
- .on("set" /* SET */, async (value, callback) => {
58
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
59
59
  (0, debug_1.debugSet)(On, service, value);
60
60
  try {
61
61
  const nextLevel = value ? state.latestBrightness || 100 : 0;
@@ -71,7 +71,7 @@ const setupLightbulb = (accessory, controller) => {
71
71
  .getValue();
72
72
  service
73
73
  .getCharacteristic(hap_1.Characteristic.Brightness)
74
- .on("get" /* GET */, async (callback) => {
74
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
75
75
  (0, debug_1.debugGet)(Brightness, service);
76
76
  try {
77
77
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -83,7 +83,7 @@ const setupLightbulb = (accessory, controller) => {
83
83
  callback(err);
84
84
  }
85
85
  })
86
- .on("set" /* SET */, async (value, callback) => {
86
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
87
87
  (0, debug_1.debugSet)(Brightness, service, value);
88
88
  try {
89
89
  const nextValue = value;
@@ -77,7 +77,7 @@ const setupSecuritySystem = async (accessory, controller) => {
77
77
  service
78
78
  .getCharacteristic(SecuritySystemCurrentState)
79
79
  .setValue(SecuritySystemCurrentState.DISARMED) // Default to disarmed to prevent notifications
80
- .on("get" /* GET */, async (callback) => {
80
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
81
81
  (0, debug_1.debugGet)(SecuritySystemCurrentState, service);
82
82
  try {
83
83
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -92,7 +92,7 @@ const setupSecuritySystem = async (accessory, controller) => {
92
92
  .getValue();
93
93
  service
94
94
  .getCharacteristic(StatusTampered)
95
- .on("get" /* GET */, async (callback) => {
95
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
96
96
  (0, debug_1.debugGet)(StatusTampered, service);
97
97
  try {
98
98
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -107,7 +107,7 @@ const setupSecuritySystem = async (accessory, controller) => {
107
107
  .getValue();
108
108
  service
109
109
  .getCharacteristic(SecuritySystemTargetState)
110
- .on("get" /* GET */, async (callback) => {
110
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
111
111
  (0, debug_1.debugGet)(SecuritySystemTargetState, service);
112
112
  try {
113
113
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -119,7 +119,7 @@ const setupSecuritySystem = async (accessory, controller) => {
119
119
  callback(err);
120
120
  }
121
121
  })
122
- .on("set" /* SET */, async (value, callback) => {
122
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
123
123
  (0, debug_1.debugSet)(SecuritySystemTargetState, service, value);
124
124
  if (!pin) {
125
125
  callback();
@@ -164,7 +164,7 @@ const setupSecuritySystem = async (accessory, controller) => {
164
164
  service.addLinkedService(systOpenIssueService);
165
165
  systOpenIssueService
166
166
  .getCharacteristic(ContactSensorState)
167
- .on("get" /* GET */, async (callback) => {
167
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
168
168
  (0, debug_1.debugGet)(ContactSensorState, systOpenIssueService);
169
169
  try {
170
170
  const data = (await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId }));
@@ -186,7 +186,7 @@ const setupSecuritySystem = async (accessory, controller) => {
186
186
  service.addLinkedService(alarmSOSService);
187
187
  alarmSOSService
188
188
  .getCharacteristic(ContactSensorState)
189
- .on("get" /* GET */, async (callback) => {
189
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
190
190
  (0, debug_1.debugGet)(ContactSensorState, alarmSOSService);
191
191
  try {
192
192
  const data = (await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId }));
@@ -224,7 +224,7 @@ const setupSecuritySystem = async (accessory, controller) => {
224
224
  service.addLinkedService(zoneService);
225
225
  zoneService
226
226
  .getCharacteristic(On)
227
- .on("get" /* GET */, async (callback) => {
227
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
228
228
  (0, debug_1.debugGet)(On, zoneService);
229
229
  try {
230
230
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -237,7 +237,7 @@ const setupSecuritySystem = async (accessory, controller) => {
237
237
  callback(err);
238
238
  }
239
239
  })
240
- .on("set" /* SET */, async (value, callback) => {
240
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
241
241
  (0, debug_1.debugSet)(On, zoneService, value);
242
242
  if (!pin) {
243
243
  callback();
@@ -41,7 +41,7 @@ const setupSecuritySystemSensors = async (accessory, controller) => {
41
41
  contactSensorService
42
42
  .getCharacteristic(ContactSensorState)
43
43
  .setValue(initialOpenedIssues[productId] ? 1 : 0)
44
- .on("get" /* GET */, async (callback) => {
44
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
45
45
  (0, debug_1.debugGet)(ContactSensorState, contactSensorService);
46
46
  try {
47
47
  const openedIssues = getOpenedIssues(await (0, tydom_1.runTydomDeviceCommand)(client, 'histo', {
@@ -13,7 +13,7 @@ const addAccessorySwitchableService = (accessory, controller, serviceClass) => {
13
13
  const service = (0, accessory_1.addAccessoryService)(accessory, serviceClass, `${accessory.displayName}`, true);
14
14
  service
15
15
  .getCharacteristic(On)
16
- .on("get" /* GET */, async (callback) => {
16
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
17
17
  (0, debug_1.debugGet)(On, service);
18
18
  try {
19
19
  const data = (await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId }));
@@ -26,7 +26,7 @@ const addAccessorySwitchableService = (accessory, controller, serviceClass) => {
26
26
  callback(err);
27
27
  }
28
28
  })
29
- .on("set" /* SET */, async (value, callback) => {
29
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
30
30
  (0, debug_1.debugSet)(On, service, value);
31
31
  try {
32
32
  const tydomValue = value ? 100 : 0;
@@ -19,7 +19,7 @@ const setupTemperatureSensor = (accessory, controller) => {
19
19
  .setProps({
20
20
  minValue: -100
21
21
  })
22
- .on("get" /* GET */, async (callback) => {
22
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
23
23
  (0, debug_1.debugGet)(CurrentTemperature, service);
24
24
  try {
25
25
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -23,7 +23,7 @@ const setupThermostat = (accessory, controller) => {
23
23
  service
24
24
  .getCharacteristic(CurrentHeatingCoolingState)
25
25
  .setProps({ validValues: [0, 1] }) // [OFF, HEAT, COOL]
26
- .on("get" /* GET */, async (callback) => {
26
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
27
27
  (0, debug_1.debugGet)(CurrentHeatingCoolingState, service);
28
28
  try {
29
29
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -44,7 +44,7 @@ const setupThermostat = (accessory, controller) => {
44
44
  service
45
45
  .getCharacteristic(TargetHeatingCoolingState)
46
46
  .setProps({ validValues: [0, 1] }) // [OFF, HEAT, COOL, AUTO]
47
- .on("get" /* GET */, async (callback) => {
47
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
48
48
  (0, debug_1.debugGet)(TargetHeatingCoolingState, service);
49
49
  try {
50
50
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -60,7 +60,7 @@ const setupThermostat = (accessory, controller) => {
60
60
  callback(err);
61
61
  }
62
62
  })
63
- .on("set" /* SET */, async (value, callback) => {
63
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
64
64
  (0, debug_1.debugSet)(TargetHeatingCoolingState, service, value);
65
65
  try {
66
66
  const shouldHeat = [TargetHeatingCoolingState.HEAT, TargetHeatingCoolingState.AUTO].includes(value);
@@ -84,7 +84,7 @@ const setupThermostat = (accessory, controller) => {
84
84
  });
85
85
  service
86
86
  .getCharacteristic(CurrentTemperature)
87
- .on("get" /* GET */, async (callback) => {
87
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
88
88
  (0, debug_1.debugGet)(CurrentTemperature, service);
89
89
  try {
90
90
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -99,7 +99,7 @@ const setupThermostat = (accessory, controller) => {
99
99
  .getValue();
100
100
  service
101
101
  .getCharacteristic(TargetTemperature)
102
- .on("get" /* GET */, async (callback) => {
102
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
103
103
  (0, debug_1.debugGet)(TargetTemperature, service);
104
104
  try {
105
105
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -111,7 +111,7 @@ const setupThermostat = (accessory, controller) => {
111
111
  callback(err);
112
112
  }
113
113
  })
114
- .on("set" /* SET */, async (value, callback) => {
114
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
115
115
  try {
116
116
  (0, debug_1.debugSet)(TargetTemperature, service, value);
117
117
  await client.put(`/devices/${deviceId}/endpoints/${endpointId}/data`, [
@@ -142,7 +142,7 @@ const setupThermostat = (accessory, controller) => {
142
142
  service.addLinkedService(absenceModeService);
143
143
  absenceModeService
144
144
  .getCharacteristic(On)
145
- .on("get" /* GET */, async (callback) => {
145
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
146
146
  (0, debug_1.debugGet)(On, absenceModeService);
147
147
  try {
148
148
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -157,7 +157,7 @@ const setupThermostat = (accessory, controller) => {
157
157
  callback(err);
158
158
  }
159
159
  })
160
- .on("set" /* SET */, async (value, callback) => {
160
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
161
161
  (0, debug_1.debugSet)(On, absenceModeService, value);
162
162
  try {
163
163
  const tydomValue = value ? 'ANTI_FROST' : 'NORMAL';
@@ -189,7 +189,7 @@ const setupThermostat = (accessory, controller) => {
189
189
  service.addLinkedService(thermicLevelService);
190
190
  thermicLevelService
191
191
  .getCharacteristic(On)
192
- .on("get" /* GET */, async (callback) => {
192
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
193
193
  (0, debug_1.debugGet)(On, thermicLevelService);
194
194
  try {
195
195
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -202,7 +202,7 @@ const setupThermostat = (accessory, controller) => {
202
202
  callback(err);
203
203
  }
204
204
  })
205
- .on("set" /* SET */, async (value, callback) => {
205
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
206
206
  (0, debug_1.debugSet)(On, thermicLevelService, value);
207
207
  try {
208
208
  const tydomValue = value ? thermicLevelValue : 'NORMAL';
@@ -36,7 +36,7 @@ const setupWindowCovering = (accessory, controller) => {
36
36
  }, 250, { leading: true, trailing: true });
37
37
  service
38
38
  .getCharacteristic(PositionState)
39
- .on("get" /* GET */, async (callback) => {
39
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
40
40
  (0, debug_1.debugGet)(PositionState, service);
41
41
  try {
42
42
  // @NOTE Tydom does not track the current position
@@ -51,7 +51,7 @@ const setupWindowCovering = (accessory, controller) => {
51
51
  .getValue();
52
52
  service
53
53
  .getCharacteristic(HoldPosition)
54
- .on("set" /* SET */, async (value, callback) => {
54
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
55
55
  (0, debug_1.debugSet)(HoldPosition, service, value);
56
56
  if (!value) {
57
57
  // @NOTE asked to not hold position
@@ -71,7 +71,7 @@ const setupWindowCovering = (accessory, controller) => {
71
71
  .getValue();
72
72
  service
73
73
  .getCharacteristic(CurrentPosition)
74
- .on("get" /* GET */, async (callback) => {
74
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
75
75
  (0, debug_1.debugGet)(CurrentPosition, service);
76
76
  try {
77
77
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -87,7 +87,7 @@ const setupWindowCovering = (accessory, controller) => {
87
87
  .getValue();
88
88
  service
89
89
  .getCharacteristic(TargetPosition)
90
- .on("get" /* GET */, async (callback) => {
90
+ .on("get" /* CharacteristicEventTypes.GET */, async (callback) => {
91
91
  (0, debug_1.debugGet)(TargetPosition, service);
92
92
  try {
93
93
  const data = await (0, tydom_1.getTydomDeviceData)(client, { deviceId, endpointId });
@@ -100,7 +100,7 @@ const setupWindowCovering = (accessory, controller) => {
100
100
  callback(err);
101
101
  }
102
102
  })
103
- .on("set" /* SET */, async (value, callback) => {
103
+ .on("set" /* CharacteristicEventTypes.SET */, async (value, callback) => {
104
104
  (0, debug_1.debugSet)(TargetPosition, service, value);
105
105
  try {
106
106
  const nextValue = value;
@@ -6,14 +6,14 @@ import { TydomHttpMessage, TydomResponse } from 'tydom-client/lib/utils/tydom';
6
6
  import { TydomPlatformConfig } from './platform';
7
7
  import { TydomAccessoryUpdateType } from './helpers';
8
8
  import { TydomAccessoryContext, TydomConfigResponse, TydomGroupsResponse, TydomMetaResponse } from './typings/tydom';
9
- export declare type ControllerDevicePayload = TydomAccessoryContext;
10
- export declare type ControllerUpdatePayload = {
9
+ export type ControllerDevicePayload = TydomAccessoryContext;
10
+ export type ControllerUpdatePayload = {
11
11
  type: TydomAccessoryUpdateType;
12
12
  category: Categories;
13
13
  updates: Record<string, unknown>[];
14
14
  context: TydomAccessoryContext;
15
15
  };
16
- export declare type ControllerNotificationPayload = {
16
+ export type ControllerNotificationPayload = {
17
17
  level: string;
18
18
  message: string;
19
19
  };
@@ -2,15 +2,15 @@ import type { PlatformAccessory, Service, WithUUID } from 'homebridge';
2
2
  import TydomController from '../controller';
3
3
  import { TydomAccessoryContext } from '../typings/tydom';
4
4
  export declare const SECURITY_SYSTEM_SENSORS: number;
5
- export declare type ServiceClass = WithUUID<typeof Service>;
5
+ export type ServiceClass = WithUUID<typeof Service>;
6
6
  export declare const getAccessoryService: (accessory: PlatformAccessory, ServiceClass: ServiceClass) => Service;
7
7
  export declare const getAccessoryServiceWithSubtype: (accessory: PlatformAccessory, ServiceClass: ServiceClass, subtype: string) => Service;
8
8
  export declare const addAccessoryService: (accessory: PlatformAccessory, service: ServiceClass, name: string, removeExisting?: boolean) => Service;
9
9
  export declare const addAccessoryServiceWithSubtype: (accessory: PlatformAccessory, service: ServiceClass, name: string, subtype: string, removeExisting?: boolean) => Service;
10
- declare type TydomAccessorySetup = (accessory: PlatformAccessory, controller: TydomController) => void | Promise<void>;
10
+ type TydomAccessorySetup = (accessory: PlatformAccessory, controller: TydomController) => void | Promise<void>;
11
11
  export declare const getTydomAccessorySetup: (accessory: PlatformAccessory) => TydomAccessorySetup;
12
- export declare type TydomAccessoryUpdateType = 'data' | 'cdata';
13
- declare type TydomAccessoryUpdate = (accessory: PlatformAccessory, controller: TydomController, updates: Record<string, unknown>[], type: TydomAccessoryUpdateType) => void | Promise<void>;
12
+ export type TydomAccessoryUpdateType = 'data' | 'cdata';
13
+ type TydomAccessoryUpdate = (accessory: PlatformAccessory, controller: TydomController, updates: Record<string, unknown>[], type: TydomAccessoryUpdateType) => void | Promise<void>;
14
14
  export declare const getTydomAccessoryDataUpdate: (accessory: PlatformAccessory) => TydomAccessoryUpdate;
15
15
  export declare const setupAccessoryInformationService: (accessory: PlatformAccessory, _controller: TydomController) => void;
16
16
  export declare const setupAccessoryIdentifyHandler: (accessory: PlatformAccessory, _controller: TydomController) => void;
@@ -13,7 +13,7 @@ const windowCovering_1 = require("../accessories/windowCovering");
13
13
  const utils_1 = require("../utils");
14
14
  const hap_1 = require("../config/hap");
15
15
  const outlet_1 = require("../accessories/outlet");
16
- exports.SECURITY_SYSTEM_SENSORS = parseInt(`${11 /* SECURITY_SYSTEM */}0`);
16
+ exports.SECURITY_SYSTEM_SENSORS = parseInt(`${11 /* Categories.SECURITY_SYSTEM */}0`);
17
17
  const getAccessoryService = (accessory, ServiceClass) => {
18
18
  const service = accessory.getService(ServiceClass);
19
19
  (0, utils_1.assert)(service, `Unexpected missing service "${ServiceClass.name}" in accessory`);
@@ -51,24 +51,24 @@ exports.addAccessoryServiceWithSubtype = addAccessoryServiceWithSubtype;
51
51
  const getTydomAccessorySetup = (accessory) => {
52
52
  const { category } = accessory;
53
53
  switch (category) {
54
- case 5 /* LIGHTBULB */:
54
+ case 5 /* Categories.LIGHTBULB */:
55
55
  return lightbulb_1.setupLightbulb;
56
- case 7 /* OUTLET */:
56
+ case 7 /* Categories.OUTLET */:
57
57
  return outlet_1.setupOutlet;
58
- case 9 /* THERMOSTAT */:
58
+ case 9 /* Categories.THERMOSTAT */:
59
59
  return thermostat_1.setupThermostat;
60
- case 3 /* FAN */:
60
+ case 3 /* Categories.FAN */:
61
61
  return fan_1.setupFan;
62
- case 4 /* GARAGE_DOOR_OPENER */:
62
+ case 4 /* Categories.GARAGE_DOOR_OPENER */:
63
63
  return garageDoorOpener_1.setupGarageDoorOpener;
64
- case 14 /* WINDOW_COVERING */:
64
+ case 14 /* Categories.WINDOW_COVERING */:
65
65
  return windowCovering_1.setupWindowCovering;
66
- case 11 /* SECURITY_SYSTEM */:
66
+ case 11 /* Categories.SECURITY_SYSTEM */:
67
67
  return securitySystem_1.setupSecuritySystem;
68
- case 10 /* SENSOR */:
68
+ case 10 /* Categories.SENSOR */:
69
69
  return temperatureSensor_1.setupTemperatureSensor;
70
- case 13 /* WINDOW */:
71
- case 12 /* DOOR */:
70
+ case 13 /* Categories.WINDOW */:
71
+ case 12 /* Categories.DOOR */:
72
72
  return contactSensor_1.setupContactSensor;
73
73
  case exports.SECURITY_SYSTEM_SENSORS:
74
74
  return securitySystemSensors_1.setupSecuritySystemSensors;
@@ -80,26 +80,26 @@ exports.getTydomAccessorySetup = getTydomAccessorySetup;
80
80
  const getTydomAccessoryDataUpdate = (accessory) => {
81
81
  const { category } = accessory;
82
82
  switch (category) {
83
- case 5 /* LIGHTBULB */:
83
+ case 5 /* Categories.LIGHTBULB */:
84
84
  return lightbulb_1.updateLightbulb;
85
- case 7 /* OUTLET */:
85
+ case 7 /* Categories.OUTLET */:
86
86
  return outlet_1.updateOutlet;
87
- case 9 /* THERMOSTAT */:
87
+ case 9 /* Categories.THERMOSTAT */:
88
88
  return thermostat_1.updateThermostat;
89
- case 3 /* FAN */:
89
+ case 3 /* Categories.FAN */:
90
90
  return fan_1.updateFan;
91
- case 4 /* GARAGE_DOOR_OPENER */:
91
+ case 4 /* Categories.GARAGE_DOOR_OPENER */:
92
92
  return () => {
93
93
  // no-op
94
94
  };
95
- case 14 /* WINDOW_COVERING */:
95
+ case 14 /* Categories.WINDOW_COVERING */:
96
96
  return windowCovering_1.updateWindowCovering;
97
- case 11 /* SECURITY_SYSTEM */:
97
+ case 11 /* Categories.SECURITY_SYSTEM */:
98
98
  return securitySystem_1.updateSecuritySystem;
99
- case 10 /* SENSOR */:
99
+ case 10 /* Categories.SENSOR */:
100
100
  return temperatureSensor_1.updateTemperatureSensor;
101
- case 13 /* WINDOW */:
102
- case 12 /* DOOR */:
101
+ case 13 /* Categories.WINDOW */:
102
+ case 12 /* Categories.DOOR */:
103
103
  return contactSensor_1.updateContactSensor;
104
104
  case exports.SECURITY_SYSTEM_SENSORS:
105
105
  return securitySystemSensors_1.updateSecuritySystemSensors;
@@ -124,7 +124,7 @@ exports.setupAccessoryInformationService = setupAccessoryInformationService;
124
124
  const setupAccessoryIdentifyHandler = (accessory, _controller) => {
125
125
  const { displayName: name, UUID: id } = accessory;
126
126
  // listen for the "identify" event for this Accessory
127
- accessory.on("identify" /* IDENTIFY */, ( /* paired: boolean, callback: VoidCallback */) => {
127
+ accessory.on("identify" /* AccessoryEventTypes.IDENTIFY */, ( /* paired: boolean, callback: VoidCallback */) => {
128
128
  // debug({id, type: 'AccessoryEventTypes.IDENTIFY', paired});
129
129
  (0, utils_1.debug)(`New identify request for device named="${name}" with id="${id}"`);
130
130
  // callback();
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -2,13 +2,13 @@ import type { PlatformAccessory } from 'homebridge';
2
2
  import TydomClient from 'tydom-client';
3
3
  import { Categories } from '../config/hap';
4
4
  import { AnyTydomDataValue, TydomConfigEndpoint, TydomEndpointData, TydomGroupsResponse, TydomMetaElement, TydomMetaEndpoint, TydomMetaResponse } from '../typings';
5
- export declare type GetTydomDeviceDataOptions = {
5
+ export type GetTydomDeviceDataOptions = {
6
6
  deviceId: number;
7
7
  endpointId: number;
8
8
  accessory?: PlatformAccessory;
9
9
  };
10
10
  export declare const getTydomDeviceData: <T extends TydomEndpointData = TydomEndpointData>(client: TydomClient, { deviceId, endpointId }: GetTydomDeviceDataOptions) => Promise<T>;
11
- export declare type RunTydomDeviceCommandOptions = {
11
+ export type RunTydomDeviceCommandOptions = {
12
12
  deviceId: number;
13
13
  endpointId: number;
14
14
  searchParams?: Record<string, string>;
@@ -18,7 +18,7 @@ export declare const getTydomDataPropValue: <V extends AnyTydomDataValue = AnyTy
18
18
  export declare const getEndpointDetailsFromMeta: ({ id_endpoint: endpointId, id_device: deviceId }: TydomConfigEndpoint, meta: TydomMetaResponse) => TydomMetaEndpoint;
19
19
  export declare const getEndpointGroupIdFromGroups: ({ id_endpoint: endpointId, id_device: deviceId }: TydomConfigEndpoint, groups: TydomGroupsResponse) => number | null;
20
20
  export declare const getEndpointSignatureFromMetadata: (metadata: TydomMetaElement[]) => string;
21
- declare type ResolveEndpointCategoryOptions = {
21
+ type ResolveEndpointCategoryOptions = {
22
22
  firstUsage: string;
23
23
  metadata: TydomMetaElement[];
24
24
  };
@@ -73,35 +73,35 @@ const getEndpointSignatureFromMetadata = (metadata) => metadata
73
73
  .join('|');
74
74
  exports.getEndpointSignatureFromMetadata = getEndpointSignatureFromMetadata;
75
75
  const LEGACY_SUPPORTED_CATEGORIES_MAP = {
76
- alarm: 11 /* SECURITY_SYSTEM */,
77
- awning: 14 /* WINDOW_COVERING */,
78
- belmDoor: 12 /* DOOR */,
79
- gate: 4 /* GARAGE_DOOR_OPENER */,
80
- garage_door: 4 /* GARAGE_DOOR_OPENER */,
81
- hvac: 9 /* THERMOSTAT */,
82
- light: 5 /* LIGHTBULB */,
83
- shutter: 14 /* WINDOW_COVERING */,
84
- window: 13 /* WINDOW */,
85
- plug: 7 /* OUTLET */
76
+ alarm: 11 /* Categories.SECURITY_SYSTEM */,
77
+ awning: 14 /* Categories.WINDOW_COVERING */,
78
+ belmDoor: 12 /* Categories.DOOR */,
79
+ gate: 4 /* Categories.GARAGE_DOOR_OPENER */,
80
+ garage_door: 4 /* Categories.GARAGE_DOOR_OPENER */,
81
+ hvac: 9 /* Categories.THERMOSTAT */,
82
+ light: 5 /* Categories.LIGHTBULB */,
83
+ shutter: 14 /* Categories.WINDOW_COVERING */,
84
+ window: 13 /* Categories.WINDOW */,
85
+ plug: 7 /* Categories.OUTLET */
86
86
  };
87
87
  const ENDPOINTS_SIGNATURES_CATEGORIES = {
88
- 'alarm:0c6e1d33808fa50a0a921502f80d36430dfaeda5abfed2467f9f2b07821e4842': 11 /* SECURITY_SYSTEM */,
89
- 'alarm:aad768ee0367013a974276117fd5ed4834cc26e4d31acc88d35134731331b0e7': 11 /* SECURITY_SYSTEM */,
90
- 'alarm:6e33f7ee5e62b58f4e888c91a13fd9b9d868f3751cead5ea1252578ba86523a5': 11 /* SECURITY_SYSTEM */,
91
- 'awning:48f43ebab20eba438fa9cc2b6ce44311d3cfb01c5be84bf17599d9c152c348d3': 14 /* WINDOW_COVERING */,
92
- 'belmDoor:fb935867933d89b3058f09384f76fd63f3defb18cfb3172f60fa9f4f237f748b': 12 /* DOOR */,
93
- 'conso:16804a9994bce28275150db329a9c0b931ef7f20608c1a3d2ff248f58569f0d3': 10 /* SENSOR */,
94
- 'gate:83b0912c6fe14622219522922ea0347dcbf86bf9cfd3346a2eca8eac70ca8260': 4 /* GARAGE_DOOR_OPENER */,
95
- 'garage_door:83b0912c6fe14622219522922ea0347dcbf86bf9cfd3346a2eca8eac70ca8260': 4 /* GARAGE_DOOR_OPENER */,
96
- 'hvac:1bab47d1dd7e898b5dc2e9867b14dfb8bc9272c4cb0b5d1221da962d43a6ffb4': 9 /* THERMOSTAT */,
97
- 'hvac:17f933bec8ed29f9b2a2cd5280fb5b64806cf8a1c064c83950e350f491d7cb9f': 9 /* THERMOSTAT */,
98
- 'light:449e2a60377094cde10224cee91d378fb0ae373ae6ceea0ac2cbc1ed011bffa7': 5 /* LIGHTBULB */,
99
- 'light:fce45085835f4f2790ea3b17d208b5ace34935444d2535e75ba3f0a2ce86de5f': 5 /* LIGHTBULB */,
100
- 'shutter:c3fe8e2afa864e1a7a5c6676b4287a7b2f2a886a466baec3df8a1ec4f898ad6c': 14 /* WINDOW_COVERING */,
101
- 'window:fb935867933d89b3058f09384f76fd63f3defb18cfb3172f60fa9f4f237f748b': 13 /* WINDOW */,
102
- 'others:449e2a60377094cde10224cee91d378fb0ae373ae6ceea0ac2cbc1ed011bffa7': 5 /* LIGHTBULB */,
103
- 'hvac:16804a9994bce28275150db329a9c0b931ef7f20608c1a3d2ff248f58569f0d3': 10 /* SENSOR */,
104
- 'plug:2534c497ff8fb013a88da28d341adff5bc0ba77e1fc8ea8dcb8b8f1c9d62ce19': 10 /* SENSOR */ // @Neo33ASM (Easy Plug)
88
+ 'alarm:0c6e1d33808fa50a0a921502f80d36430dfaeda5abfed2467f9f2b07821e4842': 11 /* Categories.SECURITY_SYSTEM */,
89
+ 'alarm:aad768ee0367013a974276117fd5ed4834cc26e4d31acc88d35134731331b0e7': 11 /* Categories.SECURITY_SYSTEM */,
90
+ 'alarm:6e33f7ee5e62b58f4e888c91a13fd9b9d868f3751cead5ea1252578ba86523a5': 11 /* Categories.SECURITY_SYSTEM */,
91
+ 'awning:48f43ebab20eba438fa9cc2b6ce44311d3cfb01c5be84bf17599d9c152c348d3': 14 /* Categories.WINDOW_COVERING */,
92
+ 'belmDoor:fb935867933d89b3058f09384f76fd63f3defb18cfb3172f60fa9f4f237f748b': 12 /* Categories.DOOR */,
93
+ 'conso:16804a9994bce28275150db329a9c0b931ef7f20608c1a3d2ff248f58569f0d3': 10 /* Categories.SENSOR */,
94
+ 'gate:83b0912c6fe14622219522922ea0347dcbf86bf9cfd3346a2eca8eac70ca8260': 4 /* Categories.GARAGE_DOOR_OPENER */,
95
+ 'garage_door:83b0912c6fe14622219522922ea0347dcbf86bf9cfd3346a2eca8eac70ca8260': 4 /* Categories.GARAGE_DOOR_OPENER */,
96
+ 'hvac:1bab47d1dd7e898b5dc2e9867b14dfb8bc9272c4cb0b5d1221da962d43a6ffb4': 9 /* Categories.THERMOSTAT */,
97
+ 'hvac:17f933bec8ed29f9b2a2cd5280fb5b64806cf8a1c064c83950e350f491d7cb9f': 9 /* Categories.THERMOSTAT */,
98
+ 'light:449e2a60377094cde10224cee91d378fb0ae373ae6ceea0ac2cbc1ed011bffa7': 5 /* Categories.LIGHTBULB */,
99
+ 'light:fce45085835f4f2790ea3b17d208b5ace34935444d2535e75ba3f0a2ce86de5f': 5 /* Categories.LIGHTBULB */,
100
+ 'shutter:c3fe8e2afa864e1a7a5c6676b4287a7b2f2a886a466baec3df8a1ec4f898ad6c': 14 /* Categories.WINDOW_COVERING */,
101
+ 'window:fb935867933d89b3058f09384f76fd63f3defb18cfb3172f60fa9f4f237f748b': 13 /* Categories.WINDOW */,
102
+ 'others:449e2a60377094cde10224cee91d378fb0ae373ae6ceea0ac2cbc1ed011bffa7': 5 /* Categories.LIGHTBULB */,
103
+ 'hvac:16804a9994bce28275150db329a9c0b931ef7f20608c1a3d2ff248f58569f0d3': 10 /* Categories.SENSOR */,
104
+ 'plug:2534c497ff8fb013a88da28d341adff5bc0ba77e1fc8ea8dcb8b8f1c9d62ce19': 7 /* Categories.OUTLET */ // @Neo33ASM (Easy Plug)
105
105
  };
106
106
  const resolveEndpointCategory = ({ firstUsage, metadata }) => {
107
107
  // Compute device signature
@@ -1,12 +1,12 @@
1
- export declare type Webhook = {
1
+ export type Webhook = {
2
2
  url: string;
3
3
  type: string;
4
4
  };
5
- export declare type WebhookPayload = {
5
+ export type WebhookPayload = {
6
6
  message: string;
7
7
  level?: string;
8
8
  };
9
- declare type DiscordPayload = {
9
+ type DiscordPayload = {
10
10
  content: string;
11
11
  username?: string;
12
12
  avatar_url?: string;
package/lib/platform.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Categories } from './config/hap';
3
3
  import TydomController, { ControllerDevicePayload, ControllerNotificationPayload, ControllerUpdatePayload } from './controller';
4
4
  import { Webhook } from './helpers';
5
5
  import { TydomAccessoryContext } from './typings/tydom';
6
- export declare type TydomPlatformConfig = PlatformConfig & {
6
+ export type TydomPlatformConfig = PlatformConfig & {
7
7
  hostname: string;
8
8
  username: string;
9
9
  password: string;
package/lib/platform.js CHANGED
@@ -93,7 +93,7 @@ class TydomPlatform {
93
93
  async createAccessory(name, id, category, context) {
94
94
  const { platformAccessory: PlatformAccessory } = this.api;
95
95
  const { group } = context;
96
- const accessoryName = category === 13 /* WINDOW */ && group ? group.name || name : name;
96
+ const accessoryName = category === 13 /* Categories.WINDOW */ && group ? group.name || name : name;
97
97
  this.log.info(`Creating accessory named="${accessoryName}" with id="${id}"`);
98
98
  const accessory = new PlatformAccessory(accessoryName, id, category);
99
99
  Object.assign(accessory.context, context);
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,5 +1,5 @@
1
1
  import { Categories } from '../config/hap';
2
- export declare type TydomAccessoryContext<T extends Record<string, unknown> = Record<string, unknown>> = {
2
+ export type TydomAccessoryContext<T extends Record<string, unknown> = Record<string, unknown>> = {
3
3
  name: string;
4
4
  category: Categories;
5
5
  metadata: TydomMetaElement[];
@@ -13,8 +13,8 @@ export declare type TydomAccessoryContext<T extends Record<string, unknown> = Re
13
13
  group?: TydomConfigGroup;
14
14
  state: T;
15
15
  };
16
- export declare type TydomAccessoryUpdateContext = Pick<TydomAccessoryContext, 'category' | 'deviceId' | 'endpointId' | 'accessoryId'>;
17
- export declare type TydomConfigEndpoint = {
16
+ export type TydomAccessoryUpdateContext = Pick<TydomAccessoryContext, 'category' | 'deviceId' | 'endpointId' | 'accessoryId'>;
17
+ export type TydomConfigEndpoint = {
18
18
  id_endpoint: number;
19
19
  id_device: number;
20
20
  picto: string;
@@ -22,18 +22,18 @@ export declare type TydomConfigEndpoint = {
22
22
  first_usage: string;
23
23
  last_usage: string;
24
24
  };
25
- export declare type TydomConfigGroup = {
25
+ export type TydomConfigGroup = {
26
26
  picto: string;
27
27
  name: string;
28
28
  group_all: boolean;
29
29
  usage: string;
30
30
  id: number;
31
31
  };
32
- export declare type TydomConfigResponse = {
32
+ export type TydomConfigResponse = {
33
33
  endpoints: TydomConfigEndpoint[];
34
34
  groups: TydomConfigGroup[];
35
35
  };
36
- export declare type TydomGroupsResponse = {
36
+ export type TydomGroupsResponse = {
37
37
  groups: Array<{
38
38
  id: number;
39
39
  devices: Array<{
@@ -44,7 +44,7 @@ export declare type TydomGroupsResponse = {
44
44
  }>;
45
45
  }>;
46
46
  };
47
- export declare type TydomMetaElement = {
47
+ export type TydomMetaElement = {
48
48
  enum_values?: string[];
49
49
  max?: number;
50
50
  min?: number;
@@ -54,30 +54,30 @@ export declare type TydomMetaElement = {
54
54
  type: 'boolean' | 'string' | 'numeric';
55
55
  unit?: 'boolean' | '%';
56
56
  };
57
- export declare type TydomMetaEndpoint = {
57
+ export type TydomMetaEndpoint = {
58
58
  id: number;
59
59
  error: number;
60
60
  metadata: TydomMetaElement[];
61
61
  };
62
- export declare type TydomMetaResponse = Array<{
62
+ export type TydomMetaResponse = Array<{
63
63
  id: number;
64
64
  endpoints: TydomMetaEndpoint[];
65
65
  }>;
66
- export declare type AnyTydomDataValue = string | number | boolean;
67
- export declare type TydomDataElement<K = string, V = AnyTydomDataValue> = {
66
+ export type AnyTydomDataValue = string | number | boolean;
67
+ export type TydomDataElement<K = string, V = AnyTydomDataValue> = {
68
68
  name: K;
69
69
  validity: 'expired' | 'upToDate';
70
70
  value: V;
71
71
  };
72
- export declare type TydomEndpointDataResponse = {
72
+ export type TydomEndpointDataResponse = {
73
73
  error: number;
74
74
  data: TydomDataElement[];
75
75
  };
76
- export declare type TydomEndpointData = TydomDataElement[];
77
- export declare type TydomDeviceThermostatAuthorization = 'STOP' | 'HEATING';
78
- export declare type TydomDeviceThermostatHvacMode = 'NORMAL' | 'STOP' | 'ANTI_FROST';
79
- export declare type TydomDeviceThermostatThermicLevel = 'ECO' | 'MODERATO' | 'MEDIO' | 'COMFORT' | 'STOP' | 'ANTI_FROST';
80
- export declare type TydomDeviceThermostatData = [
76
+ export type TydomEndpointData = TydomDataElement[];
77
+ export type TydomDeviceThermostatAuthorization = 'STOP' | 'HEATING';
78
+ export type TydomDeviceThermostatHvacMode = 'NORMAL' | 'STOP' | 'ANTI_FROST';
79
+ export type TydomDeviceThermostatThermicLevel = 'ECO' | 'MODERATO' | 'MEDIO' | 'COMFORT' | 'STOP' | 'ANTI_FROST';
80
+ export type TydomDeviceThermostatData = [
81
81
  TydomDataElement<'authorization', TydomDeviceThermostatAuthorization>,
82
82
  TydomDataElement<'setpoint', number>,
83
83
  TydomDataElement<'thermicLevel', TydomDeviceThermostatThermicLevel>,
@@ -97,7 +97,7 @@ export declare type TydomDeviceThermostatData = [
97
97
  TydomDataElement<'tempSensorOpenCirc', boolean>,
98
98
  TydomDataElement<'boostOn', boolean>
99
99
  ];
100
- export declare type TydomDeviceShutterData = [
100
+ export type TydomDeviceShutterData = [
101
101
  TydomDataElement<'battDefect', boolean>,
102
102
  TydomDataElement<'intrusion', boolean>,
103
103
  TydomDataElement<'obstacleDefect', boolean>,
@@ -105,10 +105,10 @@ export declare type TydomDeviceShutterData = [
105
105
  TydomDataElement<'position', number>,
106
106
  TydomDataElement<'thermicDefect', boolean>
107
107
  ];
108
- export declare type TydomDeviceSecuritySystemAlarmState = 'OFF' | 'DELAYED' | 'ON' | 'QUIET';
109
- export declare type TydomDeviceSecuritySystemAlarmMode = 'OFF' | 'ON' | 'TEST' | 'ZONE' | 'MAINTENANCE';
110
- export declare type TydomDeviceSecuritySystemZoneState = 'UNUSED' | 'ON' | 'OFF';
111
- export declare type TydomDeviceSecuritySystemData = [
108
+ export type TydomDeviceSecuritySystemAlarmState = 'OFF' | 'DELAYED' | 'ON' | 'QUIET';
109
+ export type TydomDeviceSecuritySystemAlarmMode = 'OFF' | 'ON' | 'TEST' | 'ZONE' | 'MAINTENANCE';
110
+ export type TydomDeviceSecuritySystemZoneState = 'UNUSED' | 'ON' | 'OFF';
111
+ export type TydomDeviceSecuritySystemData = [
112
112
  TydomDataElement<'alarmState', 'OFF' | 'DELAYED' | 'ON' | 'QUIET'>,
113
113
  TydomDataElement<'alarmMode', TydomDeviceSecuritySystemAlarmMode>,
114
114
  TydomDataElement<'alarmTechnical', boolean>,
@@ -144,7 +144,7 @@ export declare type TydomDeviceSecuritySystemData = [
144
144
  TydomDataElement<'irv3State', 'AVAILABLE' | 'UNAVAILABLE' | 'LOCKED'>,
145
145
  TydomDataElement<'irv4State', 'AVAILABLE' | 'UNAVAILABLE' | 'LOCKED'>
146
146
  ];
147
- export declare type TydomDeviceDataUpdateBody = {
147
+ export type TydomDeviceDataUpdateBody = {
148
148
  id: number;
149
149
  endpoints: {
150
150
  id: number;
@@ -153,7 +153,7 @@ export declare type TydomDeviceDataUpdateBody = {
153
153
  cdata: Record<string, unknown>[];
154
154
  }[];
155
155
  }[];
156
- export declare type SecuritySystemProduct = {
156
+ export type SecuritySystemProduct = {
157
157
  typeShort: string;
158
158
  typeLong: string;
159
159
  id: number;
@@ -161,7 +161,7 @@ export declare type SecuritySystemProduct = {
161
161
  nameCustom?: string;
162
162
  number?: number;
163
163
  };
164
- export declare type SecuritySystemLabelCommandResult = {
164
+ export type SecuritySystemLabelCommandResult = {
165
165
  zones: {
166
166
  id: number;
167
167
  nameStd?: string;
@@ -169,13 +169,13 @@ export declare type SecuritySystemLabelCommandResult = {
169
169
  }[];
170
170
  products: SecuritySystemProduct[];
171
171
  };
172
- export declare type SecuritySystemHistoOpenIssuesCommandResult = {
172
+ export type SecuritySystemHistoOpenIssuesCommandResult = {
173
173
  step: number;
174
174
  nbElemTot: number;
175
175
  index: number;
176
176
  product?: SecuritySystemProduct;
177
177
  };
178
- export declare type SecuritySystemAlarmEvent = {
178
+ export type SecuritySystemAlarmEvent = {
179
179
  name: 'arret' | 'preAlarm' | 'arretZone' | 'marcheZone' | 'marcheTotale' | 'refusMiseEnMarche' | 'preavisMarcheAuto' | 'alarmIntrusion' | 'passageEnMaintenance';
180
180
  date: string;
181
181
  zones: Array<{
@@ -1,3 +1,4 @@
1
1
  export declare const stringIncludes: (array: unknown[], value: string | number) => boolean;
2
2
  export declare const sameArrays: (source: unknown[], array: unknown[]) => boolean;
3
3
  export declare const asNumber: (maybeNumber: unknown) => number;
4
+ export declare const waitFor: (ms: number) => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asNumber = exports.sameArrays = exports.stringIncludes = void 0;
3
+ exports.waitFor = exports.asNumber = exports.sameArrays = exports.stringIncludes = void 0;
4
4
  const lodash_1 = require("lodash");
5
5
  const stringIncludes = (array, value) => array.includes(value) || array.includes(`${value}`);
6
6
  exports.stringIncludes = stringIncludes;
@@ -8,3 +8,5 @@ const sameArrays = (source, array) => source.length === array.length && (0, loda
8
8
  exports.sameArrays = sameArrays;
9
9
  const asNumber = (maybeNumber) => parseInt(`${maybeNumber}`, 10);
10
10
  exports.asNumber = asNumber;
11
+ const waitFor = async (ms) => new Promise((resolve) => setTimeout(resolve, ms));
12
+ exports.waitFor = waitFor;
@@ -1,7 +1,7 @@
1
1
  import createDebug from 'debug';
2
2
  import { Characteristic } from '../config/hap';
3
3
  import type { PlatformAccessory, Service } from 'homebridge';
4
- declare type IdentifiableAccessoryObject = PlatformAccessory | Service;
4
+ type IdentifiableAccessoryObject = PlatformAccessory | Service;
5
5
  export declare const debug: createDebug.Debugger;
6
6
  export declare const enableDebug: () => void;
7
7
  export declare const dir: (...args: unknown[]) => void;
@@ -1,4 +1,4 @@
1
1
  import crypto from 'crypto';
2
- export declare const decode: (string?: string | undefined) => string;
2
+ export declare const decode: (string?: string) => string;
3
3
  export declare const sha256: (data: crypto.BinaryLike) => Promise<string>;
4
4
  export declare const sha256Sync: (data: crypto.BinaryLike) => string;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,8 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { IncomingMessage } from 'http';
3
4
  import { RequestOptions } from 'https';
4
- export declare type PostJsonOptions = Omit<RequestOptions, 'hostname' | 'path'> & {
5
+ export type PostJsonOptions = Omit<RequestOptions, 'hostname' | 'path'> & {
5
6
  url: string;
6
7
  json?: Record<string, unknown>;
7
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-tydom",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Homebridge plugin to manage Tydom devices by Delta Dore",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -28,34 +28,34 @@
28
28
  "prettycheck": "prettier --check src/",
29
29
  "typecheck": "tsc --noEmit",
30
30
  "test": "npm run lint && npm run prettycheck && npm run typecheck",
31
- "prepare": "npm run build"
31
+ "prepublishOnly": "npm run build"
32
32
  },
33
33
  "dependencies": {
34
- "chalk": "^4.1.1",
35
- "debug": "^4.3.3",
34
+ "chalk": "^4.0.0",
35
+ "debug": "^4.3.4",
36
36
  "fakegato-history": "^0.6.3",
37
37
  "lodash": "^4.17.21",
38
38
  "source-map-support": "^0.5.21",
39
39
  "tydom-client": "^0.13.4"
40
40
  },
41
41
  "devDependencies": {
42
- "@tsconfig/node10": "^1.0.8",
42
+ "@tsconfig/node10": "^1.0.9",
43
43
  "@types/debug": "^4.1.7",
44
- "@types/jest": "^27.4.0",
45
- "@types/lodash": "^4.14.178",
46
- "@types/node": "^17.0.14",
47
- "@types/node-persist": "^3.1.2",
48
- "@types/ws": "^8.2.2",
49
- "@typescript-eslint/eslint-plugin": "^5.10.2",
50
- "@typescript-eslint/parser": "^5.10.2",
51
- "eslint": "^8.8.0",
52
- "eslint-config-prettier": "^8.3.0",
53
- "eslint-plugin-prettier": "^4.0.0",
54
- "homebridge": "^1.4.0",
55
- "jest": "^27.4.7",
56
- "nock": "^13.2.2",
57
- "prettier": "^2.5.1",
58
- "ts-node": "^10.4.0",
59
- "typescript": "^4.5.5"
44
+ "@types/jest": "^29.2.3",
45
+ "@types/lodash": "^4.14.190",
46
+ "@types/node": "^18.11.9",
47
+ "@types/node-persist": "^3.1.3",
48
+ "@types/ws": "^8.5.3",
49
+ "@typescript-eslint/eslint-plugin": "^5.44.0",
50
+ "@typescript-eslint/parser": "^5.44.0",
51
+ "eslint": "^8.28.0",
52
+ "eslint-config-prettier": "^8.5.0",
53
+ "eslint-plugin-prettier": "^4.2.1",
54
+ "homebridge": "^1.5.1",
55
+ "jest": "^29.3.1",
56
+ "nock": "^13.2.9",
57
+ "prettier": "^2.8.0",
58
+ "ts-node": "^10.9.1",
59
+ "typescript": "^4.9.3"
60
60
  }
61
61
  }