homebridge-midea-platform 1.1.2-beta.1 → 1.1.2-beta.10

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 (95) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/AC_ori.lua +5150 -0
  3. package/CHANGELOG.md +9 -1
  4. package/README.md +1 -0
  5. package/config.schema.json +26 -56
  6. package/dist/accessory/AccessoryFactory.d.ts +12 -11
  7. package/dist/accessory/AccessoryFactory.d.ts.map +1 -1
  8. package/dist/accessory/AccessoryFactory.js +31 -28
  9. package/dist/accessory/AccessoryFactory.js.map +1 -1
  10. package/dist/accessory/AirConditionerAccessory.d.ts +89 -86
  11. package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
  12. package/dist/accessory/AirConditionerAccessory.js +584 -560
  13. package/dist/accessory/AirConditionerAccessory.js.map +1 -1
  14. package/dist/accessory/BaseAccessory.d.ts +11 -11
  15. package/dist/accessory/BaseAccessory.js +21 -21
  16. package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
  17. package/dist/accessory/DehumidifierAccessory.d.ts.map +1 -1
  18. package/dist/accessory/DehumidifierAccessory.js +345 -343
  19. package/dist/accessory/DehumidifierAccessory.js.map +1 -1
  20. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
  21. package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
  22. package/dist/accessory/FanAccessory.d.ts +39 -39
  23. package/dist/accessory/FanAccessory.js +123 -123
  24. package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -30
  25. package/dist/accessory/FrontLoadWasherAccessory.js +60 -60
  26. package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
  27. package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
  28. package/dist/core/MideaCloud.d.ts +35 -35
  29. package/dist/core/MideaCloud.js +350 -350
  30. package/dist/core/MideaConstants.d.ts +49 -49
  31. package/dist/core/MideaConstants.js +57 -57
  32. package/dist/core/MideaDevice.d.ts +76 -76
  33. package/dist/core/MideaDevice.js +409 -409
  34. package/dist/core/MideaDiscover.d.ts +35 -35
  35. package/dist/core/MideaDiscover.js +212 -212
  36. package/dist/core/MideaMessage.d.ts +75 -75
  37. package/dist/core/MideaMessage.js +184 -184
  38. package/dist/core/MideaPacketBuilder.d.ts +10 -10
  39. package/dist/core/MideaPacketBuilder.js +60 -60
  40. package/dist/core/MideaSecurity.d.ts +63 -63
  41. package/dist/core/MideaSecurity.d.ts.map +1 -1
  42. package/dist/core/MideaSecurity.js +251 -242
  43. package/dist/core/MideaSecurity.js.map +1 -1
  44. package/dist/core/MideaUtils.d.ts +32 -32
  45. package/dist/core/MideaUtils.js +181 -181
  46. package/dist/devices/DeviceFactory.d.ts +12 -11
  47. package/dist/devices/DeviceFactory.d.ts.map +1 -1
  48. package/dist/devices/DeviceFactory.js +33 -30
  49. package/dist/devices/DeviceFactory.js.map +1 -1
  50. package/dist/devices/a1/MideaA1Device.d.ts +76 -76
  51. package/dist/devices/a1/MideaA1Device.js +136 -136
  52. package/dist/devices/a1/MideaA1Message.d.ts +40 -40
  53. package/dist/devices/a1/MideaA1Message.js +198 -198
  54. package/dist/devices/ac/MideaACDevice.d.ts +100 -100
  55. package/dist/devices/ac/MideaACDevice.d.ts.map +1 -1
  56. package/dist/devices/ac/MideaACDevice.js +381 -370
  57. package/dist/devices/ac/MideaACDevice.js.map +1 -1
  58. package/dist/devices/ac/MideaACMessage.d.ts +92 -92
  59. package/dist/devices/ac/MideaACMessage.js +589 -589
  60. package/dist/devices/db/MideaDBDevice.d.ts +29 -29
  61. package/dist/devices/db/MideaDBDevice.d.ts.map +1 -1
  62. package/dist/devices/db/MideaDBDevice.js +89 -88
  63. package/dist/devices/db/MideaDBDevice.js.map +1 -1
  64. package/dist/devices/db/MideaDBMessage.d.ts +32 -32
  65. package/dist/devices/db/MideaDBMessage.d.ts.map +1 -1
  66. package/dist/devices/db/MideaDBMessage.js +101 -101
  67. package/dist/devices/db/MideaDBMessage.js.map +1 -1
  68. package/dist/devices/e2/MideaE2Device.d.ts +44 -44
  69. package/dist/devices/e2/MideaE2Device.js +119 -119
  70. package/dist/devices/e2/MideaE2Message.d.ts +33 -33
  71. package/dist/devices/e2/MideaE2Message.js +132 -132
  72. package/dist/devices/e3/MideaE3Device.d.ts +43 -43
  73. package/dist/devices/e3/MideaE3Device.js +125 -125
  74. package/dist/devices/e3/MideaE3Message.d.ts +51 -51
  75. package/dist/devices/e3/MideaE3Message.js +136 -136
  76. package/dist/devices/fa/MideaFADevice.d.ts +36 -36
  77. package/dist/devices/fa/MideaFADevice.js +92 -92
  78. package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
  79. package/dist/devices/fa/MideaFAMessage.js +98 -98
  80. package/dist/index.d.ts +6 -6
  81. package/dist/index.js +6 -6
  82. package/dist/platform.d.ts +60 -60
  83. package/dist/platform.d.ts.map +1 -1
  84. package/dist/platform.js +212 -213
  85. package/dist/platform.js.map +1 -1
  86. package/dist/platformUtils.d.ts +99 -97
  87. package/dist/platformUtils.d.ts.map +1 -1
  88. package/dist/platformUtils.js +97 -95
  89. package/dist/platformUtils.js.map +1 -1
  90. package/dist/settings.d.ts +8 -8
  91. package/dist/settings.js +11 -11
  92. package/docs/ac.md +2 -0
  93. package/docs/db.md +3 -0
  94. package/homebridge-ui/server.js +30 -26
  95. 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