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,133 +1,133 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageE2Response = exports.MessageSet = exports.MessageNewProtocolSet = exports.MessagePower = exports.MessageQuery = void 0;
|
|
4
|
-
/***********************************************************************
|
|
5
|
-
* Midea Electric Water Heater 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 MessageE2Base extends MideaMessage_1.MessageRequest {
|
|
15
|
-
constructor(device_protocol_version, message_type, body_type) {
|
|
16
|
-
super(MideaConstants_1.DeviceType.ELECTRIC_WATER_HEATER, message_type, body_type, device_protocol_version);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
class MessageQuery extends MessageE2Base {
|
|
20
|
-
constructor(device_protocol_version) {
|
|
21
|
-
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x01);
|
|
22
|
-
}
|
|
23
|
-
get _body() {
|
|
24
|
-
return Buffer.from([0x01]);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.MessageQuery = MessageQuery;
|
|
28
|
-
class MessagePower extends MessageE2Base {
|
|
29
|
-
constructor(device_protocol_version) {
|
|
30
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x02);
|
|
31
|
-
this.power = false;
|
|
32
|
-
}
|
|
33
|
-
get _body() {
|
|
34
|
-
if (this.power) {
|
|
35
|
-
this.body_type = 0x01;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this.body_type = 0x02;
|
|
39
|
-
}
|
|
40
|
-
return Buffer.from([0x01]);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.MessagePower = MessagePower;
|
|
44
|
-
class MessageNewProtocolSet extends MessageE2Base {
|
|
45
|
-
constructor(device_protocol_version) {
|
|
46
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x02);
|
|
47
|
-
}
|
|
48
|
-
get _body() {
|
|
49
|
-
let byte1 = 0x00;
|
|
50
|
-
let byte2 = 0x00;
|
|
51
|
-
if (this.target_temperature !== undefined) {
|
|
52
|
-
byte1 = 0x07;
|
|
53
|
-
byte2 = (this.target_temperature | 0) & 0xf;
|
|
54
|
-
}
|
|
55
|
-
else if (this.whole_tank_heating !== undefined) {
|
|
56
|
-
byte1 = 0x04;
|
|
57
|
-
byte2 = this.whole_tank_heating ? 0x02 : 0x01;
|
|
58
|
-
}
|
|
59
|
-
else if (this.variable_heating !== undefined) {
|
|
60
|
-
byte1 = 0x10;
|
|
61
|
-
byte2 = this.variable_heating ? 0x01 : 0x00;
|
|
62
|
-
}
|
|
63
|
-
return Buffer.from([byte1, byte2]);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.MessageNewProtocolSet = MessageNewProtocolSet;
|
|
67
|
-
class MessageSet extends MessageE2Base {
|
|
68
|
-
constructor(device_protocol_version) {
|
|
69
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x02);
|
|
70
|
-
this.target_temperature = 0;
|
|
71
|
-
this.variable_heating = false;
|
|
72
|
-
this.whole_tank_heating = false;
|
|
73
|
-
this.protection = false;
|
|
74
|
-
}
|
|
75
|
-
get _body() {
|
|
76
|
-
const protection = this.protection ? 0x04 : 0x00;
|
|
77
|
-
const whole_tank_heating = this.whole_tank_heating ? 0x02 : 0x01;
|
|
78
|
-
const target_temperature = this.target_temperature & 0xff;
|
|
79
|
-
const variable_heating = this.variable_heating ? 0x10 : 0x00;
|
|
80
|
-
return Buffer.from([
|
|
81
|
-
0x01,
|
|
82
|
-
0x00,
|
|
83
|
-
0x80,
|
|
84
|
-
whole_tank_heating | protection,
|
|
85
|
-
target_temperature,
|
|
86
|
-
0x00,
|
|
87
|
-
0x00,
|
|
88
|
-
0x00,
|
|
89
|
-
variable_heating,
|
|
90
|
-
0x00,
|
|
91
|
-
0x00,
|
|
92
|
-
0x00,
|
|
93
|
-
0x00,
|
|
94
|
-
0x00,
|
|
95
|
-
0x00,
|
|
96
|
-
0x00,
|
|
97
|
-
0x00,
|
|
98
|
-
0x00,
|
|
99
|
-
]);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.MessageSet = MessageSet;
|
|
103
|
-
class E2GeneralMessageBody extends MideaMessage_1.MessageBody {
|
|
104
|
-
constructor(body) {
|
|
105
|
-
super(body);
|
|
106
|
-
this.power = (body[2] & 0x01) > 0;
|
|
107
|
-
this.heating = (body[2] & 0x04) > 0;
|
|
108
|
-
this.keep_warm = (body[2] & 0x08) > 0;
|
|
109
|
-
this.variable_heating = (body[2] & 0x80) > 0;
|
|
110
|
-
this.current_temperature = body[4];
|
|
111
|
-
this.whole_tank_heating = (body[7] & 0x08) > 0;
|
|
112
|
-
this.heating_time_remaining = body[9] * 60 + body[10];
|
|
113
|
-
this.target_temperature = body[11];
|
|
114
|
-
this.protection = body.length > 22 ? (body[22] & 0x02) > 0 : false;
|
|
115
|
-
if (body.length > 25) {
|
|
116
|
-
this.water_consumption = body[24] + (body[25] << 8);
|
|
117
|
-
}
|
|
118
|
-
if (body.length > 34) {
|
|
119
|
-
this.heating_power = body[34] * 100;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
class MessageE2Response extends MideaMessage_1.MessageResponse {
|
|
124
|
-
constructor(message) {
|
|
125
|
-
super(message);
|
|
126
|
-
if (([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.NOTIFY1].includes(this.message_type) && this.body_type === 0x01) ||
|
|
127
|
-
(this.message_type === MideaMessage_1.MessageType.SET && [0x01, 0x02, 0x04, 0x14].includes(this.body_type))) {
|
|
128
|
-
this.set_body(new E2GeneralMessageBody(this.body));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
exports.MessageE2Response = MessageE2Response;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageE2Response = exports.MessageSet = exports.MessageNewProtocolSet = exports.MessagePower = exports.MessageQuery = void 0;
|
|
4
|
+
/***********************************************************************
|
|
5
|
+
* Midea Electric Water Heater 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 MessageE2Base extends MideaMessage_1.MessageRequest {
|
|
15
|
+
constructor(device_protocol_version, message_type, body_type) {
|
|
16
|
+
super(MideaConstants_1.DeviceType.ELECTRIC_WATER_HEATER, message_type, body_type, device_protocol_version);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
class MessageQuery extends MessageE2Base {
|
|
20
|
+
constructor(device_protocol_version) {
|
|
21
|
+
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x01);
|
|
22
|
+
}
|
|
23
|
+
get _body() {
|
|
24
|
+
return Buffer.from([0x01]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.MessageQuery = MessageQuery;
|
|
28
|
+
class MessagePower extends MessageE2Base {
|
|
29
|
+
constructor(device_protocol_version) {
|
|
30
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x02);
|
|
31
|
+
this.power = false;
|
|
32
|
+
}
|
|
33
|
+
get _body() {
|
|
34
|
+
if (this.power) {
|
|
35
|
+
this.body_type = 0x01;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.body_type = 0x02;
|
|
39
|
+
}
|
|
40
|
+
return Buffer.from([0x01]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.MessagePower = MessagePower;
|
|
44
|
+
class MessageNewProtocolSet extends MessageE2Base {
|
|
45
|
+
constructor(device_protocol_version) {
|
|
46
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x02);
|
|
47
|
+
}
|
|
48
|
+
get _body() {
|
|
49
|
+
let byte1 = 0x00;
|
|
50
|
+
let byte2 = 0x00;
|
|
51
|
+
if (this.target_temperature !== undefined) {
|
|
52
|
+
byte1 = 0x07;
|
|
53
|
+
byte2 = (this.target_temperature | 0) & 0xf;
|
|
54
|
+
}
|
|
55
|
+
else if (this.whole_tank_heating !== undefined) {
|
|
56
|
+
byte1 = 0x04;
|
|
57
|
+
byte2 = this.whole_tank_heating ? 0x02 : 0x01;
|
|
58
|
+
}
|
|
59
|
+
else if (this.variable_heating !== undefined) {
|
|
60
|
+
byte1 = 0x10;
|
|
61
|
+
byte2 = this.variable_heating ? 0x01 : 0x00;
|
|
62
|
+
}
|
|
63
|
+
return Buffer.from([byte1, byte2]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.MessageNewProtocolSet = MessageNewProtocolSet;
|
|
67
|
+
class MessageSet extends MessageE2Base {
|
|
68
|
+
constructor(device_protocol_version) {
|
|
69
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x02);
|
|
70
|
+
this.target_temperature = 0;
|
|
71
|
+
this.variable_heating = false;
|
|
72
|
+
this.whole_tank_heating = false;
|
|
73
|
+
this.protection = false;
|
|
74
|
+
}
|
|
75
|
+
get _body() {
|
|
76
|
+
const protection = this.protection ? 0x04 : 0x00;
|
|
77
|
+
const whole_tank_heating = this.whole_tank_heating ? 0x02 : 0x01;
|
|
78
|
+
const target_temperature = this.target_temperature & 0xff;
|
|
79
|
+
const variable_heating = this.variable_heating ? 0x10 : 0x00;
|
|
80
|
+
return Buffer.from([
|
|
81
|
+
0x01,
|
|
82
|
+
0x00,
|
|
83
|
+
0x80,
|
|
84
|
+
whole_tank_heating | protection,
|
|
85
|
+
target_temperature,
|
|
86
|
+
0x00,
|
|
87
|
+
0x00,
|
|
88
|
+
0x00,
|
|
89
|
+
variable_heating,
|
|
90
|
+
0x00,
|
|
91
|
+
0x00,
|
|
92
|
+
0x00,
|
|
93
|
+
0x00,
|
|
94
|
+
0x00,
|
|
95
|
+
0x00,
|
|
96
|
+
0x00,
|
|
97
|
+
0x00,
|
|
98
|
+
0x00,
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.MessageSet = MessageSet;
|
|
103
|
+
class E2GeneralMessageBody extends MideaMessage_1.MessageBody {
|
|
104
|
+
constructor(body) {
|
|
105
|
+
super(body);
|
|
106
|
+
this.power = (body[2] & 0x01) > 0;
|
|
107
|
+
this.heating = (body[2] & 0x04) > 0;
|
|
108
|
+
this.keep_warm = (body[2] & 0x08) > 0;
|
|
109
|
+
this.variable_heating = (body[2] & 0x80) > 0;
|
|
110
|
+
this.current_temperature = body[4];
|
|
111
|
+
this.whole_tank_heating = (body[7] & 0x08) > 0;
|
|
112
|
+
this.heating_time_remaining = body[9] * 60 + body[10];
|
|
113
|
+
this.target_temperature = body[11];
|
|
114
|
+
this.protection = body.length > 22 ? (body[22] & 0x02) > 0 : false;
|
|
115
|
+
if (body.length > 25) {
|
|
116
|
+
this.water_consumption = body[24] + (body[25] << 8);
|
|
117
|
+
}
|
|
118
|
+
if (body.length > 34) {
|
|
119
|
+
this.heating_power = body[34] * 100;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
class MessageE2Response extends MideaMessage_1.MessageResponse {
|
|
124
|
+
constructor(message) {
|
|
125
|
+
super(message);
|
|
126
|
+
if (([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.NOTIFY1].includes(this.message_type) && this.body_type === 0x01) ||
|
|
127
|
+
(this.message_type === MideaMessage_1.MessageType.SET && [0x01, 0x02, 0x04, 0x14].includes(this.body_type))) {
|
|
128
|
+
this.set_body(new E2GeneralMessageBody(this.body));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.MessageE2Response = MessageE2Response;
|
|
133
133
|
//# sourceMappingURL=MideaE2Message.js.map
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
/***********************************************************************
|
|
2
|
-
* Midea Gas 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 { MessageRequest } from '../../core/MideaMessage';
|
|
15
|
-
import { MessageSet } from './MideaE3Message';
|
|
16
|
-
export interface E3Attributes extends DeviceAttributeBase {
|
|
17
|
-
POWER: boolean;
|
|
18
|
-
BURNING_STATE: boolean;
|
|
19
|
-
ZERO_COLD_WATER: boolean;
|
|
20
|
-
PROTECTION: boolean;
|
|
21
|
-
ZERO_COLD_PULSE: boolean;
|
|
22
|
-
SMART_VOLUME: boolean;
|
|
23
|
-
CURRENT_TEMPERATURE?: number;
|
|
24
|
-
TARGET_TEMPERATURE: number;
|
|
25
|
-
}
|
|
26
|
-
export default class MideaE3Device extends MideaDevice {
|
|
27
|
-
attributes: E3Attributes;
|
|
28
|
-
private _old_subtypes;
|
|
29
|
-
private _precision_halves;
|
|
30
|
-
/*********************************************************************
|
|
31
|
-
* Constructor initializes all the attributes. We set some to invalid
|
|
32
|
-
* values so that they are detected as "changed" on the first status
|
|
33
|
-
* refresh... and passed back to the Homebridge/HomeKit accessory callback
|
|
34
|
-
* function to set their initial values.
|
|
35
|
-
*/
|
|
36
|
-
constructor(logger: Logger, device_info: DeviceInfo, config: Config, deviceConfig: DeviceConfig);
|
|
37
|
-
get precision_halves(): boolean;
|
|
38
|
-
build_query(): MessageRequest[];
|
|
39
|
-
process_message(msg: Buffer): void;
|
|
40
|
-
make_message_set(): MessageSet;
|
|
41
|
-
set_attribute(attributes: Partial<E3Attributes>): Promise<void>;
|
|
42
|
-
protected set_subtype(): void;
|
|
43
|
-
}
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* Midea Gas 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 { MessageRequest } from '../../core/MideaMessage';
|
|
15
|
+
import { MessageSet } from './MideaE3Message';
|
|
16
|
+
export interface E3Attributes extends DeviceAttributeBase {
|
|
17
|
+
POWER: boolean;
|
|
18
|
+
BURNING_STATE: boolean;
|
|
19
|
+
ZERO_COLD_WATER: boolean;
|
|
20
|
+
PROTECTION: boolean;
|
|
21
|
+
ZERO_COLD_PULSE: boolean;
|
|
22
|
+
SMART_VOLUME: boolean;
|
|
23
|
+
CURRENT_TEMPERATURE?: number;
|
|
24
|
+
TARGET_TEMPERATURE: number;
|
|
25
|
+
}
|
|
26
|
+
export default class MideaE3Device extends MideaDevice {
|
|
27
|
+
attributes: E3Attributes;
|
|
28
|
+
private _old_subtypes;
|
|
29
|
+
private _precision_halves;
|
|
30
|
+
/*********************************************************************
|
|
31
|
+
* Constructor initializes all the attributes. We set some to invalid
|
|
32
|
+
* values so that they are detected as "changed" on the first status
|
|
33
|
+
* refresh... and passed back to the Homebridge/HomeKit accessory callback
|
|
34
|
+
* function to set their initial values.
|
|
35
|
+
*/
|
|
36
|
+
constructor(logger: Logger, device_info: DeviceInfo, config: Config, deviceConfig: DeviceConfig);
|
|
37
|
+
get precision_halves(): boolean;
|
|
38
|
+
build_query(): MessageRequest[];
|
|
39
|
+
process_message(msg: Buffer): void;
|
|
40
|
+
make_message_set(): MessageSet;
|
|
41
|
+
set_attribute(attributes: Partial<E3Attributes>): Promise<void>;
|
|
42
|
+
protected set_subtype(): void;
|
|
43
|
+
}
|
|
44
44
|
//# sourceMappingURL=MideaE3Device.d.ts.map
|
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/***********************************************************************
|
|
3
|
-
* Midea Gas 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 MideaE3Message_1 = require("./MideaE3Message");
|
|
16
|
-
class MideaE3Device 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._old_subtypes = [32, 33, 34, 35, 36, 37, 40, 43, 48, 49, 80];
|
|
26
|
-
this.attributes = {
|
|
27
|
-
POWER: false,
|
|
28
|
-
BURNING_STATE: false,
|
|
29
|
-
ZERO_COLD_WATER: false,
|
|
30
|
-
PROTECTION: false,
|
|
31
|
-
ZERO_COLD_PULSE: false,
|
|
32
|
-
SMART_VOLUME: false,
|
|
33
|
-
CURRENT_TEMPERATURE: undefined,
|
|
34
|
-
TARGET_TEMPERATURE: 40,
|
|
35
|
-
};
|
|
36
|
-
this._precision_halves = deviceConfig.E3_options.precisionHalves;
|
|
37
|
-
}
|
|
38
|
-
get precision_halves() {
|
|
39
|
-
return this._precision_halves;
|
|
40
|
-
}
|
|
41
|
-
build_query() {
|
|
42
|
-
return [new MideaE3Message_1.MessageQuery(this.device_protocol_version)];
|
|
43
|
-
}
|
|
44
|
-
process_message(msg) {
|
|
45
|
-
const message = new MideaE3Message_1.MessageE3Response(msg);
|
|
46
|
-
if (this.verbose) {
|
|
47
|
-
this.logger.debug(`[${this.name}] Body:\n${JSON.stringify(message.body)}`);
|
|
48
|
-
}
|
|
49
|
-
const changed = {};
|
|
50
|
-
for (const status of Object.keys(this.attributes)) {
|
|
51
|
-
let value = message.get_body_attribute(status.toLowerCase());
|
|
52
|
-
if (value !== undefined) {
|
|
53
|
-
if (this.attributes[status] !== value) {
|
|
54
|
-
// Track only those attributes that change value. So when we send to the Homebridge /
|
|
55
|
-
// HomeKit accessory we only update values that change. First time through this
|
|
56
|
-
// should be most/all attributes having initialized them to invalid values.
|
|
57
|
-
if (this.precision_halves && ['CURRENT_TEMPERATURE', 'TARGET_TEMPERATURE'].includes(status)) {
|
|
58
|
-
value = value / 2;
|
|
59
|
-
}
|
|
60
|
-
this.logger.debug(`[${this.name}] Value for ${status} changed from '${this.attributes[status]}' to '${value}'`);
|
|
61
|
-
changed[status] = value;
|
|
62
|
-
}
|
|
63
|
-
this.attributes[status] = value;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// Now we update Homebridge / Homekit accessory
|
|
67
|
-
if (Object.keys(changed).length > 0) {
|
|
68
|
-
this.update(changed);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
this.logger.debug(`[${this.name}] Status unchanged`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
make_message_set() {
|
|
75
|
-
const message = new MideaE3Message_1.MessageSet(this.device_protocol_version);
|
|
76
|
-
message.zero_cold_water = this.attributes.ZERO_COLD_WATER;
|
|
77
|
-
message.protection = this.attributes.PROTECTION;
|
|
78
|
-
message.zero_cold_pulse = this.attributes.ZERO_COLD_PULSE;
|
|
79
|
-
message.smart_volume = this.attributes.SMART_VOLUME;
|
|
80
|
-
message.target_temperature = this.attributes.TARGET_TEMPERATURE;
|
|
81
|
-
return message;
|
|
82
|
-
}
|
|
83
|
-
async set_attribute(attributes) {
|
|
84
|
-
var _a, _b, _c;
|
|
85
|
-
const messageToSend = {
|
|
86
|
-
POWER: undefined,
|
|
87
|
-
SET: undefined,
|
|
88
|
-
NEW_PROTOCOL_SET: undefined,
|
|
89
|
-
};
|
|
90
|
-
try {
|
|
91
|
-
for (const [k, v] of Object.entries(attributes)) {
|
|
92
|
-
if (v === this.attributes[k]) {
|
|
93
|
-
this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
|
|
97
|
-
if (this.precision_halves && k === 'TARGET_TEMPERATURE') {
|
|
98
|
-
const value = (v * 2) | 0;
|
|
99
|
-
this.attributes[k] = value;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
this.attributes[k] = v;
|
|
103
|
-
}
|
|
104
|
-
// not sensor data
|
|
105
|
-
if (!['BURNING_STATE', 'CURRENT_TEMPERATURE', 'PROTECTION'].includes(k)) {
|
|
106
|
-
if (k === 'POWER') {
|
|
107
|
-
(_a = messageToSend.POWER) !== null && _a !== void 0 ? _a : (messageToSend.POWER = new MideaE3Message_1.MessagePower(this.device_protocol_version));
|
|
108
|
-
messageToSend.POWER.power = v;
|
|
109
|
-
}
|
|
110
|
-
else if (this._old_subtypes.includes(this.sub_type)) {
|
|
111
|
-
(_b = messageToSend.SET) !== null && _b !== void 0 ? _b : (messageToSend.SET = this.make_message_set());
|
|
112
|
-
messageToSend.SET[k.toLowerCase()] = v;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
(_c = messageToSend.NEW_PROTOCOL_SET) !== null && _c !== void 0 ? _c : (messageToSend.NEW_PROTOCOL_SET = new MideaE3Message_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
116
|
-
messageToSend.NEW_PROTOCOL_SET.key = k;
|
|
117
|
-
messageToSend.NEW_PROTOCOL_SET.value = v;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
for (const [k, v] of Object.entries(messageToSend)) {
|
|
122
|
-
if (v !== undefined) {
|
|
123
|
-
this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
|
|
124
|
-
await this.build_send(v);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
catch (err) {
|
|
129
|
-
const msg = err instanceof Error ? err.stack : err;
|
|
130
|
-
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
set_subtype() {
|
|
134
|
-
this.logger.debug('No subtype for E3 device');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.default = MideaE3Device;
|
|
1
|
+
"use strict";
|
|
2
|
+
/***********************************************************************
|
|
3
|
+
* Midea Gas 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 MideaE3Message_1 = require("./MideaE3Message");
|
|
16
|
+
class MideaE3Device 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._old_subtypes = [32, 33, 34, 35, 36, 37, 40, 43, 48, 49, 80];
|
|
26
|
+
this.attributes = {
|
|
27
|
+
POWER: false,
|
|
28
|
+
BURNING_STATE: false,
|
|
29
|
+
ZERO_COLD_WATER: false,
|
|
30
|
+
PROTECTION: false,
|
|
31
|
+
ZERO_COLD_PULSE: false,
|
|
32
|
+
SMART_VOLUME: false,
|
|
33
|
+
CURRENT_TEMPERATURE: undefined,
|
|
34
|
+
TARGET_TEMPERATURE: 40,
|
|
35
|
+
};
|
|
36
|
+
this._precision_halves = deviceConfig.E3_options.precisionHalves;
|
|
37
|
+
}
|
|
38
|
+
get precision_halves() {
|
|
39
|
+
return this._precision_halves;
|
|
40
|
+
}
|
|
41
|
+
build_query() {
|
|
42
|
+
return [new MideaE3Message_1.MessageQuery(this.device_protocol_version)];
|
|
43
|
+
}
|
|
44
|
+
process_message(msg) {
|
|
45
|
+
const message = new MideaE3Message_1.MessageE3Response(msg);
|
|
46
|
+
if (this.verbose) {
|
|
47
|
+
this.logger.debug(`[${this.name}] Body:\n${JSON.stringify(message.body)}`);
|
|
48
|
+
}
|
|
49
|
+
const changed = {};
|
|
50
|
+
for (const status of Object.keys(this.attributes)) {
|
|
51
|
+
let value = message.get_body_attribute(status.toLowerCase());
|
|
52
|
+
if (value !== undefined) {
|
|
53
|
+
if (this.attributes[status] !== value) {
|
|
54
|
+
// Track only those attributes that change value. So when we send to the Homebridge /
|
|
55
|
+
// HomeKit accessory we only update values that change. First time through this
|
|
56
|
+
// should be most/all attributes having initialized them to invalid values.
|
|
57
|
+
if (this.precision_halves && ['CURRENT_TEMPERATURE', 'TARGET_TEMPERATURE'].includes(status)) {
|
|
58
|
+
value = value / 2;
|
|
59
|
+
}
|
|
60
|
+
this.logger.debug(`[${this.name}] Value for ${status} changed from '${this.attributes[status]}' to '${value}'`);
|
|
61
|
+
changed[status] = value;
|
|
62
|
+
}
|
|
63
|
+
this.attributes[status] = value;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Now we update Homebridge / Homekit accessory
|
|
67
|
+
if (Object.keys(changed).length > 0) {
|
|
68
|
+
this.update(changed);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.logger.debug(`[${this.name}] Status unchanged`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
make_message_set() {
|
|
75
|
+
const message = new MideaE3Message_1.MessageSet(this.device_protocol_version);
|
|
76
|
+
message.zero_cold_water = this.attributes.ZERO_COLD_WATER;
|
|
77
|
+
message.protection = this.attributes.PROTECTION;
|
|
78
|
+
message.zero_cold_pulse = this.attributes.ZERO_COLD_PULSE;
|
|
79
|
+
message.smart_volume = this.attributes.SMART_VOLUME;
|
|
80
|
+
message.target_temperature = this.attributes.TARGET_TEMPERATURE;
|
|
81
|
+
return message;
|
|
82
|
+
}
|
|
83
|
+
async set_attribute(attributes) {
|
|
84
|
+
var _a, _b, _c;
|
|
85
|
+
const messageToSend = {
|
|
86
|
+
POWER: undefined,
|
|
87
|
+
SET: undefined,
|
|
88
|
+
NEW_PROTOCOL_SET: undefined,
|
|
89
|
+
};
|
|
90
|
+
try {
|
|
91
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
92
|
+
if (v === this.attributes[k]) {
|
|
93
|
+
this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
|
|
97
|
+
if (this.precision_halves && k === 'TARGET_TEMPERATURE') {
|
|
98
|
+
const value = (v * 2) | 0;
|
|
99
|
+
this.attributes[k] = value;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.attributes[k] = v;
|
|
103
|
+
}
|
|
104
|
+
// not sensor data
|
|
105
|
+
if (!['BURNING_STATE', 'CURRENT_TEMPERATURE', 'PROTECTION'].includes(k)) {
|
|
106
|
+
if (k === 'POWER') {
|
|
107
|
+
(_a = messageToSend.POWER) !== null && _a !== void 0 ? _a : (messageToSend.POWER = new MideaE3Message_1.MessagePower(this.device_protocol_version));
|
|
108
|
+
messageToSend.POWER.power = v;
|
|
109
|
+
}
|
|
110
|
+
else if (this._old_subtypes.includes(this.sub_type)) {
|
|
111
|
+
(_b = messageToSend.SET) !== null && _b !== void 0 ? _b : (messageToSend.SET = this.make_message_set());
|
|
112
|
+
messageToSend.SET[k.toLowerCase()] = v;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
(_c = messageToSend.NEW_PROTOCOL_SET) !== null && _c !== void 0 ? _c : (messageToSend.NEW_PROTOCOL_SET = new MideaE3Message_1.MessageNewProtocolSet(this.device_protocol_version));
|
|
116
|
+
messageToSend.NEW_PROTOCOL_SET.key = k;
|
|
117
|
+
messageToSend.NEW_PROTOCOL_SET.value = v;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
for (const [k, v] of Object.entries(messageToSend)) {
|
|
122
|
+
if (v !== undefined) {
|
|
123
|
+
this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
|
|
124
|
+
await this.build_send(v);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
const msg = err instanceof Error ? err.stack : err;
|
|
130
|
+
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
set_subtype() {
|
|
134
|
+
this.logger.debug('No subtype for E3 device');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.default = MideaE3Device;
|
|
138
138
|
//# sourceMappingURL=MideaE3Device.js.map
|