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,146 +1,146 @@
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 MideaDevice_1 = __importDefault(require("../../core/MideaDevice"));
7
- const MideaA1Message_1 = require("./MideaA1Message");
8
- class MideaA1Device extends MideaDevice_1.default {
9
- /*********************************************************************
10
- * Constructor initializes all the attributes. We set some to invalid
11
- * values so that they are detected as "changed" on the first status
12
- * refresh... and passed back to the Homebridge/HomeKit accessory callback
13
- * function to set their initial values.
14
- */
15
- constructor(logger, device_info, config, deviceConfig) {
16
- super(logger, device_info, config, deviceConfig);
17
- this.MODES = {
18
- 0: 'Off',
19
- 1: 'Auto',
20
- 2: 'Continuous',
21
- 3: 'Clothes-Dry',
22
- 4: 'Shoes-Dry',
23
- };
24
- this.SPEEDS = {
25
- 1: 'Lowest',
26
- 40: 'Low',
27
- 60: 'Medium',
28
- 80: 'High',
29
- 102: 'Auto',
30
- 127: 'Off',
31
- };
32
- this.WATER_LEVEL_SETS = {
33
- 25: 'Low',
34
- 50: 'Medium',
35
- 75: 'High',
36
- 100: 'Full',
37
- };
38
- this.attributes = {
39
- POWER: undefined,
40
- PROMPT_TONE: false,
41
- CHILD_LOCK: undefined,
42
- MODE: 0,
43
- FAN_SPEED: 0,
44
- SWING: undefined,
45
- TARGET_HUMIDITY: 0,
46
- ANION: false,
47
- TANK_LEVEL: 0,
48
- WATER_LEVEL_SET: 50,
49
- TANK_FULL: false,
50
- CURRENT_HUMIDITY: 0,
51
- CURRENT_TEMPERATURE: 0,
52
- DEFROSTING: false,
53
- FILTER_INDICATOR: false,
54
- PUMP: false,
55
- PUMP_SWITCH_FLAG: false,
56
- SLEEP_MODE: false,
57
- };
58
- this.MIN_HUMIDITY = deviceConfig.A1_options.minHumidity;
59
- this.MAX_HUMIDITY = deviceConfig.A1_options.maxHumidity;
60
- this.HUMIDITY_STEP = deviceConfig.A1_options.humidityStep;
61
- }
62
- build_query() {
63
- return [new MideaA1Message_1.MessageQuery(this.device_protocol_version)];
64
- }
65
- process_message(msg) {
66
- const message = new MideaA1Message_1.MessageA1Response(msg);
67
- if (this.verbose) {
68
- this.logger.debug(`[${this.name}] Body:\n${JSON.stringify(message.body)}`);
69
- }
70
- const changed = {};
71
- for (const status of Object.keys(this.attributes)) {
72
- const value = message.get_body_attribute(status.toLowerCase());
73
- if (value !== undefined) {
74
- if (this.attributes[status] !== value) {
75
- // Track only those attributes that change value. So when we send to the Homebridge /
76
- // HomeKit accessory we only update values that change. First time through this
77
- // should be most/all attributes having initialized them to invalid values.
78
- this.logger.debug(`[${this.name}] Value for ${status} changed from '${this.attributes[status]}' to '${value}'`);
79
- changed[status] = value;
80
- }
81
- this.attributes[status] = value;
82
- }
83
- }
84
- // Now we update Homebridge / Homekit accessory
85
- if (Object.keys(changed).length > 0) {
86
- this.update(changed);
87
- }
88
- else {
89
- this.logger.debug(`[${this.name}] Status unchanged`);
90
- }
91
- }
92
- make_message_set() {
93
- const message = new MideaA1Message_1.MessageSet(this.device_protocol_version);
94
- message.power = !!this.attributes.POWER; // force to boolean
95
- message.prompt_tone = this.attributes.PROMPT_TONE;
96
- message.mode = this.attributes.MODE;
97
- message.child_lock = !!this.attributes.CHILD_LOCK; // force to boolean
98
- message.fan_speed = this.attributes.FAN_SPEED;
99
- message.target_humidity = this.attributes.TARGET_HUMIDITY;
100
- message.swing = !!this.attributes.SWING;
101
- message.anion = this.attributes.ANION;
102
- message.water_level_set = this.attributes.WATER_LEVEL_SET;
103
- return message;
104
- }
105
- async set_attribute(attributes) {
106
- var _a;
107
- const messageToSend = {
108
- SET: undefined,
109
- };
110
- try {
111
- for (const [k, v] of Object.entries(attributes)) {
112
- if (v === this.attributes[k]) {
113
- this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
114
- continue;
115
- }
116
- this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
117
- this.attributes[k] = v;
118
- // not sensor data
119
- if (!['CURRENT_TEMPERATURE', 'CURRENT_HUMIDITY', 'TANK_FULL', 'DEFROSTING', 'FILTER_INDICATOR', 'PUMP'].includes(k)) {
120
- if (k === 'PROMPT_TONE') {
121
- this.attributes.PROMPT_TONE = !!v;
122
- }
123
- else {
124
- (_a = messageToSend.SET) !== null && _a !== void 0 ? _a : (messageToSend.SET = this.make_message_set());
125
- // TODO handle MODE, FAN_SPEED and WATER_LEVEL_SET to ensure valid value.
126
- }
127
- }
128
- }
129
- for (const [k, v] of Object.entries(messageToSend)) {
130
- if (v !== undefined) {
131
- this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
132
- await this.build_send(v);
133
- }
134
- }
135
- }
136
- catch (err) {
137
- const msg = err instanceof Error ? err.stack : err;
138
- this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
139
- }
140
- }
141
- set_subtype() {
142
- this.logger.debug('No subtype for A1 (dehumidifier) device');
143
- }
144
- }
145
- exports.default = MideaA1Device;
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 MideaDevice_1 = __importDefault(require("../../core/MideaDevice"));
7
+ const MideaA1Message_1 = require("./MideaA1Message");
8
+ class MideaA1Device extends MideaDevice_1.default {
9
+ /*********************************************************************
10
+ * Constructor initializes all the attributes. We set some to invalid
11
+ * values so that they are detected as "changed" on the first status
12
+ * refresh... and passed back to the Homebridge/HomeKit accessory callback
13
+ * function to set their initial values.
14
+ */
15
+ constructor(logger, device_info, config, deviceConfig) {
16
+ super(logger, device_info, config, deviceConfig);
17
+ this.MODES = {
18
+ 0: 'Off',
19
+ 1: 'Auto',
20
+ 2: 'Continuous',
21
+ 3: 'Clothes-Dry',
22
+ 4: 'Shoes-Dry',
23
+ };
24
+ this.SPEEDS = {
25
+ 1: 'Lowest',
26
+ 40: 'Low',
27
+ 60: 'Medium',
28
+ 80: 'High',
29
+ 102: 'Auto',
30
+ 127: 'Off',
31
+ };
32
+ this.WATER_LEVEL_SETS = {
33
+ 25: 'Low',
34
+ 50: 'Medium',
35
+ 75: 'High',
36
+ 100: 'Full',
37
+ };
38
+ this.attributes = {
39
+ POWER: undefined,
40
+ PROMPT_TONE: false,
41
+ CHILD_LOCK: undefined,
42
+ MODE: 0,
43
+ FAN_SPEED: 0,
44
+ SWING: undefined,
45
+ TARGET_HUMIDITY: 0,
46
+ ANION: false,
47
+ TANK_LEVEL: 0,
48
+ WATER_LEVEL_SET: 50,
49
+ TANK_FULL: false,
50
+ CURRENT_HUMIDITY: 0,
51
+ CURRENT_TEMPERATURE: 0,
52
+ DEFROSTING: false,
53
+ FILTER_INDICATOR: false,
54
+ PUMP: false,
55
+ PUMP_SWITCH_FLAG: false,
56
+ SLEEP_MODE: false,
57
+ };
58
+ this.MIN_HUMIDITY = deviceConfig.A1_options.minHumidity;
59
+ this.MAX_HUMIDITY = deviceConfig.A1_options.maxHumidity;
60
+ this.HUMIDITY_STEP = deviceConfig.A1_options.humidityStep;
61
+ }
62
+ build_query() {
63
+ return [new MideaA1Message_1.MessageQuery(this.device_protocol_version)];
64
+ }
65
+ process_message(msg) {
66
+ const message = new MideaA1Message_1.MessageA1Response(msg);
67
+ if (this.verbose) {
68
+ this.logger.debug(`[${this.name}] Body:\n${JSON.stringify(message.body)}`);
69
+ }
70
+ const changed = {};
71
+ for (const status of Object.keys(this.attributes)) {
72
+ const value = message.get_body_attribute(status.toLowerCase());
73
+ if (value !== undefined) {
74
+ if (this.attributes[status] !== value) {
75
+ // Track only those attributes that change value. So when we send to the Homebridge /
76
+ // HomeKit accessory we only update values that change. First time through this
77
+ // should be most/all attributes having initialized them to invalid values.
78
+ this.logger.debug(`[${this.name}] Value for ${status} changed from '${this.attributes[status]}' to '${value}'`);
79
+ changed[status] = value;
80
+ }
81
+ this.attributes[status] = value;
82
+ }
83
+ }
84
+ // Now we update Homebridge / Homekit accessory
85
+ if (Object.keys(changed).length > 0) {
86
+ this.update(changed);
87
+ }
88
+ else {
89
+ this.logger.debug(`[${this.name}] Status unchanged`);
90
+ }
91
+ }
92
+ make_message_set() {
93
+ const message = new MideaA1Message_1.MessageSet(this.device_protocol_version);
94
+ message.power = !!this.attributes.POWER; // force to boolean
95
+ message.prompt_tone = this.attributes.PROMPT_TONE;
96
+ message.mode = this.attributes.MODE;
97
+ message.child_lock = !!this.attributes.CHILD_LOCK; // force to boolean
98
+ message.fan_speed = this.attributes.FAN_SPEED;
99
+ message.target_humidity = this.attributes.TARGET_HUMIDITY;
100
+ message.swing = !!this.attributes.SWING;
101
+ message.anion = this.attributes.ANION;
102
+ message.water_level_set = this.attributes.WATER_LEVEL_SET;
103
+ return message;
104
+ }
105
+ async set_attribute(attributes) {
106
+ var _a;
107
+ const messageToSend = {
108
+ SET: undefined,
109
+ };
110
+ try {
111
+ for (const [k, v] of Object.entries(attributes)) {
112
+ if (v === this.attributes[k]) {
113
+ this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
114
+ continue;
115
+ }
116
+ this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
117
+ this.attributes[k] = v;
118
+ // not sensor data
119
+ if (!['CURRENT_TEMPERATURE', 'CURRENT_HUMIDITY', 'TANK_FULL', 'DEFROSTING', 'FILTER_INDICATOR', 'PUMP'].includes(k)) {
120
+ if (k === 'PROMPT_TONE') {
121
+ this.attributes.PROMPT_TONE = !!v;
122
+ }
123
+ else {
124
+ (_a = messageToSend.SET) !== null && _a !== void 0 ? _a : (messageToSend.SET = this.make_message_set());
125
+ // TODO handle MODE, FAN_SPEED and WATER_LEVEL_SET to ensure valid value.
126
+ }
127
+ }
128
+ }
129
+ for (const [k, v] of Object.entries(messageToSend)) {
130
+ if (v !== undefined) {
131
+ this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
132
+ await this.build_send(v);
133
+ }
134
+ }
135
+ }
136
+ catch (err) {
137
+ const msg = err instanceof Error ? err.stack : err;
138
+ this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
139
+ }
140
+ }
141
+ set_subtype() {
142
+ this.logger.debug('No subtype for A1 (dehumidifier) device');
143
+ }
144
+ }
145
+ exports.default = MideaA1Device;
146
146
  //# sourceMappingURL=MideaA1Device.js.map
@@ -1,41 +1,41 @@
1
- /// <reference types="node" />
2
- import { MessageRequest, MessageResponse, MessageType } from '../../core/MideaMessage';
3
- declare abstract class MessageA1Base extends MessageRequest {
4
- private static message_serial;
5
- private message_id;
6
- constructor(device_protocol_version: number, message_type: MessageType, body_type: number);
7
- get body(): Buffer;
8
- }
9
- export declare class MessageQuery extends MessageA1Base {
10
- constructor(device_protocol_version: number);
11
- get _body(): Buffer;
12
- }
13
- export declare class MessageNewProtocolQuery extends MessageA1Base {
14
- private readonly alternate_display;
15
- constructor(device_protocol_version: number, alternate_display?: boolean);
16
- get _body(): Buffer;
17
- }
18
- export declare class MessageSet extends MessageA1Base {
19
- power: boolean;
20
- prompt_tone: boolean;
21
- mode: number;
22
- fan_speed: number;
23
- child_lock: boolean;
24
- target_humidity: number;
25
- swing: boolean;
26
- anion: boolean;
27
- water_level_set: number;
28
- constructor(device_protocol_version: number);
29
- get _body(): Buffer;
30
- }
31
- export declare class MessageNewProtocolSet extends MessageA1Base {
32
- light: boolean;
33
- constructor(device_protocol_version: number);
34
- get _body(): Buffer;
35
- }
36
- export declare class MessageA1Response extends MessageResponse {
37
- private readonly message;
38
- constructor(message: Buffer);
39
- }
40
- export {};
1
+ /// <reference types="node" />
2
+ import { MessageRequest, MessageResponse, MessageType } from '../../core/MideaMessage';
3
+ declare abstract class MessageA1Base extends MessageRequest {
4
+ private static message_serial;
5
+ private message_id;
6
+ constructor(device_protocol_version: number, message_type: MessageType, body_type: number);
7
+ get body(): Buffer;
8
+ }
9
+ export declare class MessageQuery extends MessageA1Base {
10
+ constructor(device_protocol_version: number);
11
+ get _body(): Buffer;
12
+ }
13
+ export declare class MessageNewProtocolQuery extends MessageA1Base {
14
+ private readonly alternate_display;
15
+ constructor(device_protocol_version: number, alternate_display?: boolean);
16
+ get _body(): Buffer;
17
+ }
18
+ export declare class MessageSet extends MessageA1Base {
19
+ power: boolean;
20
+ prompt_tone: boolean;
21
+ mode: number;
22
+ fan_speed: number;
23
+ child_lock: boolean;
24
+ target_humidity: number;
25
+ swing: boolean;
26
+ anion: boolean;
27
+ water_level_set: number;
28
+ constructor(device_protocol_version: number);
29
+ get _body(): Buffer;
30
+ }
31
+ export declare class MessageNewProtocolSet extends MessageA1Base {
32
+ light: boolean;
33
+ constructor(device_protocol_version: number);
34
+ get _body(): Buffer;
35
+ }
36
+ export declare class MessageA1Response extends MessageResponse {
37
+ private readonly message;
38
+ constructor(message: Buffer);
39
+ }
40
+ export {};
41
41
  //# sourceMappingURL=MideaA1Message.d.ts.map