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.
Files changed (69) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/dist/accessory/AccessoryFactory.d.ts +12 -12
  3. package/dist/accessory/AccessoryFactory.js +31 -31
  4. package/dist/accessory/AirConditionerAccessory.d.ts +86 -86
  5. package/dist/accessory/AirConditionerAccessory.js +560 -560
  6. package/dist/accessory/AirConditionerAccessory.js.map +1 -1
  7. package/dist/accessory/BaseAccessory.d.ts +11 -11
  8. package/dist/accessory/BaseAccessory.js +21 -21
  9. package/dist/accessory/DehumidifierAccessory.d.ts +45 -45
  10. package/dist/accessory/DehumidifierAccessory.js +344 -344
  11. package/dist/accessory/ElectricWaterHeaterAccessory.d.ts +44 -44
  12. package/dist/accessory/ElectricWaterHeaterAccessory.js +176 -176
  13. package/dist/accessory/FanAccessory.d.ts +39 -39
  14. package/dist/accessory/FanAccessory.js +123 -123
  15. package/dist/accessory/FrontLoadWasherAccessory.d.ts +30 -30
  16. package/dist/accessory/FrontLoadWasherAccessory.js +60 -60
  17. package/dist/accessory/GasWaterHeaterAccessory.d.ts +51 -51
  18. package/dist/accessory/GasWaterHeaterAccessory.js +216 -216
  19. package/dist/core/MideaCloud.d.ts +35 -35
  20. package/dist/core/MideaCloud.js +350 -350
  21. package/dist/core/MideaConstants.d.ts +49 -49
  22. package/dist/core/MideaConstants.js +57 -57
  23. package/dist/core/MideaDevice.d.ts +76 -76
  24. package/dist/core/MideaDevice.js +409 -409
  25. package/dist/core/MideaDiscover.d.ts +35 -35
  26. package/dist/core/MideaDiscover.js +212 -212
  27. package/dist/core/MideaMessage.d.ts +75 -75
  28. package/dist/core/MideaMessage.js +184 -184
  29. package/dist/core/MideaPacketBuilder.d.ts +10 -10
  30. package/dist/core/MideaPacketBuilder.js +60 -60
  31. package/dist/core/MideaSecurity.d.ts +63 -63
  32. package/dist/core/MideaSecurity.js +242 -242
  33. package/dist/core/MideaUtils.d.ts +32 -32
  34. package/dist/core/MideaUtils.js +181 -181
  35. package/dist/devices/DeviceFactory.d.ts +12 -12
  36. package/dist/devices/DeviceFactory.js +33 -33
  37. package/dist/devices/a1/MideaA1Device.d.ts +76 -76
  38. package/dist/devices/a1/MideaA1Device.js +136 -136
  39. package/dist/devices/a1/MideaA1Message.d.ts +40 -40
  40. package/dist/devices/a1/MideaA1Message.js +198 -198
  41. package/dist/devices/ac/MideaACDevice.d.ts +100 -100
  42. package/dist/devices/ac/MideaACDevice.js +370 -370
  43. package/dist/devices/ac/MideaACMessage.d.ts +92 -92
  44. package/dist/devices/ac/MideaACMessage.js +589 -589
  45. package/dist/devices/db/MideaDBDevice.d.ts +29 -29
  46. package/dist/devices/db/MideaDBDevice.js +88 -88
  47. package/dist/devices/db/MideaDBMessage.d.ts +32 -32
  48. package/dist/devices/db/MideaDBMessage.js +101 -101
  49. package/dist/devices/e2/MideaE2Device.d.ts +44 -44
  50. package/dist/devices/e2/MideaE2Device.js +119 -119
  51. package/dist/devices/e2/MideaE2Message.d.ts +33 -33
  52. package/dist/devices/e2/MideaE2Message.js +132 -132
  53. package/dist/devices/e3/MideaE3Device.d.ts +43 -43
  54. package/dist/devices/e3/MideaE3Device.js +125 -125
  55. package/dist/devices/e3/MideaE3Message.d.ts +51 -51
  56. package/dist/devices/e3/MideaE3Message.js +136 -136
  57. package/dist/devices/fa/MideaFADevice.d.ts +36 -36
  58. package/dist/devices/fa/MideaFADevice.js +92 -92
  59. package/dist/devices/fa/MideaFAMessage.d.ts +38 -38
  60. package/dist/devices/fa/MideaFAMessage.js +98 -98
  61. package/dist/index.d.ts +6 -6
  62. package/dist/index.js +6 -6
  63. package/dist/platform.d.ts +60 -60
  64. package/dist/platform.js +213 -213
  65. package/dist/platformUtils.d.ts +98 -98
  66. package/dist/platformUtils.js +96 -96
  67. package/dist/settings.d.ts +8 -8
  68. package/dist/settings.js +11 -11
  69. package/package.json +1 -1
@@ -1,124 +1,124 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
7
- class FanAccessory extends BaseAccessory_1.default {
8
- /*********************************************************************
9
- * Constructor registers all the service types with Homebridge, registers
10
- * a callback function with the MideaDevice class, and requests device status.
11
- */
12
- constructor(platform, accessory, device, configDev) {
13
- super(platform, accessory, device, configDev);
14
- this.device = device;
15
- this.configDev = configDev;
16
- this.service = this.accessory.getService(this.platform.Service.Fanv2) || this.accessory.addService(this.platform.Service.Fanv2);
17
- this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
18
- // this.service
19
- // .getCharacteristic(this.platform.Characteristic.TargetFanState)
20
- // .onGet(this.getTargetFanState.bind(this))
21
- // .onSet(this.setTargetFanState.bind(this));
22
- this.service.getCharacteristic(this.platform.Characteristic.CurrentFanState).onGet(this.getCurrentFanState.bind(this));
23
- this.service
24
- .getCharacteristic(this.platform.Characteristic.RotationSpeed)
25
- .onGet(this.getRotationSpeed.bind(this))
26
- .onSet(this.setRotationSpeed.bind(this));
27
- // this.service
28
- // .getCharacteristic(this.platform.Characteristic.RotationDirection)
29
- // .onGet(this.getRotationDirection.bind(this))
30
- // .onSet(this.setRotationDirection.bind(this));
31
- // this.service
32
- // .getCharacteristic(this.platform.Characteristic.SwingMode)
33
- // .onGet(this.getSwingMode.bind(this))
34
- // .onSet(this.setSwingMode.bind(this));
35
- this.service
36
- .getCharacteristic(this.platform.Characteristic.LockPhysicalControls)
37
- .onGet(this.getLockPhysicalControls.bind(this))
38
- .onSet(this.setLockPhysicalControls.bind(this));
39
- }
40
- async updateCharacteristics(attributes) {
41
- let updateState = false;
42
- for (const [k, v] of Object.entries(attributes)) {
43
- this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
44
- switch (k) {
45
- case 'power':
46
- updateState = true;
47
- break;
48
- case 'mode':
49
- this.service.updateCharacteristic(this.platform.Characteristic.TargetFanState, this.getTargetFanState());
50
- break;
51
- case 'fan_speed':
52
- this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.getRotationSpeed());
53
- break;
54
- case 'child_lock':
55
- this.service.updateCharacteristic(this.platform.Characteristic.LockPhysicalControls, this.getLockPhysicalControls());
56
- break;
57
- // case 'oscillate':
58
- // case 'oscillation_angle':
59
- // case 'oscillation_mode':
60
- // case 'tilting_angle':
61
- // this.service.updateCharacteristic(this.platform.Characteristic.SwingMode, this.getSwingMode());
62
- // break;
63
- default:
64
- this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
65
- break;
66
- }
67
- }
68
- if (updateState) {
69
- this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
70
- }
71
- }
72
- getActive() {
73
- return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
74
- }
75
- async setActive(value) {
76
- await this.device.set_attribute({ POWER: value === this.platform.Characteristic.Active.ACTIVE });
77
- }
78
- getTargetFanState() {
79
- return this.device.attributes.MODE;
80
- }
81
- async setTargetFanState(value) {
82
- throw new Error('Method not implemented.');
83
- }
84
- getCurrentFanState() {
85
- return this.device.attributes.POWER
86
- ? this.device.attributes.FAN_SPEED > 0
87
- ? this.platform.Characteristic.CurrentFanState.BLOWING_AIR
88
- : this.platform.Characteristic.CurrentFanState.IDLE
89
- : this.platform.Characteristic.CurrentFanState.INACTIVE;
90
- }
91
- getRotationSpeed() {
92
- return this.device.attributes.FAN_SPEED;
93
- }
94
- async setRotationSpeed(value) {
95
- await this.device.set_attribute({ FAN_SPEED: value });
96
- }
97
- getRotationDirection() {
98
- throw new Error('Method not implemented.');
99
- }
100
- async setRotationDirection(value) {
101
- throw new Error('Method not implemented.');
102
- }
103
- getSwingMode() {
104
- return this.device.attributes.OSCILLATE
105
- ? this.platform.Characteristic.SwingMode.SWING_ENABLED
106
- : this.platform.Characteristic.SwingMode.SWING_DISABLED;
107
- }
108
- async setSwingMode(value) {
109
- await this.device.set_attribute({
110
- OSCILLATE: value === this.platform.Characteristic.SwingMode.SWING_ENABLED,
111
- OSCILLATION_MODE: value === this.platform.Characteristic.SwingMode.SWING_ENABLED ? 1 : 0,
112
- });
113
- }
114
- getLockPhysicalControls() {
115
- return this.device.attributes.CHILD_LOCK
116
- ? this.platform.Characteristic.LockPhysicalControls.CONTROL_LOCK_ENABLED
117
- : this.platform.Characteristic.LockPhysicalControls.CONTROL_LOCK_DISABLED;
118
- }
119
- async setLockPhysicalControls(value) {
120
- await this.device.set_attribute({ CHILD_LOCK: value === this.platform.Characteristic.LockPhysicalControls.CONTROL_LOCK_ENABLED });
121
- }
122
- }
123
- exports.default = FanAccessory;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
7
+ class FanAccessory extends BaseAccessory_1.default {
8
+ /*********************************************************************
9
+ * Constructor registers all the service types with Homebridge, registers
10
+ * a callback function with the MideaDevice class, and requests device status.
11
+ */
12
+ constructor(platform, accessory, device, configDev) {
13
+ super(platform, accessory, device, configDev);
14
+ this.device = device;
15
+ this.configDev = configDev;
16
+ this.service = this.accessory.getService(this.platform.Service.Fanv2) || this.accessory.addService(this.platform.Service.Fanv2);
17
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
18
+ // this.service
19
+ // .getCharacteristic(this.platform.Characteristic.TargetFanState)
20
+ // .onGet(this.getTargetFanState.bind(this))
21
+ // .onSet(this.setTargetFanState.bind(this));
22
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentFanState).onGet(this.getCurrentFanState.bind(this));
23
+ this.service
24
+ .getCharacteristic(this.platform.Characteristic.RotationSpeed)
25
+ .onGet(this.getRotationSpeed.bind(this))
26
+ .onSet(this.setRotationSpeed.bind(this));
27
+ // this.service
28
+ // .getCharacteristic(this.platform.Characteristic.RotationDirection)
29
+ // .onGet(this.getRotationDirection.bind(this))
30
+ // .onSet(this.setRotationDirection.bind(this));
31
+ // this.service
32
+ // .getCharacteristic(this.platform.Characteristic.SwingMode)
33
+ // .onGet(this.getSwingMode.bind(this))
34
+ // .onSet(this.setSwingMode.bind(this));
35
+ this.service
36
+ .getCharacteristic(this.platform.Characteristic.LockPhysicalControls)
37
+ .onGet(this.getLockPhysicalControls.bind(this))
38
+ .onSet(this.setLockPhysicalControls.bind(this));
39
+ }
40
+ async updateCharacteristics(attributes) {
41
+ let updateState = false;
42
+ for (const [k, v] of Object.entries(attributes)) {
43
+ this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
44
+ switch (k) {
45
+ case 'power':
46
+ updateState = true;
47
+ break;
48
+ case 'mode':
49
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetFanState, this.getTargetFanState());
50
+ break;
51
+ case 'fan_speed':
52
+ this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.getRotationSpeed());
53
+ break;
54
+ case 'child_lock':
55
+ this.service.updateCharacteristic(this.platform.Characteristic.LockPhysicalControls, this.getLockPhysicalControls());
56
+ break;
57
+ // case 'oscillate':
58
+ // case 'oscillation_angle':
59
+ // case 'oscillation_mode':
60
+ // case 'tilting_angle':
61
+ // this.service.updateCharacteristic(this.platform.Characteristic.SwingMode, this.getSwingMode());
62
+ // break;
63
+ default:
64
+ this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
65
+ break;
66
+ }
67
+ }
68
+ if (updateState) {
69
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
70
+ }
71
+ }
72
+ getActive() {
73
+ return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
74
+ }
75
+ async setActive(value) {
76
+ await this.device.set_attribute({ POWER: value === this.platform.Characteristic.Active.ACTIVE });
77
+ }
78
+ getTargetFanState() {
79
+ return this.device.attributes.MODE;
80
+ }
81
+ async setTargetFanState(value) {
82
+ throw new Error('Method not implemented.');
83
+ }
84
+ getCurrentFanState() {
85
+ return this.device.attributes.POWER
86
+ ? this.device.attributes.FAN_SPEED > 0
87
+ ? this.platform.Characteristic.CurrentFanState.BLOWING_AIR
88
+ : this.platform.Characteristic.CurrentFanState.IDLE
89
+ : this.platform.Characteristic.CurrentFanState.INACTIVE;
90
+ }
91
+ getRotationSpeed() {
92
+ return this.device.attributes.FAN_SPEED;
93
+ }
94
+ async setRotationSpeed(value) {
95
+ await this.device.set_attribute({ FAN_SPEED: value });
96
+ }
97
+ getRotationDirection() {
98
+ throw new Error('Method not implemented.');
99
+ }
100
+ async setRotationDirection(value) {
101
+ throw new Error('Method not implemented.');
102
+ }
103
+ getSwingMode() {
104
+ return this.device.attributes.OSCILLATE
105
+ ? this.platform.Characteristic.SwingMode.SWING_ENABLED
106
+ : this.platform.Characteristic.SwingMode.SWING_DISABLED;
107
+ }
108
+ async setSwingMode(value) {
109
+ await this.device.set_attribute({
110
+ OSCILLATE: value === this.platform.Characteristic.SwingMode.SWING_ENABLED,
111
+ OSCILLATION_MODE: value === this.platform.Characteristic.SwingMode.SWING_ENABLED ? 1 : 0,
112
+ });
113
+ }
114
+ getLockPhysicalControls() {
115
+ return this.device.attributes.CHILD_LOCK
116
+ ? this.platform.Characteristic.LockPhysicalControls.CONTROL_LOCK_ENABLED
117
+ : this.platform.Characteristic.LockPhysicalControls.CONTROL_LOCK_DISABLED;
118
+ }
119
+ async setLockPhysicalControls(value) {
120
+ await this.device.set_attribute({ CHILD_LOCK: value === this.platform.Characteristic.LockPhysicalControls.CONTROL_LOCK_ENABLED });
121
+ }
122
+ }
123
+ exports.default = FanAccessory;
124
124
  //# sourceMappingURL=FanAccessory.js.map
@@ -1,31 +1,31 @@
1
- /***********************************************************************
2
- * Midea Platform Front Load Washer Accessory class
3
- *
4
- * Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
5
- *
6
- * Based on https://github.com/homebridge/homebridge-plugin-template
7
- *
8
- * An instance of this class is created for each accessory the platform registers.
9
- *
10
- */
11
- import { CharacteristicValue } from 'homebridge';
12
- import { MideaAccessory, MideaPlatform } from '../platform';
13
- import BaseAccessory from './BaseAccessory';
14
- import { DeviceConfig } from '../platformUtils';
15
- import MideaDBDevice, { DBAttributes } from '../devices/db/MideaDBDevice';
16
- export default class FanAccessory extends BaseAccessory<MideaDBDevice> {
17
- protected readonly device: MideaDBDevice;
18
- protected readonly configDev: DeviceConfig;
19
- private service;
20
- /*********************************************************************
21
- * Constructor registers all the service types with Homebridge, registers
22
- * a callback function with the MideaDevice class, and requests device status.
23
- */
24
- constructor(platform: MideaPlatform, accessory: MideaAccessory, device: MideaDBDevice, configDev: DeviceConfig);
25
- updateCharacteristics(attributes: Partial<DBAttributes>): Promise<void>;
26
- getActive(): CharacteristicValue;
27
- setActive(value: CharacteristicValue): Promise<void>;
28
- getInUse(): CharacteristicValue;
29
- getRemainingDuration(): CharacteristicValue;
30
- }
1
+ /***********************************************************************
2
+ * Midea Platform Front Load Washer Accessory class
3
+ *
4
+ * Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
5
+ *
6
+ * Based on https://github.com/homebridge/homebridge-plugin-template
7
+ *
8
+ * An instance of this class is created for each accessory the platform registers.
9
+ *
10
+ */
11
+ import { CharacteristicValue } from 'homebridge';
12
+ import { MideaAccessory, MideaPlatform } from '../platform';
13
+ import BaseAccessory from './BaseAccessory';
14
+ import { DeviceConfig } from '../platformUtils';
15
+ import MideaDBDevice, { DBAttributes } from '../devices/db/MideaDBDevice';
16
+ export default class FanAccessory extends BaseAccessory<MideaDBDevice> {
17
+ protected readonly device: MideaDBDevice;
18
+ protected readonly configDev: DeviceConfig;
19
+ private service;
20
+ /*********************************************************************
21
+ * Constructor registers all the service types with Homebridge, registers
22
+ * a callback function with the MideaDevice class, and requests device status.
23
+ */
24
+ constructor(platform: MideaPlatform, accessory: MideaAccessory, device: MideaDBDevice, configDev: DeviceConfig);
25
+ updateCharacteristics(attributes: Partial<DBAttributes>): Promise<void>;
26
+ getActive(): CharacteristicValue;
27
+ setActive(value: CharacteristicValue): Promise<void>;
28
+ getInUse(): CharacteristicValue;
29
+ getRemainingDuration(): CharacteristicValue;
30
+ }
31
31
  //# sourceMappingURL=FrontLoadWasherAccessory.d.ts.map
@@ -1,61 +1,61 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
7
- class FanAccessory extends BaseAccessory_1.default {
8
- /*********************************************************************
9
- * Constructor registers all the service types with Homebridge, registers
10
- * a callback function with the MideaDevice class, and requests device status.
11
- */
12
- constructor(platform, accessory, device, configDev) {
13
- super(platform, accessory, device, configDev);
14
- this.device = device;
15
- this.configDev = configDev;
16
- this.service = this.accessory.getService(this.platform.Service.Valve) || this.accessory.addService(this.platform.Service.Valve);
17
- this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
18
- this.service.getCharacteristic(this.platform.Characteristic.InUse).onGet(this.getInUse.bind(this));
19
- this.service.getCharacteristic(this.platform.Characteristic.RemainingDuration).onGet(this.getRemainingDuration.bind(this));
20
- }
21
- async updateCharacteristics(attributes) {
22
- let updateState = false;
23
- for (const [k, v] of Object.entries(attributes)) {
24
- this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
25
- switch (k) {
26
- case 'power':
27
- updateState = true;
28
- break;
29
- case 'start':
30
- updateState = true;
31
- break;
32
- case 'time_remaining':
33
- case 'progress':
34
- updateState = true;
35
- break;
36
- default:
37
- this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
38
- break;
39
- }
40
- }
41
- if (updateState) {
42
- this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
43
- this.service.updateCharacteristic(this.platform.Characteristic.InUse, this.getInUse());
44
- this.service.updateCharacteristic(this.platform.Characteristic.RemainingDuration, this.getRemainingDuration());
45
- }
46
- }
47
- getActive() {
48
- return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
49
- }
50
- async setActive(value) {
51
- await this.device.set_attribute({ POWER: value === this.platform.Characteristic.Active.ACTIVE });
52
- }
53
- getInUse() {
54
- return this.device.attributes.START ? this.platform.Characteristic.InUse.IN_USE : this.platform.Characteristic.InUse.NOT_IN_USE;
55
- }
56
- getRemainingDuration() {
57
- return this.device.attributes.TIME_REMAINING;
58
- }
59
- }
60
- exports.default = FanAccessory;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const BaseAccessory_1 = __importDefault(require("./BaseAccessory"));
7
+ class FanAccessory extends BaseAccessory_1.default {
8
+ /*********************************************************************
9
+ * Constructor registers all the service types with Homebridge, registers
10
+ * a callback function with the MideaDevice class, and requests device status.
11
+ */
12
+ constructor(platform, accessory, device, configDev) {
13
+ super(platform, accessory, device, configDev);
14
+ this.device = device;
15
+ this.configDev = configDev;
16
+ this.service = this.accessory.getService(this.platform.Service.Valve) || this.accessory.addService(this.platform.Service.Valve);
17
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onGet(this.getActive.bind(this)).onSet(this.setActive.bind(this));
18
+ this.service.getCharacteristic(this.platform.Characteristic.InUse).onGet(this.getInUse.bind(this));
19
+ this.service.getCharacteristic(this.platform.Characteristic.RemainingDuration).onGet(this.getRemainingDuration.bind(this));
20
+ }
21
+ async updateCharacteristics(attributes) {
22
+ let updateState = false;
23
+ for (const [k, v] of Object.entries(attributes)) {
24
+ this.platform.log.debug(`[${this.device.name}] Set attribute ${k} to: ${v}`);
25
+ switch (k) {
26
+ case 'power':
27
+ updateState = true;
28
+ break;
29
+ case 'start':
30
+ updateState = true;
31
+ break;
32
+ case 'time_remaining':
33
+ case 'progress':
34
+ updateState = true;
35
+ break;
36
+ default:
37
+ this.platform.log.debug(`[${this.device.name}] Attempt to set unsupported attribute ${k} to ${v}`);
38
+ break;
39
+ }
40
+ }
41
+ if (updateState) {
42
+ this.service.updateCharacteristic(this.platform.Characteristic.Active, this.getActive());
43
+ this.service.updateCharacteristic(this.platform.Characteristic.InUse, this.getInUse());
44
+ this.service.updateCharacteristic(this.platform.Characteristic.RemainingDuration, this.getRemainingDuration());
45
+ }
46
+ }
47
+ getActive() {
48
+ return this.device.attributes.POWER ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
49
+ }
50
+ async setActive(value) {
51
+ await this.device.set_attribute({ POWER: value === this.platform.Characteristic.Active.ACTIVE });
52
+ }
53
+ getInUse() {
54
+ return this.device.attributes.START ? this.platform.Characteristic.InUse.IN_USE : this.platform.Characteristic.InUse.NOT_IN_USE;
55
+ }
56
+ getRemainingDuration() {
57
+ return this.device.attributes.TIME_REMAINING;
58
+ }
59
+ }
60
+ exports.default = FanAccessory;
61
61
  //# sourceMappingURL=FrontLoadWasherAccessory.js.map
@@ -1,52 +1,52 @@
1
- /***********************************************************************
2
- * Midea Platform Gas Water Heater Accessory class
3
- *
4
- * Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
5
- *
6
- * Based on https://github.com/homebridge/homebridge-plugin-template
7
- *
8
- * An instance of this class is created for each accessory the platform registers.
9
- *
10
- */
11
- import { CharacteristicValue } from 'homebridge';
12
- import MideaE3Device, { E3Attributes } from '../devices/e3/MideaE3Device';
13
- import BaseAccessory from './BaseAccessory';
14
- import { MideaAccessory, MideaPlatform } from '../platform';
15
- import { DeviceConfig } from '../platformUtils';
16
- export default class GasWaterHeaterAccessory extends BaseAccessory<MideaE3Device> {
17
- protected readonly device: MideaE3Device;
18
- protected readonly configDev: DeviceConfig;
19
- private service;
20
- private burningStateService?;
21
- private protectionService?;
22
- private zeroColdWaterService?;
23
- private zeroColdPulseService?;
24
- private smartVolumeService?;
25
- constructor(platform: MideaPlatform, accessory: MideaAccessory, device: MideaE3Device, configDev: DeviceConfig);
26
- /*********************************************************************
27
- * Callback function called by MideaDevice whenever there is a change to
28
- * any attribute value.
29
- */
30
- protected updateCharacteristics(attributes: Partial<E3Attributes>): Promise<void>;
31
- /*********************************************************************
32
- * Callback functions for each Homebridge/HomeKit service
33
- *
34
- */
35
- getActive(): CharacteristicValue;
36
- setActive(value: CharacteristicValue): Promise<void>;
37
- getCurrentHeaterCoolerState(): CharacteristicValue;
38
- getTargetHeaterCoolerState(): CharacteristicValue;
39
- setTargetHeaterCoolerState(value: CharacteristicValue): Promise<void>;
40
- getCurrentTemperature(): CharacteristicValue;
41
- getTargetTemperature(): CharacteristicValue;
42
- setTargetTemperature(value: CharacteristicValue): Promise<void>;
43
- getBurningState(): CharacteristicValue;
44
- getProtection(): CharacteristicValue;
45
- getZeroColdWater(): CharacteristicValue;
46
- setZeroColdWater(value: CharacteristicValue): Promise<void>;
47
- getZeroColdPulse(): CharacteristicValue;
48
- setZeroColdPulse(value: CharacteristicValue): Promise<void>;
49
- getSmartVolume(): CharacteristicValue;
50
- setSmartVolume(value: CharacteristicValue): Promise<void>;
51
- }
1
+ /***********************************************************************
2
+ * Midea Platform Gas Water Heater Accessory class
3
+ *
4
+ * Copyright (c) 2024 Kovalovszky Patrik, https://github.com/kovapatrik
5
+ *
6
+ * Based on https://github.com/homebridge/homebridge-plugin-template
7
+ *
8
+ * An instance of this class is created for each accessory the platform registers.
9
+ *
10
+ */
11
+ import { CharacteristicValue } from 'homebridge';
12
+ import MideaE3Device, { E3Attributes } from '../devices/e3/MideaE3Device';
13
+ import BaseAccessory from './BaseAccessory';
14
+ import { MideaAccessory, MideaPlatform } from '../platform';
15
+ import { DeviceConfig } from '../platformUtils';
16
+ export default class GasWaterHeaterAccessory extends BaseAccessory<MideaE3Device> {
17
+ protected readonly device: MideaE3Device;
18
+ protected readonly configDev: DeviceConfig;
19
+ private service;
20
+ private burningStateService?;
21
+ private protectionService?;
22
+ private zeroColdWaterService?;
23
+ private zeroColdPulseService?;
24
+ private smartVolumeService?;
25
+ constructor(platform: MideaPlatform, accessory: MideaAccessory, device: MideaE3Device, configDev: DeviceConfig);
26
+ /*********************************************************************
27
+ * Callback function called by MideaDevice whenever there is a change to
28
+ * any attribute value.
29
+ */
30
+ protected updateCharacteristics(attributes: Partial<E3Attributes>): Promise<void>;
31
+ /*********************************************************************
32
+ * Callback functions for each Homebridge/HomeKit service
33
+ *
34
+ */
35
+ getActive(): CharacteristicValue;
36
+ setActive(value: CharacteristicValue): Promise<void>;
37
+ getCurrentHeaterCoolerState(): CharacteristicValue;
38
+ getTargetHeaterCoolerState(): CharacteristicValue;
39
+ setTargetHeaterCoolerState(value: CharacteristicValue): Promise<void>;
40
+ getCurrentTemperature(): CharacteristicValue;
41
+ getTargetTemperature(): CharacteristicValue;
42
+ setTargetTemperature(value: CharacteristicValue): Promise<void>;
43
+ getBurningState(): CharacteristicValue;
44
+ getProtection(): CharacteristicValue;
45
+ getZeroColdWater(): CharacteristicValue;
46
+ setZeroColdWater(value: CharacteristicValue): Promise<void>;
47
+ getZeroColdPulse(): CharacteristicValue;
48
+ setZeroColdPulse(value: CharacteristicValue): Promise<void>;
49
+ getSmartVolume(): CharacteristicValue;
50
+ setSmartVolume(value: CharacteristicValue): Promise<void>;
51
+ }
52
52
  //# sourceMappingURL=GasWaterHeaterAccessory.d.ts.map