homebridge-midea-platform 1.1.2-beta.3 → 1.1.2-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/dist/accessory/AccessoryFactory.d.ts +12 -12
- package/dist/accessory/AccessoryFactory.js +31 -31
- package/dist/accessory/AirConditionerAccessory.d.ts +86 -86
- package/dist/accessory/AirConditionerAccessory.js +560 -560
- 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/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 +60 -60
- 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 +49 -49
- package/dist/core/MideaConstants.js +57 -57
- 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 +242 -242
- package/dist/core/MideaUtils.d.ts +32 -32
- package/dist/core/MideaUtils.js +181 -181
- package/dist/devices/DeviceFactory.d.ts +12 -12
- package/dist/devices/DeviceFactory.js +33 -33
- package/dist/devices/a1/MideaA1Device.d.ts +76 -76
- package/dist/devices/a1/MideaA1Device.js +136 -136
- package/dist/devices/a1/MideaA1Message.d.ts +40 -40
- package/dist/devices/a1/MideaA1Message.js +198 -198
- package/dist/devices/ac/MideaACDevice.d.ts +100 -100
- package/dist/devices/ac/MideaACDevice.js +370 -370
- package/dist/devices/ac/MideaACMessage.d.ts +92 -92
- package/dist/devices/ac/MideaACMessage.js +589 -589
- package/dist/devices/db/MideaDBDevice.d.ts +29 -29
- package/dist/devices/db/MideaDBDevice.js +88 -88
- package/dist/devices/db/MideaDBMessage.d.ts +32 -32
- package/dist/devices/db/MideaDBMessage.js +101 -101
- package/dist/devices/e2/MideaE2Device.d.ts +44 -44
- package/dist/devices/e2/MideaE2Device.js +119 -119
- 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 +125 -125
- 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 +92 -92
- 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 +213 -213
- package/dist/platformUtils.d.ts +98 -98
- package/dist/platformUtils.js +96 -96
- package/dist/settings.d.ts +8 -8
- package/dist/settings.js +11 -11
- package/package.json +1 -1
|
@@ -1,126 +1,126 @@
|
|
|
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
|
-
try {
|
|
85
|
-
for (const [k, v] of Object.entries(attributes)) {
|
|
86
|
-
let message;
|
|
87
|
-
// not sensor data
|
|
88
|
-
if (!['BURNING_STATE', 'CURRENT_TEMPERATURE', 'PROTECTION'].includes(k)) {
|
|
89
|
-
let value = v;
|
|
90
|
-
if (this.precision_halves && k === 'TARGET_TEMPERATURE') {
|
|
91
|
-
value = (v * 2) | 0;
|
|
92
|
-
}
|
|
93
|
-
this.attributes[k] = value;
|
|
94
|
-
if (k === 'POWER') {
|
|
95
|
-
message = new MideaE3Message_1.MessagePower(this.device_protocol_version);
|
|
96
|
-
if (message instanceof MideaE3Message_1.MessagePower) {
|
|
97
|
-
message.power = value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (this._old_subtypes.includes(this.sub_type)) {
|
|
101
|
-
message = this.make_message_set();
|
|
102
|
-
message[k.toLowerCase()] = value;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
message = new MideaE3Message_1.MessageNewProtocolSet(this.device_protocol_version);
|
|
106
|
-
message.key = k;
|
|
107
|
-
message.value = value;
|
|
108
|
-
}
|
|
109
|
-
if (message) {
|
|
110
|
-
this.logger.debug(`[${this.name}] Set message:\n${JSON.stringify(message)}`);
|
|
111
|
-
await this.build_send(message);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
const msg = err instanceof Error ? err.stack : err;
|
|
118
|
-
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
set_subtype() {
|
|
122
|
-
this.logger.debug('No subtype for E3 device');
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
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
|
+
try {
|
|
85
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
86
|
+
let message;
|
|
87
|
+
// not sensor data
|
|
88
|
+
if (!['BURNING_STATE', 'CURRENT_TEMPERATURE', 'PROTECTION'].includes(k)) {
|
|
89
|
+
let value = v;
|
|
90
|
+
if (this.precision_halves && k === 'TARGET_TEMPERATURE') {
|
|
91
|
+
value = (v * 2) | 0;
|
|
92
|
+
}
|
|
93
|
+
this.attributes[k] = value;
|
|
94
|
+
if (k === 'POWER') {
|
|
95
|
+
message = new MideaE3Message_1.MessagePower(this.device_protocol_version);
|
|
96
|
+
if (message instanceof MideaE3Message_1.MessagePower) {
|
|
97
|
+
message.power = value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (this._old_subtypes.includes(this.sub_type)) {
|
|
101
|
+
message = this.make_message_set();
|
|
102
|
+
message[k.toLowerCase()] = value;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
message = new MideaE3Message_1.MessageNewProtocolSet(this.device_protocol_version);
|
|
106
|
+
message.key = k;
|
|
107
|
+
message.value = value;
|
|
108
|
+
}
|
|
109
|
+
if (message) {
|
|
110
|
+
this.logger.debug(`[${this.name}] Set message:\n${JSON.stringify(message)}`);
|
|
111
|
+
await this.build_send(message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
const msg = err instanceof Error ? err.stack : err;
|
|
118
|
+
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
set_subtype() {
|
|
122
|
+
this.logger.debug('No subtype for E3 device');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.default = MideaE3Device;
|
|
126
126
|
//# sourceMappingURL=MideaE3Device.js.map
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { MessageBody, MessageRequest, MessageResponse, MessageType } from '../../core/MideaMessage';
|
|
3
|
-
export declare enum NewProtocolTags {
|
|
4
|
-
ZERO_COLD_WATER = 3,
|
|
5
|
-
ZERO_COLD_PULSE = 4,
|
|
6
|
-
SMART_VOLUME = 7,
|
|
7
|
-
TARGET_TEMPERATURE = 8
|
|
8
|
-
}
|
|
9
|
-
declare abstract class MessageE3Base extends MessageRequest {
|
|
10
|
-
constructor(device_protocol_version: number, message_type: MessageType, body_type: number);
|
|
11
|
-
}
|
|
12
|
-
export declare class MessageQuery extends MessageE3Base {
|
|
13
|
-
constructor(device_protocol_version: number);
|
|
14
|
-
get _body(): Buffer;
|
|
15
|
-
}
|
|
16
|
-
export declare class MessagePower extends MessageE3Base {
|
|
17
|
-
power: boolean;
|
|
18
|
-
constructor(device_protocol_version: number);
|
|
19
|
-
get _body(): Buffer;
|
|
20
|
-
}
|
|
21
|
-
export declare class MessageSet extends MessageE3Base {
|
|
22
|
-
target_temperature: number;
|
|
23
|
-
zero_cold_water: boolean;
|
|
24
|
-
bathtub_volume: number;
|
|
25
|
-
protection: boolean;
|
|
26
|
-
zero_cold_pulse: boolean;
|
|
27
|
-
smart_volume: boolean;
|
|
28
|
-
constructor(device_protocol_version: number);
|
|
29
|
-
get _body(): Buffer;
|
|
30
|
-
}
|
|
31
|
-
export declare class MessageNewProtocolSet extends MessageE3Base {
|
|
32
|
-
key?: keyof typeof NewProtocolTags;
|
|
33
|
-
value?: number | boolean;
|
|
34
|
-
constructor(device_protocol_version: number);
|
|
35
|
-
get _body(): Buffer;
|
|
36
|
-
}
|
|
37
|
-
export declare class E3GeneralMessageBody extends MessageBody {
|
|
38
|
-
power: boolean;
|
|
39
|
-
burning_state: boolean;
|
|
40
|
-
zero_cold_water: boolean;
|
|
41
|
-
current_temperature: number;
|
|
42
|
-
target_temperature: number;
|
|
43
|
-
protection: boolean;
|
|
44
|
-
zero_cold_pulse: boolean;
|
|
45
|
-
smart_volume: boolean;
|
|
46
|
-
constructor(body: Buffer);
|
|
47
|
-
}
|
|
48
|
-
export declare class MessageE3Response extends MessageResponse {
|
|
49
|
-
constructor(message: Buffer);
|
|
50
|
-
}
|
|
51
|
-
export {};
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { MessageBody, MessageRequest, MessageResponse, MessageType } from '../../core/MideaMessage';
|
|
3
|
+
export declare enum NewProtocolTags {
|
|
4
|
+
ZERO_COLD_WATER = 3,
|
|
5
|
+
ZERO_COLD_PULSE = 4,
|
|
6
|
+
SMART_VOLUME = 7,
|
|
7
|
+
TARGET_TEMPERATURE = 8
|
|
8
|
+
}
|
|
9
|
+
declare abstract class MessageE3Base extends MessageRequest {
|
|
10
|
+
constructor(device_protocol_version: number, message_type: MessageType, body_type: number);
|
|
11
|
+
}
|
|
12
|
+
export declare class MessageQuery extends MessageE3Base {
|
|
13
|
+
constructor(device_protocol_version: number);
|
|
14
|
+
get _body(): Buffer;
|
|
15
|
+
}
|
|
16
|
+
export declare class MessagePower extends MessageE3Base {
|
|
17
|
+
power: boolean;
|
|
18
|
+
constructor(device_protocol_version: number);
|
|
19
|
+
get _body(): Buffer;
|
|
20
|
+
}
|
|
21
|
+
export declare class MessageSet extends MessageE3Base {
|
|
22
|
+
target_temperature: number;
|
|
23
|
+
zero_cold_water: boolean;
|
|
24
|
+
bathtub_volume: number;
|
|
25
|
+
protection: boolean;
|
|
26
|
+
zero_cold_pulse: boolean;
|
|
27
|
+
smart_volume: boolean;
|
|
28
|
+
constructor(device_protocol_version: number);
|
|
29
|
+
get _body(): Buffer;
|
|
30
|
+
}
|
|
31
|
+
export declare class MessageNewProtocolSet extends MessageE3Base {
|
|
32
|
+
key?: keyof typeof NewProtocolTags;
|
|
33
|
+
value?: number | boolean;
|
|
34
|
+
constructor(device_protocol_version: number);
|
|
35
|
+
get _body(): Buffer;
|
|
36
|
+
}
|
|
37
|
+
export declare class E3GeneralMessageBody extends MessageBody {
|
|
38
|
+
power: boolean;
|
|
39
|
+
burning_state: boolean;
|
|
40
|
+
zero_cold_water: boolean;
|
|
41
|
+
current_temperature: number;
|
|
42
|
+
target_temperature: number;
|
|
43
|
+
protection: boolean;
|
|
44
|
+
zero_cold_pulse: boolean;
|
|
45
|
+
smart_volume: boolean;
|
|
46
|
+
constructor(body: Buffer);
|
|
47
|
+
}
|
|
48
|
+
export declare class MessageE3Response extends MessageResponse {
|
|
49
|
+
constructor(message: Buffer);
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
52
52
|
//# sourceMappingURL=MideaE3Message.d.ts.map
|
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageE3Response = exports.E3GeneralMessageBody = exports.MessageNewProtocolSet = exports.MessageSet = exports.MessagePower = exports.MessageQuery = exports.NewProtocolTags = void 0;
|
|
4
|
-
/***********************************************************************
|
|
5
|
-
* Midea Gas 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
|
-
var NewProtocolTags;
|
|
15
|
-
(function (NewProtocolTags) {
|
|
16
|
-
NewProtocolTags[NewProtocolTags["ZERO_COLD_WATER"] = 3] = "ZERO_COLD_WATER";
|
|
17
|
-
NewProtocolTags[NewProtocolTags["ZERO_COLD_PULSE"] = 4] = "ZERO_COLD_PULSE";
|
|
18
|
-
NewProtocolTags[NewProtocolTags["SMART_VOLUME"] = 7] = "SMART_VOLUME";
|
|
19
|
-
NewProtocolTags[NewProtocolTags["TARGET_TEMPERATURE"] = 8] = "TARGET_TEMPERATURE";
|
|
20
|
-
})(NewProtocolTags = exports.NewProtocolTags || (exports.NewProtocolTags = {}));
|
|
21
|
-
class MessageE3Base extends MideaMessage_1.MessageRequest {
|
|
22
|
-
constructor(device_protocol_version, message_type, body_type) {
|
|
23
|
-
super(MideaConstants_1.DeviceType.GAS_WATER_HEATER, message_type, body_type, device_protocol_version);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
class MessageQuery extends MessageE3Base {
|
|
27
|
-
constructor(device_protocol_version) {
|
|
28
|
-
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x01);
|
|
29
|
-
}
|
|
30
|
-
get _body() {
|
|
31
|
-
return Buffer.from([0x01]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.MessageQuery = MessageQuery;
|
|
35
|
-
class MessagePower extends MessageE3Base {
|
|
36
|
-
constructor(device_protocol_version) {
|
|
37
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x02);
|
|
38
|
-
this.power = false;
|
|
39
|
-
}
|
|
40
|
-
get _body() {
|
|
41
|
-
if (this.power) {
|
|
42
|
-
this.body_type = 0x01;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
this.body_type = 0x02;
|
|
46
|
-
}
|
|
47
|
-
return Buffer.from([0x01]);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.MessagePower = MessagePower;
|
|
51
|
-
class MessageSet extends MessageE3Base {
|
|
52
|
-
constructor(device_protocol_version) {
|
|
53
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x04);
|
|
54
|
-
this.target_temperature = 0;
|
|
55
|
-
this.zero_cold_water = false;
|
|
56
|
-
this.bathtub_volume = 0;
|
|
57
|
-
this.protection = false;
|
|
58
|
-
this.zero_cold_pulse = false;
|
|
59
|
-
this.smart_volume = false;
|
|
60
|
-
}
|
|
61
|
-
get _body() {
|
|
62
|
-
// Byte 2 zero_cold_water mode
|
|
63
|
-
const zero_cold_water = this.zero_cold_water ? 0x01 : 0x00;
|
|
64
|
-
// Byte 3
|
|
65
|
-
const protection = this.protection ? 0x08 : 0x00;
|
|
66
|
-
const zero_cold_pulse = this.zero_cold_pulse ? 0x10 : 0x00;
|
|
67
|
-
const smart_volume = this.smart_volume ? 0x20 : 0x00;
|
|
68
|
-
// Byte 5
|
|
69
|
-
const target_temperature = this.target_temperature & 0xff;
|
|
70
|
-
return Buffer.from([
|
|
71
|
-
0x01,
|
|
72
|
-
zero_cold_water | 0x02,
|
|
73
|
-
protection | zero_cold_pulse | smart_volume,
|
|
74
|
-
0x00,
|
|
75
|
-
target_temperature,
|
|
76
|
-
0x00,
|
|
77
|
-
0x00,
|
|
78
|
-
0x00,
|
|
79
|
-
0x00,
|
|
80
|
-
0x00,
|
|
81
|
-
0x00,
|
|
82
|
-
0x00,
|
|
83
|
-
0x00,
|
|
84
|
-
0x00,
|
|
85
|
-
]);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.MessageSet = MessageSet;
|
|
89
|
-
class MessageNewProtocolSet extends MessageE3Base {
|
|
90
|
-
constructor(device_protocol_version) {
|
|
91
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x14);
|
|
92
|
-
}
|
|
93
|
-
get _body() {
|
|
94
|
-
if (this.key === undefined || this.value === undefined) {
|
|
95
|
-
throw new Error('key and value must be set');
|
|
96
|
-
}
|
|
97
|
-
const key = NewProtocolTags[this.key];
|
|
98
|
-
if (key === undefined) {
|
|
99
|
-
throw new Error('Invalid key');
|
|
100
|
-
}
|
|
101
|
-
let value;
|
|
102
|
-
if (this.key === 'TARGET_TEMPERATURE') {
|
|
103
|
-
value = this.value;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
value = this.value ? 0x01 : 0x00;
|
|
107
|
-
}
|
|
108
|
-
return Buffer.from([key, value, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.MessageNewProtocolSet = MessageNewProtocolSet;
|
|
112
|
-
class E3GeneralMessageBody extends MideaMessage_1.MessageBody {
|
|
113
|
-
constructor(body) {
|
|
114
|
-
super(body);
|
|
115
|
-
this.power = (body[2] & 0x01) > 0;
|
|
116
|
-
this.burning_state = (body[2] & 0x02) > 0;
|
|
117
|
-
this.zero_cold_water = (body[2] & 0x04) > 0;
|
|
118
|
-
this.current_temperature = body[5];
|
|
119
|
-
this.target_temperature = body[6];
|
|
120
|
-
this.protection = (body[8] & 0x08) > 0;
|
|
121
|
-
this.zero_cold_pulse = body.length > 20 ? (body[20] & 0x01) > 0 : false;
|
|
122
|
-
this.smart_volume = body.length > 20 ? (body[20] & 0x02) > 0 : false;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.E3GeneralMessageBody = E3GeneralMessageBody;
|
|
126
|
-
class MessageE3Response extends MideaMessage_1.MessageResponse {
|
|
127
|
-
constructor(message) {
|
|
128
|
-
super(message);
|
|
129
|
-
if ((this.message_type === MideaMessage_1.MessageType.QUERY && this.body_type === 0x01) ||
|
|
130
|
-
(this.message_type === MideaMessage_1.MessageType.SET && [0x01, 0x02, 0x04, 0x14].includes(this.body_type)) ||
|
|
131
|
-
(this.message_type === MideaMessage_1.MessageType.NOTIFY1 && [0x00, 0x01].includes(this.body_type))) {
|
|
132
|
-
this.set_body(new E3GeneralMessageBody(this.body));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.MessageE3Response = MessageE3Response;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageE3Response = exports.E3GeneralMessageBody = exports.MessageNewProtocolSet = exports.MessageSet = exports.MessagePower = exports.MessageQuery = exports.NewProtocolTags = void 0;
|
|
4
|
+
/***********************************************************************
|
|
5
|
+
* Midea Gas 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
|
+
var NewProtocolTags;
|
|
15
|
+
(function (NewProtocolTags) {
|
|
16
|
+
NewProtocolTags[NewProtocolTags["ZERO_COLD_WATER"] = 3] = "ZERO_COLD_WATER";
|
|
17
|
+
NewProtocolTags[NewProtocolTags["ZERO_COLD_PULSE"] = 4] = "ZERO_COLD_PULSE";
|
|
18
|
+
NewProtocolTags[NewProtocolTags["SMART_VOLUME"] = 7] = "SMART_VOLUME";
|
|
19
|
+
NewProtocolTags[NewProtocolTags["TARGET_TEMPERATURE"] = 8] = "TARGET_TEMPERATURE";
|
|
20
|
+
})(NewProtocolTags = exports.NewProtocolTags || (exports.NewProtocolTags = {}));
|
|
21
|
+
class MessageE3Base extends MideaMessage_1.MessageRequest {
|
|
22
|
+
constructor(device_protocol_version, message_type, body_type) {
|
|
23
|
+
super(MideaConstants_1.DeviceType.GAS_WATER_HEATER, message_type, body_type, device_protocol_version);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class MessageQuery extends MessageE3Base {
|
|
27
|
+
constructor(device_protocol_version) {
|
|
28
|
+
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, 0x01);
|
|
29
|
+
}
|
|
30
|
+
get _body() {
|
|
31
|
+
return Buffer.from([0x01]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.MessageQuery = MessageQuery;
|
|
35
|
+
class MessagePower extends MessageE3Base {
|
|
36
|
+
constructor(device_protocol_version) {
|
|
37
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x02);
|
|
38
|
+
this.power = false;
|
|
39
|
+
}
|
|
40
|
+
get _body() {
|
|
41
|
+
if (this.power) {
|
|
42
|
+
this.body_type = 0x01;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.body_type = 0x02;
|
|
46
|
+
}
|
|
47
|
+
return Buffer.from([0x01]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.MessagePower = MessagePower;
|
|
51
|
+
class MessageSet extends MessageE3Base {
|
|
52
|
+
constructor(device_protocol_version) {
|
|
53
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x04);
|
|
54
|
+
this.target_temperature = 0;
|
|
55
|
+
this.zero_cold_water = false;
|
|
56
|
+
this.bathtub_volume = 0;
|
|
57
|
+
this.protection = false;
|
|
58
|
+
this.zero_cold_pulse = false;
|
|
59
|
+
this.smart_volume = false;
|
|
60
|
+
}
|
|
61
|
+
get _body() {
|
|
62
|
+
// Byte 2 zero_cold_water mode
|
|
63
|
+
const zero_cold_water = this.zero_cold_water ? 0x01 : 0x00;
|
|
64
|
+
// Byte 3
|
|
65
|
+
const protection = this.protection ? 0x08 : 0x00;
|
|
66
|
+
const zero_cold_pulse = this.zero_cold_pulse ? 0x10 : 0x00;
|
|
67
|
+
const smart_volume = this.smart_volume ? 0x20 : 0x00;
|
|
68
|
+
// Byte 5
|
|
69
|
+
const target_temperature = this.target_temperature & 0xff;
|
|
70
|
+
return Buffer.from([
|
|
71
|
+
0x01,
|
|
72
|
+
zero_cold_water | 0x02,
|
|
73
|
+
protection | zero_cold_pulse | smart_volume,
|
|
74
|
+
0x00,
|
|
75
|
+
target_temperature,
|
|
76
|
+
0x00,
|
|
77
|
+
0x00,
|
|
78
|
+
0x00,
|
|
79
|
+
0x00,
|
|
80
|
+
0x00,
|
|
81
|
+
0x00,
|
|
82
|
+
0x00,
|
|
83
|
+
0x00,
|
|
84
|
+
0x00,
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.MessageSet = MessageSet;
|
|
89
|
+
class MessageNewProtocolSet extends MessageE3Base {
|
|
90
|
+
constructor(device_protocol_version) {
|
|
91
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x14);
|
|
92
|
+
}
|
|
93
|
+
get _body() {
|
|
94
|
+
if (this.key === undefined || this.value === undefined) {
|
|
95
|
+
throw new Error('key and value must be set');
|
|
96
|
+
}
|
|
97
|
+
const key = NewProtocolTags[this.key];
|
|
98
|
+
if (key === undefined) {
|
|
99
|
+
throw new Error('Invalid key');
|
|
100
|
+
}
|
|
101
|
+
let value;
|
|
102
|
+
if (this.key === 'TARGET_TEMPERATURE') {
|
|
103
|
+
value = this.value;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
value = this.value ? 0x01 : 0x00;
|
|
107
|
+
}
|
|
108
|
+
return Buffer.from([key, value, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.MessageNewProtocolSet = MessageNewProtocolSet;
|
|
112
|
+
class E3GeneralMessageBody extends MideaMessage_1.MessageBody {
|
|
113
|
+
constructor(body) {
|
|
114
|
+
super(body);
|
|
115
|
+
this.power = (body[2] & 0x01) > 0;
|
|
116
|
+
this.burning_state = (body[2] & 0x02) > 0;
|
|
117
|
+
this.zero_cold_water = (body[2] & 0x04) > 0;
|
|
118
|
+
this.current_temperature = body[5];
|
|
119
|
+
this.target_temperature = body[6];
|
|
120
|
+
this.protection = (body[8] & 0x08) > 0;
|
|
121
|
+
this.zero_cold_pulse = body.length > 20 ? (body[20] & 0x01) > 0 : false;
|
|
122
|
+
this.smart_volume = body.length > 20 ? (body[20] & 0x02) > 0 : false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.E3GeneralMessageBody = E3GeneralMessageBody;
|
|
126
|
+
class MessageE3Response extends MideaMessage_1.MessageResponse {
|
|
127
|
+
constructor(message) {
|
|
128
|
+
super(message);
|
|
129
|
+
if ((this.message_type === MideaMessage_1.MessageType.QUERY && this.body_type === 0x01) ||
|
|
130
|
+
(this.message_type === MideaMessage_1.MessageType.SET && [0x01, 0x02, 0x04, 0x14].includes(this.body_type)) ||
|
|
131
|
+
(this.message_type === MideaMessage_1.MessageType.NOTIFY1 && [0x00, 0x01].includes(this.body_type))) {
|
|
132
|
+
this.set_body(new E3GeneralMessageBody(this.body));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.MessageE3Response = MessageE3Response;
|
|
137
137
|
//# sourceMappingURL=MideaE3Message.js.map
|