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.
- package/.husky/pre-commit +0 -0
- package/AC_ori.lua +5140 -0
- package/config.schema.json +14 -2
- package/dist/accessory/AccessoryFactory.d.ts +13 -12
- package/dist/accessory/AccessoryFactory.d.ts.map +1 -1
- package/dist/accessory/AccessoryFactory.js +37 -31
- package/dist/accessory/AccessoryFactory.js.map +1 -1
- package/dist/accessory/AirConditionerAccessory.d.ts +98 -92
- package/dist/accessory/AirConditionerAccessory.d.ts.map +1 -1
- package/dist/accessory/AirConditionerAccessory.js +662 -607
- package/dist/accessory/AirConditionerAccessory.js.map +1 -1
- package/dist/accessory/BaseAccessory.d.ts +11 -11
- package/dist/accessory/BaseAccessory.js +21 -21
- package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
- package/dist/accessory/DehumidifierAccessory.js +344 -344
- package/dist/accessory/DishwasherAccessory.d.ts +30 -30
- package/dist/accessory/DishwasherAccessory.js +63 -63
- package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
- package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
- package/dist/accessory/FanAccessory.d.ts +39 -39
- package/dist/accessory/FanAccessory.js +123 -123
- package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -30
- package/dist/accessory/FrontLoadWasherAccessory.js +66 -66
- package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
- package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
- package/dist/core/MideaCloud.d.ts +35 -35
- package/dist/core/MideaCloud.js +350 -350
- package/dist/core/MideaConstants.d.ts +50 -50
- package/dist/core/MideaConstants.js +58 -58
- package/dist/core/MideaDevice.d.ts +76 -76
- package/dist/core/MideaDevice.js +409 -409
- package/dist/core/MideaDiscover.d.ts +35 -35
- package/dist/core/MideaDiscover.js +212 -212
- package/dist/core/MideaMessage.d.ts +75 -75
- package/dist/core/MideaMessage.js +184 -184
- package/dist/core/MideaPacketBuilder.d.ts +10 -10
- package/dist/core/MideaPacketBuilder.js +60 -60
- package/dist/core/MideaSecurity.d.ts +63 -63
- package/dist/core/MideaSecurity.js +251 -251
- package/dist/core/MideaUtils.d.ts +32 -32
- package/dist/core/MideaUtils.js +181 -181
- package/dist/devices/DeviceFactory.d.ts +13 -13
- package/dist/devices/DeviceFactory.d.ts.map +1 -1
- package/dist/devices/DeviceFactory.js +37 -36
- package/dist/devices/DeviceFactory.js.map +1 -1
- package/dist/devices/a1/MideaA1Device.d.ts +76 -76
- package/dist/devices/a1/MideaA1Device.js +145 -145
- package/dist/devices/a1/MideaA1Message.d.ts +40 -40
- package/dist/devices/a1/MideaA1Message.js +198 -198
- package/dist/devices/ac/MideaACDevice.d.ts +106 -104
- package/dist/devices/ac/MideaACDevice.d.ts.map +1 -1
- package/dist/devices/ac/MideaACDevice.js +400 -384
- package/dist/devices/ac/MideaACDevice.js.map +1 -1
- package/dist/devices/ac/MideaACMessage.d.ts +95 -94
- package/dist/devices/ac/MideaACMessage.d.ts.map +1 -1
- package/dist/devices/ac/MideaACMessage.js +619 -611
- package/dist/devices/ac/MideaACMessage.js.map +1 -1
- package/dist/devices/db/MideaDBDevice.d.ts +29 -29
- package/dist/devices/db/MideaDBDevice.js +100 -100
- package/dist/devices/db/MideaDBMessage.d.ts +32 -32
- package/dist/devices/db/MideaDBMessage.js +101 -101
- package/dist/devices/e1/MideaE1Device.d.ts +56 -56
- package/dist/devices/e1/MideaE1Device.js +128 -128
- package/dist/devices/e1/MideaE1Message.d.ts +28 -28
- package/dist/devices/e1/MideaE1Message.js +107 -107
- package/dist/devices/e2/MideaE2Device.d.ts +44 -44
- package/dist/devices/e2/MideaE2Device.js +129 -129
- package/dist/devices/e2/MideaE2Message.d.ts +33 -33
- package/dist/devices/e2/MideaE2Message.js +132 -132
- package/dist/devices/e3/MideaE3Device.d.ts +43 -43
- package/dist/devices/e3/MideaE3Device.js +137 -137
- package/dist/devices/e3/MideaE3Message.d.ts +51 -51
- package/dist/devices/e3/MideaE3Message.js +136 -136
- package/dist/devices/fa/MideaFADevice.d.ts +36 -36
- package/dist/devices/fa/MideaFADevice.js +106 -106
- package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
- package/dist/devices/fa/MideaFAMessage.js +98 -98
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/platform.d.ts +60 -60
- package/dist/platform.js +212 -212
- package/dist/platformUtils.d.ts +108 -106
- package/dist/platformUtils.d.ts.map +1 -1
- package/dist/platformUtils.js +103 -101
- package/dist/platformUtils.js.map +1 -1
- package/dist/settings.d.ts +8 -8
- package/dist/settings.js +11 -11
- package/docs/ac.md +6 -0
- package/package.json +1 -1
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageE1Response = exports.MessageQuery = exports.MessageStorage = exports.MessageLock = exports.MessagePower = void 0;
|
|
4
|
-
/***********************************************************************
|
|
5
|
-
* Midea Dishwasher Device message handler class
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
8
|
-
*
|
|
9
|
-
* With thanks to https://github.com/georgezhao2010/midea_ac_lan
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
const MideaConstants_1 = require("../../core/MideaConstants");
|
|
13
|
-
const MideaMessage_1 = require("../../core/MideaMessage");
|
|
14
|
-
class MessageE1Base extends MideaMessage_1.MessageRequest {
|
|
15
|
-
constructor(device_protocol_version, message_type, body_type) {
|
|
16
|
-
super(MideaConstants_1.DeviceType.DISHWASHER, message_type, body_type, device_protocol_version);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
class MessagePower extends MessageE1Base {
|
|
20
|
-
constructor(device_protocol_version) {
|
|
21
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x08);
|
|
22
|
-
this.power = false;
|
|
23
|
-
}
|
|
24
|
-
get _body() {
|
|
25
|
-
const power = this.power ? 0x01 : 0x00;
|
|
26
|
-
return Buffer.from([power, 0x00, 0x00, 0x00]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.MessagePower = MessagePower;
|
|
30
|
-
class MessageLock extends MessageE1Base {
|
|
31
|
-
constructor(device_protocol_version) {
|
|
32
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x83);
|
|
33
|
-
this.lock = false;
|
|
34
|
-
}
|
|
35
|
-
get _body() {
|
|
36
|
-
const lock = this.lock ? 0x03 : 0x04;
|
|
37
|
-
return Buffer.concat([Buffer.from([lock]), Buffer.alloc(36)]);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.MessageLock = MessageLock;
|
|
41
|
-
class MessageStorage extends MessageE1Base {
|
|
42
|
-
constructor(device_protocol_version) {
|
|
43
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x14);
|
|
44
|
-
this.storage = false;
|
|
45
|
-
}
|
|
46
|
-
get _body() {
|
|
47
|
-
const storage = this.storage ? 0x01 : 0x00;
|
|
48
|
-
return Buffer.concat([Buffer.from([0x00, 0x00, 0x00, storage]), Buffer.alloc(6, 0xff), Buffer.alloc(27)]);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.MessageStorage = MessageStorage;
|
|
52
|
-
class MessageQuery extends MessageE1Base {
|
|
53
|
-
constructor(device_protocol_version) {
|
|
54
|
-
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x00);
|
|
55
|
-
}
|
|
56
|
-
get _body() {
|
|
57
|
-
return Buffer.alloc(0);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.MessageQuery = MessageQuery;
|
|
61
|
-
class E1GeneralMessageBody extends MideaMessage_1.MessageBody {
|
|
62
|
-
constructor(body) {
|
|
63
|
-
super(body);
|
|
64
|
-
this.power = body[1] > 0;
|
|
65
|
-
this.status = body[1];
|
|
66
|
-
this.mode = body[2];
|
|
67
|
-
this.additional = body[3];
|
|
68
|
-
this.door = (body[5] & 0x01) === 0; // 0: closed, 1: open
|
|
69
|
-
this.rinse_aid = (body[5] & 0x02) > 0; // 0: enough, 1: shortage
|
|
70
|
-
this.salt = (body[5] & 0x04) > 0; // 0: enough, 1: shortage
|
|
71
|
-
this.start_pause = (body[5] & 0x08) > 0;
|
|
72
|
-
this.start = false;
|
|
73
|
-
if (this.start_pause) {
|
|
74
|
-
this.start = true;
|
|
75
|
-
}
|
|
76
|
-
else if ([2, 3].includes(this.status)) {
|
|
77
|
-
this.start = false;
|
|
78
|
-
}
|
|
79
|
-
this.child_lock = (body[5] & 0x10) > 0;
|
|
80
|
-
this.uv = (body[4] & 0x2) > 0;
|
|
81
|
-
this.dry = (body[4] & 0x10) > 0;
|
|
82
|
-
this.dry_status = (body[4] & 0x20) > 0;
|
|
83
|
-
this.storage = (body[5] & 0x20) > 0;
|
|
84
|
-
this.storage_status = (body[5] & 0x40) > 0;
|
|
85
|
-
this.time_remaining = body[6];
|
|
86
|
-
this.progress = body[9];
|
|
87
|
-
this.storage_remaining = body.length > 18 ? body[18] : undefined;
|
|
88
|
-
this.temperature = body[11];
|
|
89
|
-
this.humidity = body.length > 33 ? body[33] : undefined;
|
|
90
|
-
this.waterswitch = (body[4] & 0x4) > 0;
|
|
91
|
-
this.water_lack = (body[5] & 0x80) > 0;
|
|
92
|
-
this.error_code = body[10];
|
|
93
|
-
this.softwater = body[13];
|
|
94
|
-
this.wrong_operation = body[16];
|
|
95
|
-
this.bright = body.length > 24 ? body[24] : undefined;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
class MessageE1Response extends MideaMessage_1.MessageResponse {
|
|
99
|
-
constructor(message) {
|
|
100
|
-
super(message);
|
|
101
|
-
if ((this.message_type === MideaMessage_1.MessageType.SET && this.body_type >= 0 && this.body_type <= 7) ||
|
|
102
|
-
([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.NOTIFY1].includes(this.message_type) && this.body_type === 0x00)) {
|
|
103
|
-
this.set_body(new E1GeneralMessageBody(this.body));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.MessageE1Response = MessageE1Response;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageE1Response = exports.MessageQuery = exports.MessageStorage = exports.MessageLock = exports.MessagePower = void 0;
|
|
4
|
+
/***********************************************************************
|
|
5
|
+
* Midea Dishwasher Device message handler class
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
8
|
+
*
|
|
9
|
+
* With thanks to https://github.com/georgezhao2010/midea_ac_lan
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
const MideaConstants_1 = require("../../core/MideaConstants");
|
|
13
|
+
const MideaMessage_1 = require("../../core/MideaMessage");
|
|
14
|
+
class MessageE1Base extends MideaMessage_1.MessageRequest {
|
|
15
|
+
constructor(device_protocol_version, message_type, body_type) {
|
|
16
|
+
super(MideaConstants_1.DeviceType.DISHWASHER, message_type, body_type, device_protocol_version);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
class MessagePower extends MessageE1Base {
|
|
20
|
+
constructor(device_protocol_version) {
|
|
21
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x08);
|
|
22
|
+
this.power = false;
|
|
23
|
+
}
|
|
24
|
+
get _body() {
|
|
25
|
+
const power = this.power ? 0x01 : 0x00;
|
|
26
|
+
return Buffer.from([power, 0x00, 0x00, 0x00]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.MessagePower = MessagePower;
|
|
30
|
+
class MessageLock extends MessageE1Base {
|
|
31
|
+
constructor(device_protocol_version) {
|
|
32
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x83);
|
|
33
|
+
this.lock = false;
|
|
34
|
+
}
|
|
35
|
+
get _body() {
|
|
36
|
+
const lock = this.lock ? 0x03 : 0x04;
|
|
37
|
+
return Buffer.concat([Buffer.from([lock]), Buffer.alloc(36)]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.MessageLock = MessageLock;
|
|
41
|
+
class MessageStorage extends MessageE1Base {
|
|
42
|
+
constructor(device_protocol_version) {
|
|
43
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x14);
|
|
44
|
+
this.storage = false;
|
|
45
|
+
}
|
|
46
|
+
get _body() {
|
|
47
|
+
const storage = this.storage ? 0x01 : 0x00;
|
|
48
|
+
return Buffer.concat([Buffer.from([0x00, 0x00, 0x00, storage]), Buffer.alloc(6, 0xff), Buffer.alloc(27)]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.MessageStorage = MessageStorage;
|
|
52
|
+
class MessageQuery extends MessageE1Base {
|
|
53
|
+
constructor(device_protocol_version) {
|
|
54
|
+
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x00);
|
|
55
|
+
}
|
|
56
|
+
get _body() {
|
|
57
|
+
return Buffer.alloc(0);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.MessageQuery = MessageQuery;
|
|
61
|
+
class E1GeneralMessageBody extends MideaMessage_1.MessageBody {
|
|
62
|
+
constructor(body) {
|
|
63
|
+
super(body);
|
|
64
|
+
this.power = body[1] > 0;
|
|
65
|
+
this.status = body[1];
|
|
66
|
+
this.mode = body[2];
|
|
67
|
+
this.additional = body[3];
|
|
68
|
+
this.door = (body[5] & 0x01) === 0; // 0: closed, 1: open
|
|
69
|
+
this.rinse_aid = (body[5] & 0x02) > 0; // 0: enough, 1: shortage
|
|
70
|
+
this.salt = (body[5] & 0x04) > 0; // 0: enough, 1: shortage
|
|
71
|
+
this.start_pause = (body[5] & 0x08) > 0;
|
|
72
|
+
this.start = false;
|
|
73
|
+
if (this.start_pause) {
|
|
74
|
+
this.start = true;
|
|
75
|
+
}
|
|
76
|
+
else if ([2, 3].includes(this.status)) {
|
|
77
|
+
this.start = false;
|
|
78
|
+
}
|
|
79
|
+
this.child_lock = (body[5] & 0x10) > 0;
|
|
80
|
+
this.uv = (body[4] & 0x2) > 0;
|
|
81
|
+
this.dry = (body[4] & 0x10) > 0;
|
|
82
|
+
this.dry_status = (body[4] & 0x20) > 0;
|
|
83
|
+
this.storage = (body[5] & 0x20) > 0;
|
|
84
|
+
this.storage_status = (body[5] & 0x40) > 0;
|
|
85
|
+
this.time_remaining = body[6];
|
|
86
|
+
this.progress = body[9];
|
|
87
|
+
this.storage_remaining = body.length > 18 ? body[18] : undefined;
|
|
88
|
+
this.temperature = body[11];
|
|
89
|
+
this.humidity = body.length > 33 ? body[33] : undefined;
|
|
90
|
+
this.waterswitch = (body[4] & 0x4) > 0;
|
|
91
|
+
this.water_lack = (body[5] & 0x80) > 0;
|
|
92
|
+
this.error_code = body[10];
|
|
93
|
+
this.softwater = body[13];
|
|
94
|
+
this.wrong_operation = body[16];
|
|
95
|
+
this.bright = body.length > 24 ? body[24] : undefined;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
class MessageE1Response extends MideaMessage_1.MessageResponse {
|
|
99
|
+
constructor(message) {
|
|
100
|
+
super(message);
|
|
101
|
+
if ((this.message_type === MideaMessage_1.MessageType.SET && this.body_type >= 0 && this.body_type <= 7) ||
|
|
102
|
+
([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.NOTIFY1].includes(this.message_type) && this.body_type === 0x00)) {
|
|
103
|
+
this.set_body(new E1GeneralMessageBody(this.body));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.MessageE1Response = MessageE1Response;
|
|
108
108
|
//# sourceMappingURL=MideaE1Message.js.map
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/***********************************************************************
|
|
2
|
-
* Midea Electric Water Heater Device class
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
5
|
-
*
|
|
6
|
-
* With thanks to https://github.com/georgezhao2010/midea_ac_lan
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
/// <reference types="node" />
|
|
10
|
-
import { Logger } from 'homebridge';
|
|
11
|
-
import MideaDevice, { DeviceAttributeBase } from '../../core/MideaDevice';
|
|
12
|
-
import { DeviceInfo } from '../../core/MideaConstants';
|
|
13
|
-
import { Config, DeviceConfig } from '../../platformUtils';
|
|
14
|
-
import { MessageQuery, MessageSet } from './MideaE2Message';
|
|
15
|
-
export interface E2Attributes extends DeviceAttributeBase {
|
|
16
|
-
POWER: boolean;
|
|
17
|
-
HEATING: boolean;
|
|
18
|
-
KEEP_WARM: boolean;
|
|
19
|
-
PROTECTION: boolean;
|
|
20
|
-
CURRENT_TEMPERATURE?: number;
|
|
21
|
-
TARGET_TEMPERATURE: number;
|
|
22
|
-
WHOLE_TANK_HEATING: boolean;
|
|
23
|
-
VARIABLE_HEATING: boolean;
|
|
24
|
-
HEATING_TIME_REMAINING: number;
|
|
25
|
-
WATER_CONSUMPTION?: number;
|
|
26
|
-
HEATING_POWER?: number;
|
|
27
|
-
}
|
|
28
|
-
export default class MideaE2Device extends MideaDevice {
|
|
29
|
-
attributes: E2Attributes;
|
|
30
|
-
private _old_protocol;
|
|
31
|
-
/*********************************************************************
|
|
32
|
-
* Constructor initializes all the attributes. We set some to invalid
|
|
33
|
-
* values so that they are detected as "changed" on the first status
|
|
34
|
-
* refresh... and passed back to the Homebridge/HomeKit accessory callback
|
|
35
|
-
* function to set their initial values.
|
|
36
|
-
*/
|
|
37
|
-
constructor(logger: Logger, device_info: DeviceInfo, config: Config, deviceConfig: DeviceConfig);
|
|
38
|
-
get old_protocol(): boolean;
|
|
39
|
-
build_query(): MessageQuery[];
|
|
40
|
-
process_message(msg: Buffer): void;
|
|
41
|
-
make_message_set(): MessageSet;
|
|
42
|
-
set_attribute(attributes: Partial<E2Attributes>): Promise<void>;
|
|
43
|
-
protected set_subtype(): void;
|
|
44
|
-
}
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* Midea Electric Water Heater Device class
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
5
|
+
*
|
|
6
|
+
* With thanks to https://github.com/georgezhao2010/midea_ac_lan
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
/// <reference types="node" />
|
|
10
|
+
import { Logger } from 'homebridge';
|
|
11
|
+
import MideaDevice, { DeviceAttributeBase } from '../../core/MideaDevice';
|
|
12
|
+
import { DeviceInfo } from '../../core/MideaConstants';
|
|
13
|
+
import { Config, DeviceConfig } from '../../platformUtils';
|
|
14
|
+
import { MessageQuery, MessageSet } from './MideaE2Message';
|
|
15
|
+
export interface E2Attributes extends DeviceAttributeBase {
|
|
16
|
+
POWER: boolean;
|
|
17
|
+
HEATING: boolean;
|
|
18
|
+
KEEP_WARM: boolean;
|
|
19
|
+
PROTECTION: boolean;
|
|
20
|
+
CURRENT_TEMPERATURE?: number;
|
|
21
|
+
TARGET_TEMPERATURE: number;
|
|
22
|
+
WHOLE_TANK_HEATING: boolean;
|
|
23
|
+
VARIABLE_HEATING: boolean;
|
|
24
|
+
HEATING_TIME_REMAINING: number;
|
|
25
|
+
WATER_CONSUMPTION?: number;
|
|
26
|
+
HEATING_POWER?: number;
|
|
27
|
+
}
|
|
28
|
+
export default class MideaE2Device extends MideaDevice {
|
|
29
|
+
attributes: E2Attributes;
|
|
30
|
+
private _old_protocol;
|
|
31
|
+
/*********************************************************************
|
|
32
|
+
* Constructor initializes all the attributes. We set some to invalid
|
|
33
|
+
* values so that they are detected as "changed" on the first status
|
|
34
|
+
* refresh... and passed back to the Homebridge/HomeKit accessory callback
|
|
35
|
+
* function to set their initial values.
|
|
36
|
+
*/
|
|
37
|
+
constructor(logger: Logger, device_info: DeviceInfo, config: Config, deviceConfig: DeviceConfig);
|
|
38
|
+
get old_protocol(): boolean;
|
|
39
|
+
build_query(): MessageQuery[];
|
|
40
|
+
process_message(msg: Buffer): void;
|
|
41
|
+
make_message_set(): MessageSet;
|
|
42
|
+
set_attribute(attributes: Partial<E2Attributes>): Promise<void>;
|
|
43
|
+
protected set_subtype(): void;
|
|
44
|
+
}
|
|
45
45
|
//# sourceMappingURL=MideaE2Device.d.ts.map
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/***********************************************************************
|
|
3
|
-
* Midea Electric Water Heater Device class
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
6
|
-
*
|
|
7
|
-
* With thanks to https://github.com/georgezhao2010/midea_ac_lan
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const MideaDevice_1 = __importDefault(require("../../core/MideaDevice"));
|
|
15
|
-
const MideaE2Message_1 = require("./MideaE2Message");
|
|
16
|
-
class MideaE2Device extends MideaDevice_1.default {
|
|
17
|
-
/*********************************************************************
|
|
18
|
-
* Constructor initializes all the attributes. We set some to invalid
|
|
19
|
-
* values so that they are detected as "changed" on the first status
|
|
20
|
-
* refresh... and passed back to the Homebridge/HomeKit accessory callback
|
|
21
|
-
* function to set their initial values.
|
|
22
|
-
*/
|
|
23
|
-
constructor(logger, device_info, config, deviceConfig) {
|
|
24
|
-
super(logger, device_info, config, deviceConfig);
|
|
25
|
-
this.attributes = {
|
|
26
|
-
POWER: false,
|
|
27
|
-
HEATING: false,
|
|
28
|
-
KEEP_WARM: false,
|
|
29
|
-
PROTECTION: false,
|
|
30
|
-
CURRENT_TEMPERATURE: undefined,
|
|
31
|
-
TARGET_TEMPERATURE: 40,
|
|
32
|
-
WHOLE_TANK_HEATING: false,
|
|
33
|
-
VARIABLE_HEATING: false,
|
|
34
|
-
HEATING_TIME_REMAINING: 0,
|
|
35
|
-
WATER_CONSUMPTION: undefined,
|
|
36
|
-
HEATING_POWER: undefined,
|
|
37
|
-
};
|
|
38
|
-
this._old_protocol = deviceConfig.E2_options.protocol;
|
|
39
|
-
}
|
|
40
|
-
get old_protocol() {
|
|
41
|
-
return this.sub_type <= 82 || this.sub_type === 85 || this.sub_type === 36353;
|
|
42
|
-
}
|
|
43
|
-
build_query() {
|
|
44
|
-
return [new MideaE2Message_1.MessageQuery(this.device_protocol_version)];
|
|
45
|
-
}
|
|
46
|
-
process_message(msg) {
|
|
47
|
-
const message = new MideaE2Message_1.MessageE2Response(msg);
|
|
48
|
-
if (this.verbose) {
|
|
49
|
-
this.logger.debug(`[${this.name}] Body:\n${JSON.stringify(message.body)}`);
|
|
50
|
-
}
|
|
51
|
-
const changed = {};
|
|
52
|
-
for (const status of Object.keys(this.attributes)) {
|
|
53
|
-
const value = message.get_body_attribute(status.toLowerCase());
|
|
54
|
-
if (value !== undefined) {
|
|
55
|
-
if (this.attributes[status] !== value) {
|
|
56
|
-
// Track only those attributes that change value. So when we send to the Homebridge /
|
|
57
|
-
// HomeKit accessory we only update values that change. First time through this
|
|
58
|
-
// should be most/all attributes having initialized them to invalid values.
|
|
59
|
-
this.logger.debug(`[${this.name}] Value for ${status} changed from '${this.attributes[status]}' to '${value}'`);
|
|
60
|
-
changed[status] = value;
|
|
61
|
-
}
|
|
62
|
-
this.attributes[status] = value;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// Now we update Homebridge / Homekit accessory
|
|
66
|
-
if (Object.keys(changed).length > 0) {
|
|
67
|
-
this.update(changed);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.logger.debug(`[${this.name}] Status unchanged`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
make_message_set() {
|
|
74
|
-
const message = new MideaE2Message_1.MessageSet(this.device_protocol_version);
|
|
75
|
-
message.protection = this.attributes.PROTECTION;
|
|
76
|
-
message.whole_tank_heating = this.attributes.WHOLE_TANK_HEATING;
|
|
77
|
-
message.target_temperature = this.attributes.TARGET_TEMPERATURE;
|
|
78
|
-
message.variable_heating = this.attributes.VARIABLE_HEATING;
|
|
79
|
-
return message;
|
|
80
|
-
}
|
|
81
|
-
async set_attribute(attributes) {
|
|
82
|
-
var _a, _b, _c;
|
|
83
|
-
const messageToSend = {
|
|
84
|
-
POWER: undefined,
|
|
85
|
-
SET: undefined,
|
|
86
|
-
NEW_PROTOCOL_SET: undefined,
|
|
87
|
-
};
|
|
88
|
-
try {
|
|
89
|
-
for (const [k, v] of Object.entries(attributes)) {
|
|
90
|
-
if (v === this.attributes[k]) {
|
|
91
|
-
this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
|
|
95
|
-
this.attributes[k] = v;
|
|
96
|
-
// not sensor data
|
|
97
|
-
if (!['HEATING', 'KEEP_WARM', 'CURRENT_TEMPERATURE'].includes(k)) {
|
|
98
|
-
const old_protocol = this._old_protocol !== 'auto' ? this._old_protocol === 'old' : this.old_protocol;
|
|
99
|
-
if (k === 'POWER') {
|
|
100
|
-
(_a = messageToSend.POWER) !== null && _a !== void 0 ? _a : (messageToSend.POWER = new MideaE2Message_1.MessagePower(this.device_protocol_version));
|
|
101
|
-
messageToSend.POWER.power = v;
|
|
102
|
-
}
|
|
103
|
-
else if (old_protocol) {
|
|
104
|
-
(_b = messageToSend.SET) !== null && _b !== void 0 ? _b : (messageToSend.SET = this.make_message_set());
|
|
105
|
-
messageToSend.SET[k.toLowerCase()] = v;
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
(_c = messageToSend.NEW_PROTOCOL_SET) !== null && _c !== void 0 ? _c : (messageToSend.NEW_PROTOCOL_SET = new MideaE2Message_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
109
|
-
messageToSend.NEW_PROTOCOL_SET[k.toLowerCase()] = v;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
for (const [k, v] of Object.entries(messageToSend)) {
|
|
114
|
-
if (v !== undefined) {
|
|
115
|
-
this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
|
|
116
|
-
await this.build_send(v);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
catch (err) {
|
|
121
|
-
const msg = err instanceof Error ? err.stack : err;
|
|
122
|
-
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
set_subtype() {
|
|
126
|
-
this.logger.debug('No subtype for E2 device');
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.default = MideaE2Device;
|
|
1
|
+
"use strict";
|
|
2
|
+
/***********************************************************************
|
|
3
|
+
* Midea Electric Water Heater Device class
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
6
|
+
*
|
|
7
|
+
* With thanks to https://github.com/georgezhao2010/midea_ac_lan
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const MideaDevice_1 = __importDefault(require("../../core/MideaDevice"));
|
|
15
|
+
const MideaE2Message_1 = require("./MideaE2Message");
|
|
16
|
+
class MideaE2Device extends MideaDevice_1.default {
|
|
17
|
+
/*********************************************************************
|
|
18
|
+
* Constructor initializes all the attributes. We set some to invalid
|
|
19
|
+
* values so that they are detected as "changed" on the first status
|
|
20
|
+
* refresh... and passed back to the Homebridge/HomeKit accessory callback
|
|
21
|
+
* function to set their initial values.
|
|
22
|
+
*/
|
|
23
|
+
constructor(logger, device_info, config, deviceConfig) {
|
|
24
|
+
super(logger, device_info, config, deviceConfig);
|
|
25
|
+
this.attributes = {
|
|
26
|
+
POWER: false,
|
|
27
|
+
HEATING: false,
|
|
28
|
+
KEEP_WARM: false,
|
|
29
|
+
PROTECTION: false,
|
|
30
|
+
CURRENT_TEMPERATURE: undefined,
|
|
31
|
+
TARGET_TEMPERATURE: 40,
|
|
32
|
+
WHOLE_TANK_HEATING: false,
|
|
33
|
+
VARIABLE_HEATING: false,
|
|
34
|
+
HEATING_TIME_REMAINING: 0,
|
|
35
|
+
WATER_CONSUMPTION: undefined,
|
|
36
|
+
HEATING_POWER: undefined,
|
|
37
|
+
};
|
|
38
|
+
this._old_protocol = deviceConfig.E2_options.protocol;
|
|
39
|
+
}
|
|
40
|
+
get old_protocol() {
|
|
41
|
+
return this.sub_type <= 82 || this.sub_type === 85 || this.sub_type === 36353;
|
|
42
|
+
}
|
|
43
|
+
build_query() {
|
|
44
|
+
return [new MideaE2Message_1.MessageQuery(this.device_protocol_version)];
|
|
45
|
+
}
|
|
46
|
+
process_message(msg) {
|
|
47
|
+
const message = new MideaE2Message_1.MessageE2Response(msg);
|
|
48
|
+
if (this.verbose) {
|
|
49
|
+
this.logger.debug(`[${this.name}] Body:\n${JSON.stringify(message.body)}`);
|
|
50
|
+
}
|
|
51
|
+
const changed = {};
|
|
52
|
+
for (const status of Object.keys(this.attributes)) {
|
|
53
|
+
const value = message.get_body_attribute(status.toLowerCase());
|
|
54
|
+
if (value !== undefined) {
|
|
55
|
+
if (this.attributes[status] !== value) {
|
|
56
|
+
// Track only those attributes that change value. So when we send to the Homebridge /
|
|
57
|
+
// HomeKit accessory we only update values that change. First time through this
|
|
58
|
+
// should be most/all attributes having initialized them to invalid values.
|
|
59
|
+
this.logger.debug(`[${this.name}] Value for ${status} changed from '${this.attributes[status]}' to '${value}'`);
|
|
60
|
+
changed[status] = value;
|
|
61
|
+
}
|
|
62
|
+
this.attributes[status] = value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Now we update Homebridge / Homekit accessory
|
|
66
|
+
if (Object.keys(changed).length > 0) {
|
|
67
|
+
this.update(changed);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.logger.debug(`[${this.name}] Status unchanged`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
make_message_set() {
|
|
74
|
+
const message = new MideaE2Message_1.MessageSet(this.device_protocol_version);
|
|
75
|
+
message.protection = this.attributes.PROTECTION;
|
|
76
|
+
message.whole_tank_heating = this.attributes.WHOLE_TANK_HEATING;
|
|
77
|
+
message.target_temperature = this.attributes.TARGET_TEMPERATURE;
|
|
78
|
+
message.variable_heating = this.attributes.VARIABLE_HEATING;
|
|
79
|
+
return message;
|
|
80
|
+
}
|
|
81
|
+
async set_attribute(attributes) {
|
|
82
|
+
var _a, _b, _c;
|
|
83
|
+
const messageToSend = {
|
|
84
|
+
POWER: undefined,
|
|
85
|
+
SET: undefined,
|
|
86
|
+
NEW_PROTOCOL_SET: undefined,
|
|
87
|
+
};
|
|
88
|
+
try {
|
|
89
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
90
|
+
if (v === this.attributes[k]) {
|
|
91
|
+
this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
|
|
95
|
+
this.attributes[k] = v;
|
|
96
|
+
// not sensor data
|
|
97
|
+
if (!['HEATING', 'KEEP_WARM', 'CURRENT_TEMPERATURE'].includes(k)) {
|
|
98
|
+
const old_protocol = this._old_protocol !== 'auto' ? this._old_protocol === 'old' : this.old_protocol;
|
|
99
|
+
if (k === 'POWER') {
|
|
100
|
+
(_a = messageToSend.POWER) !== null && _a !== void 0 ? _a : (messageToSend.POWER = new MideaE2Message_1.MessagePower(this.device_protocol_version));
|
|
101
|
+
messageToSend.POWER.power = v;
|
|
102
|
+
}
|
|
103
|
+
else if (old_protocol) {
|
|
104
|
+
(_b = messageToSend.SET) !== null && _b !== void 0 ? _b : (messageToSend.SET = this.make_message_set());
|
|
105
|
+
messageToSend.SET[k.toLowerCase()] = v;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
(_c = messageToSend.NEW_PROTOCOL_SET) !== null && _c !== void 0 ? _c : (messageToSend.NEW_PROTOCOL_SET = new MideaE2Message_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
109
|
+
messageToSend.NEW_PROTOCOL_SET[k.toLowerCase()] = v;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const [k, v] of Object.entries(messageToSend)) {
|
|
114
|
+
if (v !== undefined) {
|
|
115
|
+
this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
|
|
116
|
+
await this.build_send(v);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
const msg = err instanceof Error ? err.stack : err;
|
|
122
|
+
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
set_subtype() {
|
|
126
|
+
this.logger.debug('No subtype for E2 device');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.default = MideaE2Device;
|
|
130
130
|
//# sourceMappingURL=MideaE2Device.js.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { MessageRequest, MessageResponse, MessageType } from '../../core/MideaMessage';
|
|
3
|
-
declare abstract class MessageE2Base extends MessageRequest {
|
|
4
|
-
constructor(device_protocol_version: number, message_type: MessageType, body_type: number);
|
|
5
|
-
}
|
|
6
|
-
export declare class MessageQuery extends MessageE2Base {
|
|
7
|
-
constructor(device_protocol_version: number);
|
|
8
|
-
get _body(): Buffer;
|
|
9
|
-
}
|
|
10
|
-
export declare class MessagePower extends MessageE2Base {
|
|
11
|
-
power: boolean;
|
|
12
|
-
constructor(device_protocol_version: number);
|
|
13
|
-
get _body(): Buffer;
|
|
14
|
-
}
|
|
15
|
-
export declare class MessageNewProtocolSet extends MessageE2Base {
|
|
16
|
-
target_temperature?: number;
|
|
17
|
-
variable_heating?: boolean;
|
|
18
|
-
whole_tank_heating?: boolean;
|
|
19
|
-
constructor(device_protocol_version: number);
|
|
20
|
-
get _body(): Buffer;
|
|
21
|
-
}
|
|
22
|
-
export declare class MessageSet extends MessageE2Base {
|
|
23
|
-
target_temperature: number;
|
|
24
|
-
variable_heating: boolean;
|
|
25
|
-
whole_tank_heating: boolean;
|
|
26
|
-
protection: boolean;
|
|
27
|
-
constructor(device_protocol_version: number);
|
|
28
|
-
get _body(): Buffer;
|
|
29
|
-
}
|
|
30
|
-
export declare class MessageE2Response extends MessageResponse {
|
|
31
|
-
constructor(message: Buffer);
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { MessageRequest, MessageResponse, MessageType } from '../../core/MideaMessage';
|
|
3
|
+
declare abstract class MessageE2Base extends MessageRequest {
|
|
4
|
+
constructor(device_protocol_version: number, message_type: MessageType, body_type: number);
|
|
5
|
+
}
|
|
6
|
+
export declare class MessageQuery extends MessageE2Base {
|
|
7
|
+
constructor(device_protocol_version: number);
|
|
8
|
+
get _body(): Buffer;
|
|
9
|
+
}
|
|
10
|
+
export declare class MessagePower extends MessageE2Base {
|
|
11
|
+
power: boolean;
|
|
12
|
+
constructor(device_protocol_version: number);
|
|
13
|
+
get _body(): Buffer;
|
|
14
|
+
}
|
|
15
|
+
export declare class MessageNewProtocolSet extends MessageE2Base {
|
|
16
|
+
target_temperature?: number;
|
|
17
|
+
variable_heating?: boolean;
|
|
18
|
+
whole_tank_heating?: boolean;
|
|
19
|
+
constructor(device_protocol_version: number);
|
|
20
|
+
get _body(): Buffer;
|
|
21
|
+
}
|
|
22
|
+
export declare class MessageSet extends MessageE2Base {
|
|
23
|
+
target_temperature: number;
|
|
24
|
+
variable_heating: boolean;
|
|
25
|
+
whole_tank_heating: boolean;
|
|
26
|
+
protection: boolean;
|
|
27
|
+
constructor(device_protocol_version: number);
|
|
28
|
+
get _body(): Buffer;
|
|
29
|
+
}
|
|
30
|
+
export declare class MessageE2Response extends MessageResponse {
|
|
31
|
+
constructor(message: Buffer);
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
34
34
|
//# sourceMappingURL=MideaE2Message.d.ts.map
|