homebridge-midea-platform 1.2.0-beta.2 → 1.2.0-beta.4

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.
Files changed (89) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/AC_ori.lua +5140 -0
  3. package/config.schema.json +14 -2
  4. package/dist/accessory/AccessoryFactory.d.ts +13 -12
  5. package/dist/accessory/AccessoryFactory.d.ts.map +1 -1
  6. package/dist/accessory/AccessoryFactory.js +37 -31
  7. package/dist/accessory/AccessoryFactory.js.map +1 -1
  8. package/dist/accessory/AirConditionerAccessory.d.ts +98 -92
  9. package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
  10. package/dist/accessory/AirConditionerAccessory.js +662 -607
  11. package/dist/accessory/AirConditionerAccessory.js.map +1 -1
  12. package/dist/accessory/BaseAccessory.d.ts +11 -11
  13. package/dist/accessory/BaseAccessory.js +21 -21
  14. package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
  15. package/dist/accessory/DehumidifierAccessory.js +344 -344
  16. package/dist/accessory/DishwasherAccessory.d.ts +30 -30
  17. package/dist/accessory/DishwasherAccessory.js +63 -63
  18. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
  19. package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
  20. package/dist/accessory/FanAccessory.d.ts +39 -39
  21. package/dist/accessory/FanAccessory.js +123 -123
  22. package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -30
  23. package/dist/accessory/FrontLoadWasherAccessory.js +66 -66
  24. package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
  25. package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
  26. package/dist/core/MideaCloud.d.ts +35 -35
  27. package/dist/core/MideaCloud.js +350 -350
  28. package/dist/core/MideaConstants.d.ts +50 -50
  29. package/dist/core/MideaConstants.js +58 -58
  30. package/dist/core/MideaDevice.d.ts +76 -76
  31. package/dist/core/MideaDevice.js +409 -409
  32. package/dist/core/MideaDiscover.d.ts +35 -35
  33. package/dist/core/MideaDiscover.js +212 -212
  34. package/dist/core/MideaMessage.d.ts +75 -75
  35. package/dist/core/MideaMessage.js +184 -184
  36. package/dist/core/MideaPacketBuilder.d.ts +10 -10
  37. package/dist/core/MideaPacketBuilder.js +60 -60
  38. package/dist/core/MideaSecurity.d.ts +63 -63
  39. package/dist/core/MideaSecurity.js +251 -251
  40. package/dist/core/MideaUtils.d.ts +32 -32
  41. package/dist/core/MideaUtils.js +181 -181
  42. package/dist/devices/DeviceFactory.d.ts +13 -13
  43. package/dist/devices/DeviceFactory.d.ts.map +1 -1
  44. package/dist/devices/DeviceFactory.js +37 -36
  45. package/dist/devices/DeviceFactory.js.map +1 -1
  46. package/dist/devices/a1/MideaA1Device.d.ts +76 -76
  47. package/dist/devices/a1/MideaA1Device.js +145 -145
  48. package/dist/devices/a1/MideaA1Message.d.ts +40 -40
  49. package/dist/devices/a1/MideaA1Message.js +198 -198
  50. package/dist/devices/ac/MideaACDevice.d.ts +106 -104
  51. package/dist/devices/ac/MideaACDevice.d.ts.map +1 -1
  52. package/dist/devices/ac/MideaACDevice.js +400 -384
  53. package/dist/devices/ac/MideaACDevice.js.map +1 -1
  54. package/dist/devices/ac/MideaACMessage.d.ts +95 -94
  55. package/dist/devices/ac/MideaACMessage.d.ts.map +1 -1
  56. package/dist/devices/ac/MideaACMessage.js +619 -611
  57. package/dist/devices/ac/MideaACMessage.js.map +1 -1
  58. package/dist/devices/db/MideaDBDevice.d.ts +29 -29
  59. package/dist/devices/db/MideaDBDevice.js +100 -100
  60. package/dist/devices/db/MideaDBMessage.d.ts +32 -32
  61. package/dist/devices/db/MideaDBMessage.js +101 -101
  62. package/dist/devices/e1/MideaE1Device.d.ts +56 -56
  63. package/dist/devices/e1/MideaE1Device.js +128 -128
  64. package/dist/devices/e1/MideaE1Message.d.ts +28 -28
  65. package/dist/devices/e1/MideaE1Message.js +107 -107
  66. package/dist/devices/e2/MideaE2Device.d.ts +44 -44
  67. package/dist/devices/e2/MideaE2Device.js +129 -129
  68. package/dist/devices/e2/MideaE2Message.d.ts +33 -33
  69. package/dist/devices/e2/MideaE2Message.js +132 -132
  70. package/dist/devices/e3/MideaE3Device.d.ts +43 -43
  71. package/dist/devices/e3/MideaE3Device.js +137 -137
  72. package/dist/devices/e3/MideaE3Message.d.ts +51 -51
  73. package/dist/devices/e3/MideaE3Message.js +136 -136
  74. package/dist/devices/fa/MideaFADevice.d.ts +36 -36
  75. package/dist/devices/fa/MideaFADevice.js +106 -106
  76. package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
  77. package/dist/devices/fa/MideaFAMessage.js +98 -98
  78. package/dist/index.d.ts +6 -6
  79. package/dist/index.js +6 -6
  80. package/dist/platform.d.ts +60 -60
  81. package/dist/platform.js +212 -212
  82. package/dist/platformUtils.d.ts +108 -106
  83. package/dist/platformUtils.d.ts.map +1 -1
  84. package/dist/platformUtils.js +103 -101
  85. package/dist/platformUtils.js.map +1 -1
  86. package/dist/settings.d.ts +8 -8
  87. package/dist/settings.js +11 -11
  88. package/docs/ac.md +6 -0
  89. package/package.json +1 -1
@@ -1,182 +1,182 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PromiseSocket = exports.calculate = exports.strxor = exports.numberToUint8Array = void 0;
4
- const MideaConstants_1 = require("./MideaConstants");
5
- const net_1 = require("net");
6
- function numberToUint8Array(num, byte_length, endianness) {
7
- const arr = new Uint8Array(byte_length);
8
- for (let i = 0; i < byte_length; i++) {
9
- arr[i] = num % 256;
10
- num = Math.floor(num / 256);
11
- }
12
- return endianness === MideaConstants_1.Endianness.Big ? arr.reverse() : arr;
13
- }
14
- exports.numberToUint8Array = numberToUint8Array;
15
- function strxor(a, b) {
16
- if (a.length !== b.length) {
17
- throw Error('strxor: a and b must have the same length!');
18
- }
19
- const output = Buffer.alloc(a.length);
20
- for (let i = 0; i < a.length; i++) {
21
- output[i] = a[i] ^ b[i];
22
- }
23
- return output;
24
- }
25
- exports.strxor = strxor;
26
- const CRC8_854_TABLE = [
27
- 0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40,
28
- 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde,
29
- 0x3c, 0x62, 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff, 0x46, 0x18, 0xfa, 0xa4, 0x27,
30
- 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07, 0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb,
31
- 0x78, 0x26, 0xc4, 0x9a, 0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24, 0xf8, 0xa6, 0x44,
32
- 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9, 0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10,
33
- 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd, 0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50, 0xaf,
34
- 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee, 0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1,
35
- 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73, 0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5,
36
- 0x8b, 0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16, 0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6,
37
- 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8, 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7,
38
- 0x89, 0x6b, 0x35,
39
- ];
40
- function calculate(data) {
41
- let crc = 0;
42
- for (let i = 0; i < data.length; i++) {
43
- let k = crc ^ data[i];
44
- if (k > 256) {
45
- k -= 256;
46
- }
47
- if (k < 0) {
48
- k += 256;
49
- }
50
- crc = CRC8_854_TABLE[k];
51
- }
52
- return crc;
53
- }
54
- exports.calculate = calculate;
55
- /*********************************************************************
56
- * PromiseSocket
57
- * A very basic implementation of promise-wrapped Socket
58
- *
59
- */
60
- class PromiseSocket {
61
- constructor(logger, logerror) {
62
- this.logger = logger;
63
- this.logerror = logerror;
64
- this.innerSok = new net_1.Socket();
65
- this.destroyed = false;
66
- this.innerSok.on('error', (e) => {
67
- // Log the error
68
- const msg = e instanceof Error ? e.stack : e;
69
- if (this.logerror) {
70
- this.logger.warn(`Socket error:\n${msg}`);
71
- }
72
- else {
73
- this.logger.debug(`Socket error:\n${msg}`);
74
- }
75
- // According to https://nodejs.org/api/net.html#event-error_1 the "close" event
76
- // will be called immediately following an "error" event. So don't throw an error
77
- // and handle the destory in the close event.
78
- });
79
- this.innerSok.on('close', async (hadError) => {
80
- this.destroy();
81
- if (this.logerror) {
82
- this.logger.warn(`Socket closed ${hadError ? 'with' : 'without'} error`);
83
- }
84
- else {
85
- this.logger.debug(`Socket closed ${hadError ? 'with' : 'without'} error`);
86
- }
87
- });
88
- }
89
- async connect(port, host) {
90
- return new Promise((resolve, reject) => {
91
- const errorHandler = (err) => {
92
- removeListeners();
93
- reject(err);
94
- };
95
- const removeListeners = () => {
96
- this.innerSok.removeListener('error', errorHandler);
97
- };
98
- this.innerSok.connect(port, host, () => {
99
- // This function is added as a "connect" listener so called
100
- // on successful connection.
101
- removeListeners();
102
- resolve();
103
- });
104
- this.innerSok.on('error', errorHandler);
105
- });
106
- }
107
- setTimeout(t) {
108
- this.innerSok.setTimeout(t);
109
- }
110
- destroy() {
111
- this.destroyed = true;
112
- this.innerSok.destroy();
113
- }
114
- async write(data, encoding) {
115
- return new Promise((resolve, reject) => {
116
- const errorHandler = (err) => {
117
- removeListeners();
118
- reject(err);
119
- };
120
- const removeListeners = () => {
121
- this.innerSok.removeListener('error', errorHandler);
122
- };
123
- this.innerSok.on('error', errorHandler);
124
- try {
125
- this.innerSok.write(data, encoding, (err) => {
126
- // This function is called when all data successfully sent
127
- removeListeners();
128
- if (err) {
129
- reject(err);
130
- }
131
- else {
132
- resolve();
133
- }
134
- });
135
- }
136
- catch (err) {
137
- removeListeners();
138
- reject(err);
139
- }
140
- });
141
- }
142
- async read() {
143
- return new Promise((resolve, reject) => {
144
- let buf = Buffer.alloc(0);
145
- const dataHandler = (data) => {
146
- buf = Buffer.concat([buf, data]);
147
- removeListeners();
148
- resolve(buf);
149
- };
150
- const timeoutHandler = () => {
151
- removeListeners();
152
- resolve(buf);
153
- };
154
- const endHandler = () => {
155
- removeListeners();
156
- resolve(buf);
157
- };
158
- const errorHandler = (err) => {
159
- removeListeners();
160
- reject(err);
161
- };
162
- const closeHandler = () => {
163
- removeListeners();
164
- resolve(buf);
165
- };
166
- const removeListeners = () => {
167
- this.innerSok.removeListener('close', closeHandler);
168
- this.innerSok.removeListener('data', dataHandler);
169
- this.innerSok.removeListener('timeout', timeoutHandler);
170
- this.innerSok.removeListener('end', endHandler);
171
- this.innerSok.removeListener('error', errorHandler);
172
- };
173
- this.innerSok.on('close', closeHandler);
174
- this.innerSok.on('data', dataHandler);
175
- this.innerSok.on('timeout', timeoutHandler);
176
- this.innerSok.on('end', endHandler);
177
- this.innerSok.on('error', errorHandler);
178
- });
179
- }
180
- }
181
- exports.PromiseSocket = PromiseSocket;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PromiseSocket = exports.calculate = exports.strxor = exports.numberToUint8Array = void 0;
4
+ const MideaConstants_1 = require("./MideaConstants");
5
+ const net_1 = require("net");
6
+ function numberToUint8Array(num, byte_length, endianness) {
7
+ const arr = new Uint8Array(byte_length);
8
+ for (let i = 0; i < byte_length; i++) {
9
+ arr[i] = num % 256;
10
+ num = Math.floor(num / 256);
11
+ }
12
+ return endianness === MideaConstants_1.Endianness.Big ? arr.reverse() : arr;
13
+ }
14
+ exports.numberToUint8Array = numberToUint8Array;
15
+ function strxor(a, b) {
16
+ if (a.length !== b.length) {
17
+ throw Error('strxor: a and b must have the same length!');
18
+ }
19
+ const output = Buffer.alloc(a.length);
20
+ for (let i = 0; i < a.length; i++) {
21
+ output[i] = a[i] ^ b[i];
22
+ }
23
+ return output;
24
+ }
25
+ exports.strxor = strxor;
26
+ const CRC8_854_TABLE = [
27
+ 0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40,
28
+ 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0x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xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6,
37
+ 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8, 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7,
38
+ 0x89, 0x6b, 0x35,
39
+ ];
40
+ function calculate(data) {
41
+ let crc = 0;
42
+ for (let i = 0; i < data.length; i++) {
43
+ let k = crc ^ data[i];
44
+ if (k > 256) {
45
+ k -= 256;
46
+ }
47
+ if (k < 0) {
48
+ k += 256;
49
+ }
50
+ crc = CRC8_854_TABLE[k];
51
+ }
52
+ return crc;
53
+ }
54
+ exports.calculate = calculate;
55
+ /*********************************************************************
56
+ * PromiseSocket
57
+ * A very basic implementation of promise-wrapped Socket
58
+ *
59
+ */
60
+ class PromiseSocket {
61
+ constructor(logger, logerror) {
62
+ this.logger = logger;
63
+ this.logerror = logerror;
64
+ this.innerSok = new net_1.Socket();
65
+ this.destroyed = false;
66
+ this.innerSok.on('error', (e) => {
67
+ // Log the error
68
+ const msg = e instanceof Error ? e.stack : e;
69
+ if (this.logerror) {
70
+ this.logger.warn(`Socket error:\n${msg}`);
71
+ }
72
+ else {
73
+ this.logger.debug(`Socket error:\n${msg}`);
74
+ }
75
+ // According to https://nodejs.org/api/net.html#event-error_1 the "close" event
76
+ // will be called immediately following an "error" event. So don't throw an error
77
+ // and handle the destory in the close event.
78
+ });
79
+ this.innerSok.on('close', async (hadError) => {
80
+ this.destroy();
81
+ if (this.logerror) {
82
+ this.logger.warn(`Socket closed ${hadError ? 'with' : 'without'} error`);
83
+ }
84
+ else {
85
+ this.logger.debug(`Socket closed ${hadError ? 'with' : 'without'} error`);
86
+ }
87
+ });
88
+ }
89
+ async connect(port, host) {
90
+ return new Promise((resolve, reject) => {
91
+ const errorHandler = (err) => {
92
+ removeListeners();
93
+ reject(err);
94
+ };
95
+ const removeListeners = () => {
96
+ this.innerSok.removeListener('error', errorHandler);
97
+ };
98
+ this.innerSok.connect(port, host, () => {
99
+ // This function is added as a "connect" listener so called
100
+ // on successful connection.
101
+ removeListeners();
102
+ resolve();
103
+ });
104
+ this.innerSok.on('error', errorHandler);
105
+ });
106
+ }
107
+ setTimeout(t) {
108
+ this.innerSok.setTimeout(t);
109
+ }
110
+ destroy() {
111
+ this.destroyed = true;
112
+ this.innerSok.destroy();
113
+ }
114
+ async write(data, encoding) {
115
+ return new Promise((resolve, reject) => {
116
+ const errorHandler = (err) => {
117
+ removeListeners();
118
+ reject(err);
119
+ };
120
+ const removeListeners = () => {
121
+ this.innerSok.removeListener('error', errorHandler);
122
+ };
123
+ this.innerSok.on('error', errorHandler);
124
+ try {
125
+ this.innerSok.write(data, encoding, (err) => {
126
+ // This function is called when all data successfully sent
127
+ removeListeners();
128
+ if (err) {
129
+ reject(err);
130
+ }
131
+ else {
132
+ resolve();
133
+ }
134
+ });
135
+ }
136
+ catch (err) {
137
+ removeListeners();
138
+ reject(err);
139
+ }
140
+ });
141
+ }
142
+ async read() {
143
+ return new Promise((resolve, reject) => {
144
+ let buf = Buffer.alloc(0);
145
+ const dataHandler = (data) => {
146
+ buf = Buffer.concat([buf, data]);
147
+ removeListeners();
148
+ resolve(buf);
149
+ };
150
+ const timeoutHandler = () => {
151
+ removeListeners();
152
+ resolve(buf);
153
+ };
154
+ const endHandler = () => {
155
+ removeListeners();
156
+ resolve(buf);
157
+ };
158
+ const errorHandler = (err) => {
159
+ removeListeners();
160
+ reject(err);
161
+ };
162
+ const closeHandler = () => {
163
+ removeListeners();
164
+ resolve(buf);
165
+ };
166
+ const removeListeners = () => {
167
+ this.innerSok.removeListener('close', closeHandler);
168
+ this.innerSok.removeListener('data', dataHandler);
169
+ this.innerSok.removeListener('timeout', timeoutHandler);
170
+ this.innerSok.removeListener('end', endHandler);
171
+ this.innerSok.removeListener('error', errorHandler);
172
+ };
173
+ this.innerSok.on('close', closeHandler);
174
+ this.innerSok.on('data', dataHandler);
175
+ this.innerSok.on('timeout', timeoutHandler);
176
+ this.innerSok.on('end', endHandler);
177
+ this.innerSok.on('error', errorHandler);
178
+ });
179
+ }
180
+ }
181
+ exports.PromiseSocket = PromiseSocket;
182
182
  //# sourceMappingURL=MideaUtils.js.map
@@ -1,14 +1,14 @@
1
- import { Logger } from 'homebridge';
2
- import { DeviceInfo } from '../core/MideaConstants';
3
- import { Config, DeviceConfig } from '../platformUtils';
4
- import MideaACDevice from './ac/MideaACDevice';
5
- import MideaA1Device from './a1/MideaA1Device';
6
- import MideaE2Device from './e2/MideaE2Device';
7
- import MideaE3Device from './e3/MideaE3Device';
8
- import MideaFADevice from './fa/MideaFADevice';
9
- import MideaDBDevice from './db/MideaDBDevice';
10
- import MideaE1Device from './e1/MideaE1Device';
11
- export default class DeviceFactory {
12
- static createDevice(logger: Logger, device_info: DeviceInfo, config: Config, deviceConfig: DeviceConfig): MideaACDevice | MideaA1Device | MideaDBDevice | MideaE2Device | MideaE3Device | MideaFADevice | MideaE1Device | null;
13
- }
1
+ import { Logger } from 'homebridge';
2
+ import { DeviceInfo } from '../core/MideaConstants';
3
+ import { Config, DeviceConfig } from '../platformUtils';
4
+ import MideaACDevice from './ac/MideaACDevice';
5
+ import MideaA1Device from './a1/MideaA1Device';
6
+ import MideaE2Device from './e2/MideaE2Device';
7
+ import MideaE3Device from './e3/MideaE3Device';
8
+ import MideaFADevice from './fa/MideaFADevice';
9
+ import MideaDBDevice from './db/MideaDBDevice';
10
+ import MideaE1Device from './e1/MideaE1Device';
11
+ export default class DeviceFactory {
12
+ static createDevice(logger: Logger, device_info: DeviceInfo, config: Config, deviceConfig: DeviceConfig): MideaACDevice | MideaA1Device | MideaDBDevice | MideaE2Device | MideaE3Device | MideaFADevice | MideaE1Device | null;
13
+ }
14
14
  //# sourceMappingURL=DeviceFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceFactory.d.ts","sourceRoot":"","sources":["../../src/devices/DeviceFactory.ts"],"names":[],"mapp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AE,MAAM,EAAE,YAAY,EAAE,YAAY;CAqB/G"}
@@ -1,37 +1,38 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const MideaConstants_1 = require("../core/MideaConstants");
7
- const MideaACDevice_1 = __importDefault(require("./ac/MideaACDevice"));
8
- const MideaA1Device_1 = __importDefault(require("./a1/MideaA1Device"));
9
- const MideaE2Device_1 = __importDefault(require("./e2/MideaE2Device"));
10
- const MideaE3Device_1 = __importDefault(require("./e3/MideaE3Device"));
11
- const MideaFADevice_1 = __importDefault(require("./fa/MideaFADevice"));
12
- const MideaDBDevice_1 = __importDefault(require("./db/MideaDBDevice"));
13
- const MideaE1Device_1 = __importDefault(require("./e1/MideaE1Device"));
14
- class DeviceFactory {
15
- static createDevice(logger, device_info, config, deviceConfig) {
16
- switch (device_info.type) {
17
- case MideaConstants_1.DeviceType.AIR_CONDITIONER:
18
- return new MideaACDevice_1.default(logger, device_info, config, deviceConfig);
19
- case MideaConstants_1.DeviceType.DEHUMIDIFIER:
20
- return new MideaA1Device_1.default(logger, device_info, config, deviceConfig);
21
- case MideaConstants_1.DeviceType.FRONT_LOAD_WASHER:
22
- return new MideaDBDevice_1.default(logger, device_info, config, deviceConfig);
23
- case MideaConstants_1.DeviceType.DISHWASHER:
24
- return new MideaE1Device_1.default(logger, device_info, config, deviceConfig);
25
- case MideaConstants_1.DeviceType.ELECTRIC_WATER_HEATER:
26
- return new MideaE2Device_1.default(logger, device_info, config, deviceConfig);
27
- case MideaConstants_1.DeviceType.GAS_WATER_HEATER:
28
- return new MideaE3Device_1.default(logger, device_info, config, deviceConfig);
29
- case MideaConstants_1.DeviceType.FAN:
30
- return new MideaFADevice_1.default(logger, device_info, config, deviceConfig);
31
- default:
32
- return null;
33
- }
34
- }
35
- }
36
- exports.default = DeviceFactory;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const MideaConstants_1 = require("../core/MideaConstants");
7
+ const MideaACDevice_1 = __importDefault(require("./ac/MideaACDevice"));
8
+ const MideaA1Device_1 = __importDefault(require("./a1/MideaA1Device"));
9
+ const MideaE2Device_1 = __importDefault(require("./e2/MideaE2Device"));
10
+ const MideaE3Device_1 = __importDefault(require("./e3/MideaE3Device"));
11
+ const MideaFADevice_1 = __importDefault(require("./fa/MideaFADevice"));
12
+ const MideaDBDevice_1 = __importDefault(require("./db/MideaDBDevice"));
13
+ const MideaE1Device_1 = __importDefault(require("./e1/MideaE1Device"));
14
+ class DeviceFactory {
15
+ static createDevice(logger, device_info, config, deviceConfig) {
16
+ switch (device_info.type) {
17
+ case MideaConstants_1.DeviceType.DEHUMIDIFIER:
18
+ return new MideaA1Device_1.default(logger, device_info, config, deviceConfig);
19
+ case MideaConstants_1.DeviceType.AIR_CONDITIONER:
20
+ return new MideaACDevice_1.default(logger, device_info, config, deviceConfig);
21
+ case MideaConstants_1.DeviceType.FRONT_LOAD_WASHER:
22
+ return new MideaDBDevice_1.default(logger, device_info, config, deviceConfig);
23
+ case MideaConstants_1.DeviceType.DISHWASHER:
24
+ return new MideaE1Device_1.default(logger, device_info, config, deviceConfig);
25
+ case MideaConstants_1.DeviceType.ELECTRIC_WATER_HEATER:
26
+ return new MideaE2Device_1.default(logger, device_info, config, deviceConfig);
27
+ case MideaConstants_1.DeviceType.GAS_WATER_HEATER:
28
+ return new MideaE3Device_1.default(logger, device_info, config, deviceConfig);
29
+ case MideaConstants_1.DeviceType.FAN:
30
+ return new MideaFADevice_1.default(logger, device_info, config, deviceConfig);
31
+ case MideaConstants_1.DeviceType.UNKNOWN:
32
+ default:
33
+ return null;
34
+ }
35
+ }
36
+ }
37
+ exports.default = DeviceFactory;
37
38
  //# sourceMappingURL=DeviceFactory.js.map
@@ -1 +1 @@
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xB;gBACE,OAAO,IAAI,CAAC;SACf;IACH,CAAC;CACF;AAtBD,gCAsBC"}
@@ -1,77 +1,77 @@
1
- /// <reference types="node" />
2
- /***********************************************************************
3
- * Midea Dehumidifier Device class
4
- *
5
- * Copyright (c) 2023 David Kerr, https://github.com/dkerr64
6
- *
7
- * With thanks to https://github.com/kovapatrik/homebridge-midea-platform
8
- * And https://github.com/georgezhao2010/midea_ac_lan
9
- *
10
- * An instance of this class is created for each device the platform registers.
11
- *
12
- */
13
- import { Logger } from 'homebridge';
14
- import { DeviceInfo } from '../../core/MideaConstants';
15
- import MideaDevice, { DeviceAttributeBase } from '../../core/MideaDevice';
16
- import { MessageQuery, MessageSet } from './MideaA1Message';
17
- import { Config, DeviceConfig } from '../../platformUtils';
18
- export interface A1Attributes extends DeviceAttributeBase {
19
- POWER: boolean | undefined;
20
- PROMPT_TONE: boolean;
21
- CHILD_LOCK: boolean | undefined;
22
- MODE: number;
23
- FAN_SPEED: number;
24
- SWING: boolean | undefined;
25
- TARGET_HUMIDITY: number;
26
- ANION: boolean;
27
- TANK_LEVEL: number;
28
- WATER_LEVEL_SET: number;
29
- TANK_FULL: boolean;
30
- CURRENT_HUMIDITY: number;
31
- CURRENT_TEMPERATURE: number;
32
- DEFROSTING: boolean;
33
- FILTER_INDICATOR: boolean;
34
- PUMP: boolean;
35
- PUMP_SWITCH_FLAG: boolean;
36
- SLEEP_MODE: boolean;
37
- }
38
- export default class MideaA1Device extends MideaDevice {
39
- readonly MIN_HUMIDITY: number;
40
- readonly MAX_HUMIDITY: number;
41
- readonly HUMIDITY_STEP: number;
42
- attributes: A1Attributes;
43
- readonly MODES: {
44
- 0: string;
45
- 1: string;
46
- 2: string;
47
- 3: string;
48
- 4: string;
49
- };
50
- readonly SPEEDS: {
51
- 1: string;
52
- 40: string;
53
- 60: string;
54
- 80: string;
55
- 102: string;
56
- 127: string;
57
- };
58
- readonly WATER_LEVEL_SETS: {
59
- 25: string;
60
- 50: string;
61
- 75: string;
62
- 100: string;
63
- };
64
- /*********************************************************************
65
- * Constructor initializes all the attributes. We set some to invalid
66
- * values so that they are detected as "changed" on the first status
67
- * refresh... and passed back to the Homebridge/HomeKit accessory callback
68
- * function to set their initial values.
69
- */
70
- constructor(logger: Logger, device_info: DeviceInfo, config: Config, deviceConfig: DeviceConfig);
71
- build_query(): MessageQuery[];
72
- process_message(msg: Buffer): void;
73
- make_message_set(): MessageSet;
74
- set_attribute(attributes: Partial<A1Attributes>): Promise<void>;
75
- protected set_subtype(): void;
76
- }
1
+ /// <reference types="node" />
2
+ /***********************************************************************
3
+ * Midea Dehumidifier Device class
4
+ *
5
+ * Copyright (c) 2023 David Kerr, https://github.com/dkerr64
6
+ *
7
+ * With thanks to https://github.com/kovapatrik/homebridge-midea-platform
8
+ * And https://github.com/georgezhao2010/midea_ac_lan
9
+ *
10
+ * An instance of this class is created for each device the platform registers.
11
+ *
12
+ */
13
+ import { Logger } from 'homebridge';
14
+ import { DeviceInfo } from '../../core/MideaConstants';
15
+ import MideaDevice, { DeviceAttributeBase } from '../../core/MideaDevice';
16
+ import { MessageQuery, MessageSet } from './MideaA1Message';
17
+ import { Config, DeviceConfig } from '../../platformUtils';
18
+ export interface A1Attributes extends DeviceAttributeBase {
19
+ POWER: boolean | undefined;
20
+ PROMPT_TONE: boolean;
21
+ CHILD_LOCK: boolean | undefined;
22
+ MODE: number;
23
+ FAN_SPEED: number;
24
+ SWING: boolean | undefined;
25
+ TARGET_HUMIDITY: number;
26
+ ANION: boolean;
27
+ TANK_LEVEL: number;
28
+ WATER_LEVEL_SET: number;
29
+ TANK_FULL: boolean;
30
+ CURRENT_HUMIDITY: number;
31
+ CURRENT_TEMPERATURE: number;
32
+ DEFROSTING: boolean;
33
+ FILTER_INDICATOR: boolean;
34
+ PUMP: boolean;
35
+ PUMP_SWITCH_FLAG: boolean;
36
+ SLEEP_MODE: boolean;
37
+ }
38
+ export default class MideaA1Device extends MideaDevice {
39
+ readonly MIN_HUMIDITY: number;
40
+ readonly MAX_HUMIDITY: number;
41
+ readonly HUMIDITY_STEP: number;
42
+ attributes: A1Attributes;
43
+ readonly MODES: {
44
+ 0: string;
45
+ 1: string;
46
+ 2: string;
47
+ 3: string;
48
+ 4: string;
49
+ };
50
+ readonly SPEEDS: {
51
+ 1: string;
52
+ 40: string;
53
+ 60: string;
54
+ 80: string;
55
+ 102: string;
56
+ 127: string;
57
+ };
58
+ readonly WATER_LEVEL_SETS: {
59
+ 25: string;
60
+ 50: string;
61
+ 75: string;
62
+ 100: string;
63
+ };
64
+ /*********************************************************************
65
+ * Constructor initializes all the attributes. We set some to invalid
66
+ * values so that they are detected as "changed" on the first status
67
+ * refresh... and passed back to the Homebridge/HomeKit accessory callback
68
+ * function to set their initial values.
69
+ */
70
+ constructor(logger: Logger, device_info: DeviceInfo, config: Config, deviceConfig: DeviceConfig);
71
+ build_query(): MessageQuery[];
72
+ process_message(msg: Buffer): void;
73
+ make_message_set(): MessageSet;
74
+ set_attribute(attributes: Partial<A1Attributes>): Promise<void>;
75
+ protected set_subtype(): void;
76
+ }
77
77
  //# sourceMappingURL=MideaA1Device.d.ts.map