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,107 +1,107 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/***********************************************************************
|
|
3
|
-
* Midea Fan 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 MideaFAMessage_1 = require("./MideaFAMessage");
|
|
16
|
-
class MideaFADevice extends MideaDevice_1.default {
|
|
17
|
-
constructor(logger, device_info, config, deviceConfig) {
|
|
18
|
-
super(logger, device_info, config, deviceConfig);
|
|
19
|
-
this.attributes = {
|
|
20
|
-
POWER: false,
|
|
21
|
-
CHILD_LOCK: false,
|
|
22
|
-
MODE: 0,
|
|
23
|
-
FAN_SPEED: 0,
|
|
24
|
-
OSCILLATE: false,
|
|
25
|
-
OSCILLATION_ANGLE: 0,
|
|
26
|
-
OSCILLATION_MODE: 0,
|
|
27
|
-
TILTING_ANGLE: 0,
|
|
28
|
-
};
|
|
29
|
-
this.default_speed_count = 3;
|
|
30
|
-
this.speed_count = this.default_speed_count;
|
|
31
|
-
}
|
|
32
|
-
build_query() {
|
|
33
|
-
return [new MideaFAMessage_1.MessageQuery(this.device_protocol_version)];
|
|
34
|
-
}
|
|
35
|
-
process_message(msg) {
|
|
36
|
-
const message = new MideaFAMessage_1.MessageFAResponse(msg);
|
|
37
|
-
if (this.verbose) {
|
|
38
|
-
this.logger.debug(`[${this.name}] Body:\n${JSON.stringify(message.body)}`);
|
|
39
|
-
}
|
|
40
|
-
const changed = {};
|
|
41
|
-
for (const status of Object.keys(this.attributes)) {
|
|
42
|
-
const value = message.get_body_attribute(status.toLowerCase());
|
|
43
|
-
if (value !== undefined) {
|
|
44
|
-
if (this.attributes[status] !== value) {
|
|
45
|
-
// Track only those attributes that change value. So when we send to the Homebridge /
|
|
46
|
-
// HomeKit accessory we only update values that change. First time through this
|
|
47
|
-
// should be most/all attributes having initialized them to invalid values.
|
|
48
|
-
this.logger.debug(`[${this.name}] Value for ${status} changed from '${this.attributes[status]}' to '${value}'`);
|
|
49
|
-
changed[status] = value;
|
|
50
|
-
}
|
|
51
|
-
this.attributes[status] = value;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// Now we update Homebridge / Homekit accessory
|
|
55
|
-
if (Object.keys(changed).length > 0) {
|
|
56
|
-
this.update(changed);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
this.logger.debug(`[${this.name}] Status unchanged`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
set_subtype() {
|
|
63
|
-
this.logger.debug('No subtype for FA device');
|
|
64
|
-
}
|
|
65
|
-
make_message_set() {
|
|
66
|
-
const message = new MideaFAMessage_1.MessageSet(this.device_protocol_version, this.sub_type);
|
|
67
|
-
message.power = this.attributes.POWER;
|
|
68
|
-
message.lock = this.attributes.CHILD_LOCK;
|
|
69
|
-
message.mode = this.attributes.MODE;
|
|
70
|
-
message.fan_speed = this.attributes.FAN_SPEED;
|
|
71
|
-
message.oscillate = this.attributes.OSCILLATE;
|
|
72
|
-
message.oscillation_angle = this.attributes.OSCILLATION_ANGLE;
|
|
73
|
-
message.oscillation_mode = this.attributes.OSCILLATION_MODE;
|
|
74
|
-
message.tilting_angle = this.attributes.TILTING_ANGLE;
|
|
75
|
-
return message;
|
|
76
|
-
}
|
|
77
|
-
async set_attribute(attributes) {
|
|
78
|
-
var _a;
|
|
79
|
-
const messageToSend = {
|
|
80
|
-
SET: undefined,
|
|
81
|
-
};
|
|
82
|
-
try {
|
|
83
|
-
for (const [k, v] of Object.entries(attributes)) {
|
|
84
|
-
if (v === this.attributes[k]) {
|
|
85
|
-
this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
|
|
89
|
-
this.attributes[k] = v;
|
|
90
|
-
(_a = messageToSend.SET) !== null && _a !== void 0 ? _a : (messageToSend.SET = this.make_message_set());
|
|
91
|
-
messageToSend.SET[k.toLowerCase()] = v;
|
|
92
|
-
}
|
|
93
|
-
for (const [k, v] of Object.entries(messageToSend)) {
|
|
94
|
-
if (v !== undefined) {
|
|
95
|
-
this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
|
|
96
|
-
await this.build_send(v);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
catch (err) {
|
|
101
|
-
const msg = err instanceof Error ? err.stack : err;
|
|
102
|
-
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.default = MideaFADevice;
|
|
1
|
+
"use strict";
|
|
2
|
+
/***********************************************************************
|
|
3
|
+
* Midea Fan 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 MideaFAMessage_1 = require("./MideaFAMessage");
|
|
16
|
+
class MideaFADevice extends MideaDevice_1.default {
|
|
17
|
+
constructor(logger, device_info, config, deviceConfig) {
|
|
18
|
+
super(logger, device_info, config, deviceConfig);
|
|
19
|
+
this.attributes = {
|
|
20
|
+
POWER: false,
|
|
21
|
+
CHILD_LOCK: false,
|
|
22
|
+
MODE: 0,
|
|
23
|
+
FAN_SPEED: 0,
|
|
24
|
+
OSCILLATE: false,
|
|
25
|
+
OSCILLATION_ANGLE: 0,
|
|
26
|
+
OSCILLATION_MODE: 0,
|
|
27
|
+
TILTING_ANGLE: 0,
|
|
28
|
+
};
|
|
29
|
+
this.default_speed_count = 3;
|
|
30
|
+
this.speed_count = this.default_speed_count;
|
|
31
|
+
}
|
|
32
|
+
build_query() {
|
|
33
|
+
return [new MideaFAMessage_1.MessageQuery(this.device_protocol_version)];
|
|
34
|
+
}
|
|
35
|
+
process_message(msg) {
|
|
36
|
+
const message = new MideaFAMessage_1.MessageFAResponse(msg);
|
|
37
|
+
if (this.verbose) {
|
|
38
|
+
this.logger.debug(`[${this.name}] Body:\n${JSON.stringify(message.body)}`);
|
|
39
|
+
}
|
|
40
|
+
const changed = {};
|
|
41
|
+
for (const status of Object.keys(this.attributes)) {
|
|
42
|
+
const value = message.get_body_attribute(status.toLowerCase());
|
|
43
|
+
if (value !== undefined) {
|
|
44
|
+
if (this.attributes[status] !== value) {
|
|
45
|
+
// Track only those attributes that change value. So when we send to the Homebridge /
|
|
46
|
+
// HomeKit accessory we only update values that change. First time through this
|
|
47
|
+
// should be most/all attributes having initialized them to invalid values.
|
|
48
|
+
this.logger.debug(`[${this.name}] Value for ${status} changed from '${this.attributes[status]}' to '${value}'`);
|
|
49
|
+
changed[status] = value;
|
|
50
|
+
}
|
|
51
|
+
this.attributes[status] = value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Now we update Homebridge / Homekit accessory
|
|
55
|
+
if (Object.keys(changed).length > 0) {
|
|
56
|
+
this.update(changed);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.logger.debug(`[${this.name}] Status unchanged`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
set_subtype() {
|
|
63
|
+
this.logger.debug('No subtype for FA device');
|
|
64
|
+
}
|
|
65
|
+
make_message_set() {
|
|
66
|
+
const message = new MideaFAMessage_1.MessageSet(this.device_protocol_version, this.sub_type);
|
|
67
|
+
message.power = this.attributes.POWER;
|
|
68
|
+
message.lock = this.attributes.CHILD_LOCK;
|
|
69
|
+
message.mode = this.attributes.MODE;
|
|
70
|
+
message.fan_speed = this.attributes.FAN_SPEED;
|
|
71
|
+
message.oscillate = this.attributes.OSCILLATE;
|
|
72
|
+
message.oscillation_angle = this.attributes.OSCILLATION_ANGLE;
|
|
73
|
+
message.oscillation_mode = this.attributes.OSCILLATION_MODE;
|
|
74
|
+
message.tilting_angle = this.attributes.TILTING_ANGLE;
|
|
75
|
+
return message;
|
|
76
|
+
}
|
|
77
|
+
async set_attribute(attributes) {
|
|
78
|
+
var _a;
|
|
79
|
+
const messageToSend = {
|
|
80
|
+
SET: undefined,
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
84
|
+
if (v === this.attributes[k]) {
|
|
85
|
+
this.logger.info(`[${this.name}] Attribute ${k} already set to ${v}`);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
this.logger.info(`[${this.name}] Set device attribute ${k} to: ${v}`);
|
|
89
|
+
this.attributes[k] = v;
|
|
90
|
+
(_a = messageToSend.SET) !== null && _a !== void 0 ? _a : (messageToSend.SET = this.make_message_set());
|
|
91
|
+
messageToSend.SET[k.toLowerCase()] = v;
|
|
92
|
+
}
|
|
93
|
+
for (const [k, v] of Object.entries(messageToSend)) {
|
|
94
|
+
if (v !== undefined) {
|
|
95
|
+
this.logger.debug(`[${this.name}] Set message ${k}:\n${JSON.stringify(v)}`);
|
|
96
|
+
await this.build_send(v);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
const msg = err instanceof Error ? err.stack : err;
|
|
102
|
+
this.logger.debug(`[${this.name}] Error in set_attribute (${this.ip}:${this.port}):\n${msg}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.default = MideaFADevice;
|
|
107
107
|
//# sourceMappingURL=MideaFADevice.js.map
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { MessageBody, MessageRequest, MessageResponse, MessageType } from '../../core/MideaMessage';
|
|
3
|
-
declare abstract class MessageFABase extends MessageRequest {
|
|
4
|
-
constructor(device_protocol_version: number, message_type: MessageType, body_type: number | null);
|
|
5
|
-
}
|
|
6
|
-
export declare class MessageQuery extends MessageFABase {
|
|
7
|
-
constructor(device_protocol_version: number);
|
|
8
|
-
get _body(): Buffer;
|
|
9
|
-
get body(): Buffer;
|
|
10
|
-
}
|
|
11
|
-
export declare class MessageSet extends MessageFABase {
|
|
12
|
-
private subtype;
|
|
13
|
-
power?: boolean;
|
|
14
|
-
lock?: boolean;
|
|
15
|
-
mode?: number;
|
|
16
|
-
fan_speed?: number;
|
|
17
|
-
oscillate?: boolean;
|
|
18
|
-
oscillation_angle?: number;
|
|
19
|
-
oscillation_mode?: number;
|
|
20
|
-
tilting_angle?: number;
|
|
21
|
-
constructor(device_protocol_version: number, subtype: number);
|
|
22
|
-
get _body(): Buffer;
|
|
23
|
-
}
|
|
24
|
-
export declare class FAGeneralMessageBody extends MessageBody {
|
|
25
|
-
child_lock: boolean;
|
|
26
|
-
power: boolean;
|
|
27
|
-
mode: number;
|
|
28
|
-
fan_speed: number;
|
|
29
|
-
oscillate: boolean;
|
|
30
|
-
oscillation_angle: number;
|
|
31
|
-
oscillation_mode: number;
|
|
32
|
-
tilting_angle: number;
|
|
33
|
-
constructor(body: Buffer);
|
|
34
|
-
}
|
|
35
|
-
export declare class MessageFAResponse extends MessageResponse {
|
|
36
|
-
constructor(message: Buffer);
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { MessageBody, MessageRequest, MessageResponse, MessageType } from '../../core/MideaMessage';
|
|
3
|
+
declare abstract class MessageFABase extends MessageRequest {
|
|
4
|
+
constructor(device_protocol_version: number, message_type: MessageType, body_type: number | null);
|
|
5
|
+
}
|
|
6
|
+
export declare class MessageQuery extends MessageFABase {
|
|
7
|
+
constructor(device_protocol_version: number);
|
|
8
|
+
get _body(): Buffer;
|
|
9
|
+
get body(): Buffer;
|
|
10
|
+
}
|
|
11
|
+
export declare class MessageSet extends MessageFABase {
|
|
12
|
+
private subtype;
|
|
13
|
+
power?: boolean;
|
|
14
|
+
lock?: boolean;
|
|
15
|
+
mode?: number;
|
|
16
|
+
fan_speed?: number;
|
|
17
|
+
oscillate?: boolean;
|
|
18
|
+
oscillation_angle?: number;
|
|
19
|
+
oscillation_mode?: number;
|
|
20
|
+
tilting_angle?: number;
|
|
21
|
+
constructor(device_protocol_version: number, subtype: number);
|
|
22
|
+
get _body(): Buffer;
|
|
23
|
+
}
|
|
24
|
+
export declare class FAGeneralMessageBody extends MessageBody {
|
|
25
|
+
child_lock: boolean;
|
|
26
|
+
power: boolean;
|
|
27
|
+
mode: number;
|
|
28
|
+
fan_speed: number;
|
|
29
|
+
oscillate: boolean;
|
|
30
|
+
oscillation_angle: number;
|
|
31
|
+
oscillation_mode: number;
|
|
32
|
+
tilting_angle: number;
|
|
33
|
+
constructor(body: Buffer);
|
|
34
|
+
}
|
|
35
|
+
export declare class MessageFAResponse extends MessageResponse {
|
|
36
|
+
constructor(message: Buffer);
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
39
|
//# sourceMappingURL=MideaFAMessage.d.ts.map
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageFAResponse = exports.FAGeneralMessageBody = exports.MessageSet = exports.MessageQuery = void 0;
|
|
4
|
-
const MideaConstants_1 = require("../../core/MideaConstants");
|
|
5
|
-
const MideaMessage_1 = require("../../core/MideaMessage");
|
|
6
|
-
class MessageFABase extends MideaMessage_1.MessageRequest {
|
|
7
|
-
constructor(device_protocol_version, message_type, body_type) {
|
|
8
|
-
super(MideaConstants_1.DeviceType.FAN, message_type, body_type, device_protocol_version);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
class MessageQuery extends MessageFABase {
|
|
12
|
-
constructor(device_protocol_version) {
|
|
13
|
-
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, null);
|
|
14
|
-
}
|
|
15
|
-
get _body() {
|
|
16
|
-
return Buffer.from([]);
|
|
17
|
-
}
|
|
18
|
-
get body() {
|
|
19
|
-
return Buffer.from([]);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.MessageQuery = MessageQuery;
|
|
23
|
-
class MessageSet extends MessageFABase {
|
|
24
|
-
constructor(device_protocol_version, subtype) {
|
|
25
|
-
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x00);
|
|
26
|
-
this.subtype = subtype;
|
|
27
|
-
}
|
|
28
|
-
get _body() {
|
|
29
|
-
let body_return;
|
|
30
|
-
if ((1 <= this.subtype && this.subtype <= 10) || this.subtype === 161) {
|
|
31
|
-
body_return = Buffer.from([
|
|
32
|
-
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
33
|
-
]);
|
|
34
|
-
if (this.subtype !== 10) {
|
|
35
|
-
body_return[13] = 0xff;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
body_return = Buffer.from([
|
|
40
|
-
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
41
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
42
|
-
0x00, 0x00, 0x00, 0x00, 0x00,
|
|
43
|
-
]);
|
|
44
|
-
}
|
|
45
|
-
if (this.power !== undefined) {
|
|
46
|
-
body_return[3] = this.power ? 0x01 : 0x00;
|
|
47
|
-
}
|
|
48
|
-
if (this.lock !== undefined) {
|
|
49
|
-
body_return[2] = this.lock ? 0x01 : 0x03;
|
|
50
|
-
}
|
|
51
|
-
if (this.mode !== undefined) {
|
|
52
|
-
body_return[3] = 0x01 | (((this.mode + 1) << 1) & 0x1e);
|
|
53
|
-
}
|
|
54
|
-
if (this.fan_speed !== undefined && 1 <= this.fan_speed && this.fan_speed <= 26) {
|
|
55
|
-
body_return[4] = this.fan_speed;
|
|
56
|
-
}
|
|
57
|
-
if (this.oscillate !== undefined) {
|
|
58
|
-
body_return[7] = this.oscillate ? 0x01 : 0x00;
|
|
59
|
-
}
|
|
60
|
-
if (this.oscillation_angle !== undefined) {
|
|
61
|
-
body_return[7] = 1 | body_return[7] | ((this.oscillation_angle << 4) & 0x70);
|
|
62
|
-
}
|
|
63
|
-
if (this.oscillation_mode !== undefined) {
|
|
64
|
-
body_return[7] = 1 | body_return[7] | ((this.oscillation_mode << 1) & 0x0e);
|
|
65
|
-
}
|
|
66
|
-
if (this.tilting_angle !== undefined && body_return.length > 24) {
|
|
67
|
-
body_return[24] = this.tilting_angle;
|
|
68
|
-
}
|
|
69
|
-
return body_return;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.MessageSet = MessageSet;
|
|
73
|
-
class FAGeneralMessageBody extends MideaMessage_1.MessageBody {
|
|
74
|
-
constructor(body) {
|
|
75
|
-
super(body);
|
|
76
|
-
const lock = body[3] & 0x03;
|
|
77
|
-
this.child_lock = lock === 0x01;
|
|
78
|
-
this.power = (body[4] & 0x01) > 0;
|
|
79
|
-
const mode = (body[4] & 0x1e) >> 1;
|
|
80
|
-
this.mode = mode > 0 ? mode - 1 : mode;
|
|
81
|
-
const fan_speed = body[5];
|
|
82
|
-
this.fan_speed = 1 <= fan_speed && fan_speed <= 26 ? fan_speed : 0;
|
|
83
|
-
this.oscillate = (body[8] & 0x01) > 0;
|
|
84
|
-
this.oscillation_angle = (body[8] & 0x70) >> 4;
|
|
85
|
-
this.oscillation_mode = (body[8] & 0x0e) >> 1;
|
|
86
|
-
this.tilting_angle = body.length > 25 ? body[25] : 0;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.FAGeneralMessageBody = FAGeneralMessageBody;
|
|
90
|
-
class MessageFAResponse extends MideaMessage_1.MessageResponse {
|
|
91
|
-
constructor(message) {
|
|
92
|
-
super(message);
|
|
93
|
-
if ([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.SET, MideaMessage_1.MessageType.NOTIFY1].includes(this.message_type)) {
|
|
94
|
-
this.set_body(new FAGeneralMessageBody(this.body));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.MessageFAResponse = MessageFAResponse;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageFAResponse = exports.FAGeneralMessageBody = exports.MessageSet = exports.MessageQuery = void 0;
|
|
4
|
+
const MideaConstants_1 = require("../../core/MideaConstants");
|
|
5
|
+
const MideaMessage_1 = require("../../core/MideaMessage");
|
|
6
|
+
class MessageFABase extends MideaMessage_1.MessageRequest {
|
|
7
|
+
constructor(device_protocol_version, message_type, body_type) {
|
|
8
|
+
super(MideaConstants_1.DeviceType.FAN, message_type, body_type, device_protocol_version);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
class MessageQuery extends MessageFABase {
|
|
12
|
+
constructor(device_protocol_version) {
|
|
13
|
+
super(device_protocol_version, MideaMessage_1.MessageType.QUERY, null);
|
|
14
|
+
}
|
|
15
|
+
get _body() {
|
|
16
|
+
return Buffer.from([]);
|
|
17
|
+
}
|
|
18
|
+
get body() {
|
|
19
|
+
return Buffer.from([]);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.MessageQuery = MessageQuery;
|
|
23
|
+
class MessageSet extends MessageFABase {
|
|
24
|
+
constructor(device_protocol_version, subtype) {
|
|
25
|
+
super(device_protocol_version, MideaMessage_1.MessageType.SET, 0x00);
|
|
26
|
+
this.subtype = subtype;
|
|
27
|
+
}
|
|
28
|
+
get _body() {
|
|
29
|
+
let body_return;
|
|
30
|
+
if ((1 <= this.subtype && this.subtype <= 10) || this.subtype === 161) {
|
|
31
|
+
body_return = Buffer.from([
|
|
32
|
+
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
33
|
+
]);
|
|
34
|
+
if (this.subtype !== 10) {
|
|
35
|
+
body_return[13] = 0xff;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
body_return = Buffer.from([
|
|
40
|
+
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
41
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
42
|
+
0x00, 0x00, 0x00, 0x00, 0x00,
|
|
43
|
+
]);
|
|
44
|
+
}
|
|
45
|
+
if (this.power !== undefined) {
|
|
46
|
+
body_return[3] = this.power ? 0x01 : 0x00;
|
|
47
|
+
}
|
|
48
|
+
if (this.lock !== undefined) {
|
|
49
|
+
body_return[2] = this.lock ? 0x01 : 0x03;
|
|
50
|
+
}
|
|
51
|
+
if (this.mode !== undefined) {
|
|
52
|
+
body_return[3] = 0x01 | (((this.mode + 1) << 1) & 0x1e);
|
|
53
|
+
}
|
|
54
|
+
if (this.fan_speed !== undefined && 1 <= this.fan_speed && this.fan_speed <= 26) {
|
|
55
|
+
body_return[4] = this.fan_speed;
|
|
56
|
+
}
|
|
57
|
+
if (this.oscillate !== undefined) {
|
|
58
|
+
body_return[7] = this.oscillate ? 0x01 : 0x00;
|
|
59
|
+
}
|
|
60
|
+
if (this.oscillation_angle !== undefined) {
|
|
61
|
+
body_return[7] = 1 | body_return[7] | ((this.oscillation_angle << 4) & 0x70);
|
|
62
|
+
}
|
|
63
|
+
if (this.oscillation_mode !== undefined) {
|
|
64
|
+
body_return[7] = 1 | body_return[7] | ((this.oscillation_mode << 1) & 0x0e);
|
|
65
|
+
}
|
|
66
|
+
if (this.tilting_angle !== undefined && body_return.length > 24) {
|
|
67
|
+
body_return[24] = this.tilting_angle;
|
|
68
|
+
}
|
|
69
|
+
return body_return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.MessageSet = MessageSet;
|
|
73
|
+
class FAGeneralMessageBody extends MideaMessage_1.MessageBody {
|
|
74
|
+
constructor(body) {
|
|
75
|
+
super(body);
|
|
76
|
+
const lock = body[3] & 0x03;
|
|
77
|
+
this.child_lock = lock === 0x01;
|
|
78
|
+
this.power = (body[4] & 0x01) > 0;
|
|
79
|
+
const mode = (body[4] & 0x1e) >> 1;
|
|
80
|
+
this.mode = mode > 0 ? mode - 1 : mode;
|
|
81
|
+
const fan_speed = body[5];
|
|
82
|
+
this.fan_speed = 1 <= fan_speed && fan_speed <= 26 ? fan_speed : 0;
|
|
83
|
+
this.oscillate = (body[8] & 0x01) > 0;
|
|
84
|
+
this.oscillation_angle = (body[8] & 0x70) >> 4;
|
|
85
|
+
this.oscillation_mode = (body[8] & 0x0e) >> 1;
|
|
86
|
+
this.tilting_angle = body.length > 25 ? body[25] : 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.FAGeneralMessageBody = FAGeneralMessageBody;
|
|
90
|
+
class MessageFAResponse extends MideaMessage_1.MessageResponse {
|
|
91
|
+
constructor(message) {
|
|
92
|
+
super(message);
|
|
93
|
+
if ([MideaMessage_1.MessageType.QUERY, MideaMessage_1.MessageType.SET, MideaMessage_1.MessageType.NOTIFY1].includes(this.message_type)) {
|
|
94
|
+
this.set_body(new FAGeneralMessageBody(this.body));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.MessageFAResponse = MessageFAResponse;
|
|
99
99
|
//# sourceMappingURL=MideaFAMessage.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { API } from 'homebridge';
|
|
2
|
-
/**
|
|
3
|
-
* This method registers the platform with Homebridge
|
|
4
|
-
*/
|
|
5
|
-
declare const _default: (api: API) => void;
|
|
6
|
-
export = _default;
|
|
1
|
+
import { API } from 'homebridge';
|
|
2
|
+
/**
|
|
3
|
+
* This method registers the platform with Homebridge
|
|
4
|
+
*/
|
|
5
|
+
declare const _default: (api: API) => void;
|
|
6
|
+
export = _default;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const settings_1 = require("./settings");
|
|
3
|
-
const platform_1 = require("./platform");
|
|
4
|
-
module.exports = (api) => {
|
|
5
|
-
api.registerPlatform(settings_1.PLATFORM_NAME, platform_1.MideaPlatform);
|
|
6
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
const settings_1 = require("./settings");
|
|
3
|
+
const platform_1 = require("./platform");
|
|
4
|
+
module.exports = (api) => {
|
|
5
|
+
api.registerPlatform(settings_1.PLATFORM_NAME, platform_1.MideaPlatform);
|
|
6
|
+
};
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/platform.d.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
/***********************************************************************
|
|
2
|
-
* Midea Homebridge platform initialization
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2023 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
5
|
-
* Portions Copyright (c) 2023 David Kerr, https://github.com/dkerr64
|
|
6
|
-
*
|
|
7
|
-
* Based on https://github.com/homebridge/homebridge-plugin-template
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service, Characteristic } from 'homebridge';
|
|
11
|
-
export interface MideaAccessory extends PlatformAccessory {
|
|
12
|
-
context: {
|
|
13
|
-
token: string;
|
|
14
|
-
key: string;
|
|
15
|
-
id: string;
|
|
16
|
-
type: string;
|
|
17
|
-
sn: string;
|
|
18
|
-
model: string;
|
|
19
|
-
serviceVersion: number;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export declare class MideaPlatform implements DynamicPlatformPlugin {
|
|
23
|
-
readonly log: Logger;
|
|
24
|
-
readonly config: PlatformConfig;
|
|
25
|
-
readonly api: API;
|
|
26
|
-
readonly Service: typeof Service;
|
|
27
|
-
readonly Characteristic: typeof Characteristic;
|
|
28
|
-
readonly accessories: MideaAccessory[];
|
|
29
|
-
private discoveredDevices;
|
|
30
|
-
private discoveryInterval;
|
|
31
|
-
private readonly discover;
|
|
32
|
-
private readonly platformConfig;
|
|
33
|
-
constructor(log: Logger, config: PlatformConfig, api: API);
|
|
34
|
-
/*********************************************************************
|
|
35
|
-
* finishedLaunching
|
|
36
|
-
* Function called when Homebridge has finished loading the plugin.
|
|
37
|
-
*/
|
|
38
|
-
private finishedLaunching;
|
|
39
|
-
/*********************************************************************
|
|
40
|
-
* deviceDiscovered
|
|
41
|
-
* Function called by the 'device' on handler.
|
|
42
|
-
*/
|
|
43
|
-
private deviceDiscovered;
|
|
44
|
-
/*********************************************************************
|
|
45
|
-
* discoveryComplete
|
|
46
|
-
* Function called by the 'complete' on handler.
|
|
47
|
-
*/
|
|
48
|
-
private discoveryComplete;
|
|
49
|
-
/*********************************************************************
|
|
50
|
-
* addDevice
|
|
51
|
-
* Called for each device as discovered on the network. Creates the
|
|
52
|
-
* Midea device handler and the associated Homebridge accessory.
|
|
53
|
-
*/
|
|
54
|
-
private addDevice;
|
|
55
|
-
/**
|
|
56
|
-
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
57
|
-
* It should be used to setup event handlers for characteristics and update respective values.
|
|
58
|
-
*/
|
|
59
|
-
configureAccessory(accessory: MideaAccessory): void;
|
|
60
|
-
}
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* Midea Homebridge platform initialization
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2023 Kovalovszky Patrik, https://github.com/kovapatrik
|
|
5
|
+
* Portions Copyright (c) 2023 David Kerr, https://github.com/dkerr64
|
|
6
|
+
*
|
|
7
|
+
* Based on https://github.com/homebridge/homebridge-plugin-template
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service, Characteristic } from 'homebridge';
|
|
11
|
+
export interface MideaAccessory extends PlatformAccessory {
|
|
12
|
+
context: {
|
|
13
|
+
token: string;
|
|
14
|
+
key: string;
|
|
15
|
+
id: string;
|
|
16
|
+
type: string;
|
|
17
|
+
sn: string;
|
|
18
|
+
model: string;
|
|
19
|
+
serviceVersion: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare class MideaPlatform implements DynamicPlatformPlugin {
|
|
23
|
+
readonly log: Logger;
|
|
24
|
+
readonly config: PlatformConfig;
|
|
25
|
+
readonly api: API;
|
|
26
|
+
readonly Service: typeof Service;
|
|
27
|
+
readonly Characteristic: typeof Characteristic;
|
|
28
|
+
readonly accessories: MideaAccessory[];
|
|
29
|
+
private discoveredDevices;
|
|
30
|
+
private discoveryInterval;
|
|
31
|
+
private readonly discover;
|
|
32
|
+
private readonly platformConfig;
|
|
33
|
+
constructor(log: Logger, config: PlatformConfig, api: API);
|
|
34
|
+
/*********************************************************************
|
|
35
|
+
* finishedLaunching
|
|
36
|
+
* Function called when Homebridge has finished loading the plugin.
|
|
37
|
+
*/
|
|
38
|
+
private finishedLaunching;
|
|
39
|
+
/*********************************************************************
|
|
40
|
+
* deviceDiscovered
|
|
41
|
+
* Function called by the 'device' on handler.
|
|
42
|
+
*/
|
|
43
|
+
private deviceDiscovered;
|
|
44
|
+
/*********************************************************************
|
|
45
|
+
* discoveryComplete
|
|
46
|
+
* Function called by the 'complete' on handler.
|
|
47
|
+
*/
|
|
48
|
+
private discoveryComplete;
|
|
49
|
+
/*********************************************************************
|
|
50
|
+
* addDevice
|
|
51
|
+
* Called for each device as discovered on the network. Creates the
|
|
52
|
+
* Midea device handler and the associated Homebridge accessory.
|
|
53
|
+
*/
|
|
54
|
+
private addDevice;
|
|
55
|
+
/**
|
|
56
|
+
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
57
|
+
* It should be used to setup event handlers for characteristics and update respective values.
|
|
58
|
+
*/
|
|
59
|
+
configureAccessory(accessory: MideaAccessory): void;
|
|
60
|
+
}
|
|
61
61
|
//# sourceMappingURL=platform.d.ts.map
|