homebridge-midea-platform 1.1.0-beta.4 → 1.1.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.
Files changed (72) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/CHANGELOG.md +3 -0
  3. package/config.schema.json +8 -1
  4. package/dist/accessory/AccessoryFactory.d.ts +11 -11
  5. package/dist/accessory/AccessoryFactory.js +28 -28
  6. package/dist/accessory/AirConditionerAccessory.d.ts +86 -86
  7. package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
  8. package/dist/accessory/AirConditionerAccessory.js +560 -561
  9. package/dist/accessory/AirConditionerAccessory.js.map +1 -1
  10. package/dist/accessory/BaseAccessory.d.ts +11 -11
  11. package/dist/accessory/BaseAccessory.js +21 -21
  12. package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
  13. package/dist/accessory/DehumidifierAccessory.js +343 -343
  14. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
  15. package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
  16. package/dist/accessory/FanAccessory.d.ts +39 -39
  17. package/dist/accessory/FanAccessory.js +123 -123
  18. package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
  19. package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
  20. package/dist/core/MideaCloud.d.ts +35 -35
  21. package/dist/core/MideaCloud.js +350 -350
  22. package/dist/core/MideaConstants.d.ts +48 -48
  23. package/dist/core/MideaConstants.js +56 -56
  24. package/dist/core/MideaDevice.d.ts +76 -76
  25. package/dist/core/MideaDevice.js +409 -409
  26. package/dist/core/MideaDiscover.d.ts +35 -35
  27. package/dist/core/MideaDiscover.js +212 -212
  28. package/dist/core/MideaMessage.d.ts +75 -75
  29. package/dist/core/MideaMessage.js +184 -184
  30. package/dist/core/MideaPacketBuilder.d.ts +10 -10
  31. package/dist/core/MideaPacketBuilder.js +60 -60
  32. package/dist/core/MideaSecurity.d.ts +63 -63
  33. package/dist/core/MideaSecurity.js +242 -242
  34. package/dist/core/MideaUtils.d.ts +32 -32
  35. package/dist/core/MideaUtils.js +181 -181
  36. package/dist/devices/DeviceFactory.d.ts +11 -11
  37. package/dist/devices/DeviceFactory.js +30 -30
  38. package/dist/devices/a1/MideaA1Device.d.ts +76 -76
  39. package/dist/devices/a1/MideaA1Device.js +136 -136
  40. package/dist/devices/a1/MideaA1Message.d.ts +40 -40
  41. package/dist/devices/a1/MideaA1Message.js +198 -198
  42. package/dist/devices/ac/MideaACDevice.d.ts +100 -98
  43. package/dist/devices/ac/MideaACDevice.d.ts.map +1 -1
  44. package/dist/devices/ac/MideaACDevice.js +370 -357
  45. package/dist/devices/ac/MideaACDevice.js.map +1 -1
  46. package/dist/devices/ac/MideaACMessage.d.ts +92 -92
  47. package/dist/devices/ac/MideaACMessage.js +589 -589
  48. package/dist/devices/e2/MideaE2Device.d.ts +44 -44
  49. package/dist/devices/e2/MideaE2Device.js +119 -119
  50. package/dist/devices/e2/MideaE2Message.d.ts +33 -33
  51. package/dist/devices/e2/MideaE2Message.js +132 -132
  52. package/dist/devices/e3/MideaE3Device.d.ts +43 -43
  53. package/dist/devices/e3/MideaE3Device.js +125 -125
  54. package/dist/devices/e3/MideaE3Message.d.ts +51 -51
  55. package/dist/devices/e3/MideaE3Message.js +136 -136
  56. package/dist/devices/fa/MideaFADevice.d.ts +36 -36
  57. package/dist/devices/fa/MideaFADevice.js +92 -92
  58. package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
  59. package/dist/devices/fa/MideaFAMessage.js +98 -98
  60. package/dist/index.d.ts +6 -6
  61. package/dist/index.js +6 -6
  62. package/dist/platform.d.ts +60 -60
  63. package/dist/platform.js +213 -213
  64. package/dist/platformUtils.d.ts +97 -96
  65. package/dist/platformUtils.d.ts.map +1 -1
  66. package/dist/platformUtils.js +95 -94
  67. package/dist/platformUtils.js.map +1 -1
  68. package/dist/settings.d.ts +8 -8
  69. package/dist/settings.js +11 -11
  70. package/docs/ac.md +2 -0
  71. package/docs/fa.md +3 -0
  72. package/package.json +1 -1
@@ -1,137 +1,137 @@
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
- try {
107
- for (const [k, v] of Object.entries(attributes)) {
108
- let message = undefined;
109
- this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
110
- // not sensor data
111
- if (!['CURRENT_TEMPERATURE', 'CURRENT_HUMIDITY', 'TANK_FULL', 'DEFROSTING', 'FILTER_INDICATOR', 'PUMP'].includes(k)) {
112
- this.attributes[k] = v;
113
- if (k === 'PROMPT_TONE') {
114
- this.attributes.PROMPT_TONE = !!v;
115
- }
116
- else {
117
- message = this.make_message_set();
118
- // TODO handle MODE, FAN_SPEED and WATER_LEVEL_SET to ensure valid value.
119
- }
120
- }
121
- if (message) {
122
- this.logger.debug(`[${this.name}] Set message:\n${JSON.stringify(message)}`);
123
- await this.build_send(message);
124
- }
125
- }
126
- }
127
- catch (err) {
128
- const msg = err instanceof Error ? err.stack : err;
129
- this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
130
- }
131
- }
132
- set_subtype() {
133
- this.logger.debug('No subtype for A1 (dehumidifier) device');
134
- }
135
- }
136
- 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
+ try {
107
+ for (const [k, v] of Object.entries(attributes)) {
108
+ let message = undefined;
109
+ this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
110
+ // not sensor data
111
+ if (!['CURRENT_TEMPERATURE', 'CURRENT_HUMIDITY', 'TANK_FULL', 'DEFROSTING', 'FILTER_INDICATOR', 'PUMP'].includes(k)) {
112
+ this.attributes[k] = v;
113
+ if (k === 'PROMPT_TONE') {
114
+ this.attributes.PROMPT_TONE = !!v;
115
+ }
116
+ else {
117
+ message = this.make_message_set();
118
+ // TODO handle MODE, FAN_SPEED and WATER_LEVEL_SET to ensure valid value.
119
+ }
120
+ }
121
+ if (message) {
122
+ this.logger.debug(`[${this.name}] Set message:\n${JSON.stringify(message)}`);
123
+ await this.build_send(message);
124
+ }
125
+ }
126
+ }
127
+ catch (err) {
128
+ const msg = err instanceof Error ? err.stack : err;
129
+ this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
130
+ }
131
+ }
132
+ set_subtype() {
133
+ this.logger.debug('No subtype for A1 (dehumidifier) device');
134
+ }
135
+ }
136
+ exports.default = MideaA1Device;
137
137
  //# 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