@homebridge-plugins/homebridge-smarthq 0.5.0-beta.0 → 0.5.0-beta.10

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 (128) hide show
  1. package/.github/ISSUE_TEMPLATE/config.yml +1 -1
  2. package/.github/copilot-instructions.md +90 -0
  3. package/.github/scripts/branch-helper.sh +41 -0
  4. package/.github/workflows/beta-release.yml +1 -1
  5. package/.github/workflows/release.yml +53 -17
  6. package/CHANGELOG.md +563 -18
  7. package/README.md +15 -0
  8. package/dist/devices/OpalIceMaker/Managers/OpalProgressSvcManager.d.ts +1 -1
  9. package/dist/devices/OpalIceMaker/Managers/OpalProgressSvcManager.d.ts.map +1 -1
  10. package/dist/devices/OpalIceMaker/Managers/OpalProgressSvcManager.js +9 -5
  11. package/dist/devices/OpalIceMaker/Managers/OpalProgressSvcManager.js.map +1 -1
  12. package/dist/devices/advantium.d.ts +10 -0
  13. package/dist/devices/advantium.d.ts.map +1 -0
  14. package/dist/devices/advantium.js +75 -0
  15. package/dist/devices/advantium.js.map +1 -0
  16. package/dist/devices/airConditioner.d.ts +1 -0
  17. package/dist/devices/airConditioner.d.ts.map +1 -1
  18. package/dist/devices/airConditioner.js +38 -7
  19. package/dist/devices/airConditioner.js.map +1 -1
  20. package/dist/devices/beverageCenter.d.ts +10 -0
  21. package/dist/devices/beverageCenter.d.ts.map +1 -0
  22. package/dist/devices/beverageCenter.js +125 -0
  23. package/dist/devices/beverageCenter.js.map +1 -0
  24. package/dist/devices/clothesDryer.d.ts +10 -0
  25. package/dist/devices/clothesDryer.d.ts.map +1 -0
  26. package/dist/devices/clothesDryer.js +84 -0
  27. package/dist/devices/clothesDryer.js.map +1 -0
  28. package/dist/devices/clothesWasher.d.ts +10 -0
  29. package/dist/devices/clothesWasher.d.ts.map +1 -0
  30. package/dist/devices/clothesWasher.js +84 -0
  31. package/dist/devices/clothesWasher.js.map +1 -0
  32. package/dist/devices/coffeeMaker.d.ts +10 -0
  33. package/dist/devices/coffeeMaker.d.ts.map +1 -0
  34. package/dist/devices/coffeeMaker.js +79 -0
  35. package/dist/devices/coffeeMaker.js.map +1 -0
  36. package/dist/devices/device.d.ts +12 -0
  37. package/dist/devices/device.d.ts.map +1 -1
  38. package/dist/devices/device.js +61 -1
  39. package/dist/devices/device.js.map +1 -1
  40. package/dist/devices/dishwasher.d.ts +0 -3
  41. package/dist/devices/dishwasher.d.ts.map +1 -1
  42. package/dist/devices/dishwasher.js +49 -29
  43. package/dist/devices/dishwasher.js.map +1 -1
  44. package/dist/devices/hood.d.ts +34 -0
  45. package/dist/devices/hood.d.ts.map +1 -0
  46. package/dist/devices/hood.js +306 -0
  47. package/dist/devices/hood.js.map +1 -0
  48. package/dist/devices/microwave.d.ts +10 -0
  49. package/dist/devices/microwave.d.ts.map +1 -0
  50. package/dist/devices/microwave.js +84 -0
  51. package/dist/devices/microwave.js.map +1 -0
  52. package/dist/devices/oven.d.ts +0 -2
  53. package/dist/devices/oven.d.ts.map +1 -1
  54. package/dist/devices/oven.js +78 -43
  55. package/dist/devices/oven.js.map +1 -1
  56. package/dist/devices/refrigerator.d.ts +0 -2
  57. package/dist/devices/refrigerator.d.ts.map +1 -1
  58. package/dist/devices/refrigerator.js +112 -29
  59. package/dist/devices/refrigerator.js.map +1 -1
  60. package/dist/devices/waterFilter.d.ts +10 -0
  61. package/dist/devices/waterFilter.d.ts.map +1 -0
  62. package/dist/devices/waterFilter.js +67 -0
  63. package/dist/devices/waterFilter.js.map +1 -0
  64. package/dist/devices/waterHeater.d.ts +10 -0
  65. package/dist/devices/waterHeater.d.ts.map +1 -0
  66. package/dist/devices/waterHeater.js +95 -0
  67. package/dist/devices/waterHeater.js.map +1 -0
  68. package/dist/devices/waterSoftener.d.ts +10 -0
  69. package/dist/devices/waterSoftener.d.ts.map +1 -0
  70. package/dist/devices/waterSoftener.js +67 -0
  71. package/dist/devices/waterSoftener.js.map +1 -0
  72. package/dist/getAccessToken.d.ts.map +1 -1
  73. package/dist/getAccessToken.js +6 -0
  74. package/dist/getAccessToken.js.map +1 -1
  75. package/dist/platform.d.ts +10 -0
  76. package/dist/platform.d.ts.map +1 -1
  77. package/dist/platform.js +393 -0
  78. package/dist/platform.js.map +1 -1
  79. package/dist/platform.test.d.ts +2 -0
  80. package/dist/platform.test.d.ts.map +1 -0
  81. package/dist/platform.test.js +80 -0
  82. package/dist/platform.test.js.map +1 -0
  83. package/dist/settings.d.ts +13 -0
  84. package/dist/settings.d.ts.map +1 -1
  85. package/dist/settings.js +3 -0
  86. package/dist/settings.js.map +1 -1
  87. package/docs/assets/highlight.css +7 -0
  88. package/docs/assets/main.js +5 -5
  89. package/docs/assets/navigation.js +1 -0
  90. package/docs/assets/search.js +1 -0
  91. package/docs/assets/style.css +248 -226
  92. package/docs/classes/SmartHQPlatform.html +45 -56
  93. package/docs/hierarchy.html +1 -0
  94. package/docs/index.html +22 -12
  95. package/docs/interfaces/DeviceOptions.html +2 -3
  96. package/docs/interfaces/SmartHQPlatformConfig.html +6 -17
  97. package/docs/interfaces/SmartHqContext.html +6 -4
  98. package/docs/interfaces/SmartHqERDResponse.html +7 -8
  99. package/docs/interfaces/credentials.html +3 -4
  100. package/docs/interfaces/devicesConfig.html +7 -8
  101. package/docs/interfaces/options.html +7 -8
  102. package/docs/media/copilot-instructions.md +90 -0
  103. package/docs/modules.html +1 -2
  104. package/docs/variables/API_URL.html +1 -2
  105. package/docs/variables/ERD_CODES.html +1 -2
  106. package/docs/variables/ERD_TYPES.html +1 -2
  107. package/docs/variables/KEEPALIVE_TIMEOUT.html +1 -2
  108. package/docs/variables/LOGIN_URL.html +2 -3
  109. package/docs/variables/OAUTH2_CLIENT_ID.html +1 -2
  110. package/docs/variables/OAUTH2_CLIENT_SECRET.html +1 -2
  111. package/docs/variables/OAUTH2_REDIRECT_URI.html +1 -2
  112. package/docs/variables/PLATFORM_NAME.html +2 -3
  113. package/docs/variables/PLUGIN_NAME.html +2 -3
  114. package/docs/variables/SECURE_URL.html +2 -3
  115. package/docs/variables/default.html +1 -0
  116. package/package.json +21 -28
  117. package/typedoc.json +0 -4
  118. package/vitest.config.ts +6 -5
  119. package/.github/workflows/build.yml +0 -18
  120. package/.github/workflows/changerelease.yml +0 -11
  121. package/.github/workflows/labeler.yml +0 -9
  122. package/.github/workflows/release-drafter.yml +0 -14
  123. package/docs/assets/dmt/dmt-component-data.js +0 -1
  124. package/docs/assets/dmt/dmt-components.css +0 -20
  125. package/docs/assets/dmt/dmt-components.js +0 -67
  126. package/docs/assets/dmt/dmt-search.cmp +0 -0
  127. package/docs/assets/dmt/dmt-theme.css +0 -1
  128. package/docs/functions/default.html +0 -2
@@ -0,0 +1,34 @@
1
+ import type { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
+ import type { SmartHQPlatform } from '../platform.js';
3
+ import type { devicesConfig, SmartHqContext } from '../settings.js';
4
+ import { deviceBase } from './device.js';
5
+ export declare class SmartHQHood extends deviceBase {
6
+ protected readonly platform: SmartHQPlatform;
7
+ protected readonly accessory: PlatformAccessory<SmartHqContext>;
8
+ protected readonly device: SmartHqContext['device'] & devicesConfig;
9
+ private readonly FAN_SVC_NAME;
10
+ private readonly LIGHT_SVC_NAME;
11
+ private readonly fanSvc;
12
+ private readonly lightSvc;
13
+ constructor(platform: SmartHQPlatform, accessory: PlatformAccessory<SmartHqContext>, device: SmartHqContext['device'] & devicesConfig);
14
+ private getErdValue;
15
+ private setErdValue;
16
+ private getFanSpeed;
17
+ private setFanSpeed;
18
+ private getLightLevel;
19
+ private setLightLevel;
20
+ private fanSpeedToRotationSpeed;
21
+ private rotationSpeedToFanSpeed;
22
+ private lightLevelToBrightness;
23
+ private brightnessToLightLevel;
24
+ handleGetFanActive(): Promise<CharacteristicValue>;
25
+ handleSetFanActive(value: CharacteristicValue): Promise<void>;
26
+ handleGetFanRotationSpeed(): Promise<CharacteristicValue>;
27
+ handleSetFanRotationSpeed(value: CharacteristicValue): Promise<void>;
28
+ handleGetLightOn(): Promise<CharacteristicValue>;
29
+ handleSetLightOn(value: CharacteristicValue): Promise<void>;
30
+ handleGetLightBrightness(): Promise<CharacteristicValue>;
31
+ handleSetLightBrightness(value: CharacteristicValue): Promise<void>;
32
+ refreshState(): Promise<void>;
33
+ }
34
+ //# sourceMappingURL=hood.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hood.d.ts","sourceRoot":"","sources":["../../src/devices/hood.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,MAAM,YAAY,CAAA;AAEjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAsB,MAAM,gBAAgB,CAAA;AAMvF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAgBxC,qBAAa,WAAY,SAAQ,UAAU;IAOvC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,eAAe;IAC5C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC,cAAc,CAAC;IAC/D,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,aAAa;IARrE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;gBAGd,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,iBAAiB,CAAC,cAAc,CAAC,EAC5C,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,aAAa;IA+DrE,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,uBAAuB;IAgB/B,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,sBAAsB;IAU9B,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAclD,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB7D,yBAAyB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAazD,yBAAyB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBpE,gBAAgB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAahD,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB3D,wBAAwB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAaxD,wBAAwB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBnE,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CA0B9B"}
@@ -0,0 +1,306 @@
1
+ import axios from 'axios';
2
+ import { interval, startWith } from 'rxjs';
3
+ import { ERD_TYPES } from '../settings.js';
4
+ import { deviceBase } from './device.js';
5
+ var FanSpeed;
6
+ (function (FanSpeed) {
7
+ FanSpeed["OFF"] = "00";
8
+ FanSpeed["LOW"] = "01";
9
+ FanSpeed["MEDIUM"] = "02";
10
+ FanSpeed["HIGH"] = "03";
11
+ FanSpeed["BOOST"] = "04";
12
+ })(FanSpeed || (FanSpeed = {}));
13
+ var LightLevel;
14
+ (function (LightLevel) {
15
+ LightLevel["OFF"] = "00";
16
+ LightLevel["DIM"] = "01";
17
+ LightLevel["HIGH"] = "02";
18
+ })(LightLevel || (LightLevel = {}));
19
+ export class SmartHQHood extends deviceBase {
20
+ platform;
21
+ accessory;
22
+ device;
23
+ FAN_SVC_NAME = 'HOOD_FAN';
24
+ LIGHT_SVC_NAME = 'HOOD_LIGHT';
25
+ fanSvc;
26
+ lightSvc;
27
+ constructor(platform, accessory, device) {
28
+ super(platform, accessory, device);
29
+ this.platform = platform;
30
+ this.accessory = accessory;
31
+ this.device = device;
32
+ this.fanSvc = this.accessory.getService(this.FAN_SVC_NAME)
33
+ ?? this.accessory.addService(this.platform.Service.Fanv2, `${accessory.displayName} Fan`, this.FAN_SVC_NAME);
34
+ this.lightSvc = this.accessory.getService(this.LIGHT_SVC_NAME)
35
+ ?? this.accessory.addService(this.platform.Service.Lightbulb, `${accessory.displayName} Light`, this.LIGHT_SVC_NAME);
36
+ const fanSwitchSvc = this.accessory.getService('HOOD_FAN_SWITCH');
37
+ if (fanSwitchSvc) {
38
+ this.accessory.removeService(fanSwitchSvc);
39
+ }
40
+ const lightSwitchSvc = this.accessory.getService('HOOD_LIGHT_SWITCH');
41
+ if (lightSwitchSvc) {
42
+ this.accessory.removeService(lightSwitchSvc);
43
+ }
44
+ this.fanSvc
45
+ .getCharacteristic(this.platform.Characteristic.Active)
46
+ .onGet(this.handleGetFanActive.bind(this))
47
+ .onSet(this.handleSetFanActive.bind(this));
48
+ this.fanSvc
49
+ .getCharacteristic(this.platform.Characteristic.RotationSpeed)
50
+ .setProps({
51
+ minValue: 0,
52
+ maxValue: 100,
53
+ minStep: 25,
54
+ })
55
+ .onGet(this.handleGetFanRotationSpeed.bind(this))
56
+ .onSet(this.handleSetFanRotationSpeed.bind(this));
57
+ this.lightSvc
58
+ .getCharacteristic(this.platform.Characteristic.On)
59
+ .onGet(this.handleGetLightOn.bind(this))
60
+ .onSet(this.handleSetLightOn.bind(this));
61
+ this.lightSvc
62
+ .getCharacteristic(this.platform.Characteristic.Brightness)
63
+ .setProps({
64
+ minValue: 0,
65
+ maxValue: 100,
66
+ minStep: 50,
67
+ })
68
+ .onGet(this.handleGetLightBrightness.bind(this))
69
+ .onSet(this.handleSetLightBrightness.bind(this));
70
+ interval(this.deviceRefreshRate * 1000)
71
+ .pipe(startWith(0))
72
+ .subscribe(this.refreshState.bind(this));
73
+ }
74
+ getErdValue(erd) {
75
+ return axios
76
+ .get(`/appliance/${this.accessory.context.device.applianceId}/erd/${erd}`)
77
+ .then(response => response.data.value)
78
+ .catch((err) => {
79
+ const message = axios.isAxiosError(err) && err.response
80
+ ? `Failed to fetch ERD: ${err.response.data.message}`
81
+ : `Failed to fetch ERD: ${err instanceof Error ? err.message : 'An unknown error occurred'}`;
82
+ throw new Error(message, { cause: err });
83
+ });
84
+ }
85
+ setErdValue(erd, value) {
86
+ return axios
87
+ .post(`/appliance/${this.accessory.context.device.applianceId}/erd/${erd}`, {
88
+ kind: 'appliance#erdListEntry',
89
+ userId: this.accessory.context.userId,
90
+ applianceId: this.accessory.context.device.applianceId,
91
+ erd,
92
+ value,
93
+ })
94
+ .then(() => {
95
+ this.platform.log.debug(`[${this.accessory.displayName}] Set ERD ${erd}=${value}`);
96
+ })
97
+ .catch((err) => {
98
+ const message = axios.isAxiosError(err) && err.response
99
+ ? `Failed to set ERD ${erd}=${value}: ${err.response.data.message}`
100
+ : `Failed to set ERD ${erd}=${value}: ${err instanceof Error ? err.message : 'An unknown error occurred'}`;
101
+ throw new Error(message, { cause: err });
102
+ });
103
+ }
104
+ getFanSpeed() {
105
+ return this.getErdValue(ERD_TYPES.HOOD_FAN_SPEED)
106
+ .then(value => value)
107
+ .catch((err) => {
108
+ throw new Error(`Failed to get fan speed: ${err instanceof Error ? err.message : 'An unknown error occurred'}`, { cause: err });
109
+ });
110
+ }
111
+ setFanSpeed(value) {
112
+ return this.setErdValue(ERD_TYPES.HOOD_FAN_SPEED, value)
113
+ .catch((err) => {
114
+ throw new Error(`Failed to set fan speed: ${err instanceof Error ? err.message : 'An unknown error occurred'}`, { cause: err });
115
+ });
116
+ }
117
+ getLightLevel() {
118
+ return this.getErdValue(ERD_TYPES.HOOD_LIGHT_LEVEL)
119
+ .then(value => value)
120
+ .catch((err) => {
121
+ throw new Error(`Failed to get light level: ${err instanceof Error ? err.message : 'An unknown error occurred'}`, { cause: err });
122
+ });
123
+ }
124
+ setLightLevel(value) {
125
+ return this.setErdValue(ERD_TYPES.HOOD_LIGHT_LEVEL, value)
126
+ .catch((err) => {
127
+ throw new Error(`Failed to set light level: ${err instanceof Error ? err.message : 'An unknown error occurred'}`, { cause: err });
128
+ });
129
+ }
130
+ fanSpeedToRotationSpeed(fanSpeed) {
131
+ switch (fanSpeed) {
132
+ case FanSpeed.OFF:
133
+ return 0;
134
+ case FanSpeed.LOW:
135
+ return 25;
136
+ case FanSpeed.MEDIUM:
137
+ return 50;
138
+ case FanSpeed.HIGH:
139
+ return 75;
140
+ case FanSpeed.BOOST:
141
+ return 100;
142
+ default:
143
+ return 0;
144
+ }
145
+ }
146
+ rotationSpeedToFanSpeed(rotationSpeed) {
147
+ if (rotationSpeed === 0) {
148
+ return FanSpeed.OFF;
149
+ }
150
+ if (rotationSpeed <= 25) {
151
+ return FanSpeed.LOW;
152
+ }
153
+ if (rotationSpeed <= 50) {
154
+ return FanSpeed.MEDIUM;
155
+ }
156
+ if (rotationSpeed <= 75) {
157
+ return FanSpeed.HIGH;
158
+ }
159
+ return FanSpeed.BOOST;
160
+ }
161
+ lightLevelToBrightness(lightLevel) {
162
+ switch (lightLevel) {
163
+ case LightLevel.OFF:
164
+ return 0;
165
+ case LightLevel.DIM:
166
+ return 50;
167
+ case LightLevel.HIGH:
168
+ return 100;
169
+ default:
170
+ return 0;
171
+ }
172
+ }
173
+ brightnessToLightLevel(brightness) {
174
+ if (brightness === 0) {
175
+ return LightLevel.OFF;
176
+ }
177
+ if (brightness <= 50) {
178
+ return LightLevel.DIM;
179
+ }
180
+ return LightLevel.HIGH;
181
+ }
182
+ handleGetFanActive() {
183
+ return this.getFanSpeed()
184
+ .then((fanSpeed) => {
185
+ const isActive = fanSpeed !== FanSpeed.OFF;
186
+ const value = isActive ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
187
+ this.debugLog(`Get fan active: ${isActive}`);
188
+ return value;
189
+ })
190
+ .catch((err) => {
191
+ this.errorLog(`handleGetFanActive failed: ${err.message}`);
192
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
193
+ });
194
+ }
195
+ handleSetFanActive(value) {
196
+ const isActive = value === this.platform.Characteristic.Active.ACTIVE;
197
+ const fanSpeed = isActive ? FanSpeed.LOW : FanSpeed.OFF;
198
+ this.debugLog(`Set fan active: ${isActive}`);
199
+ return this.setFanSpeed(fanSpeed)
200
+ .then(() => {
201
+ const rotationSpeed = isActive ? 25 : 0;
202
+ this.fanSvc.updateCharacteristic(this.platform.Characteristic.RotationSpeed, rotationSpeed);
203
+ })
204
+ .catch((err) => {
205
+ this.errorLog(`handleSetFanActive failed: ${err.message}`);
206
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
207
+ });
208
+ }
209
+ handleGetFanRotationSpeed() {
210
+ return this.getFanSpeed()
211
+ .then((fanSpeed) => {
212
+ const rotationSpeed = this.fanSpeedToRotationSpeed(fanSpeed);
213
+ this.debugLog(`Get fan rotation speed: ${rotationSpeed}% (${fanSpeed})`);
214
+ return rotationSpeed;
215
+ })
216
+ .catch((err) => {
217
+ this.errorLog(`handleGetFanRotationSpeed failed: ${err.message}`);
218
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
219
+ });
220
+ }
221
+ handleSetFanRotationSpeed(value) {
222
+ const rotationSpeed = value;
223
+ const fanSpeed = this.rotationSpeedToFanSpeed(rotationSpeed);
224
+ this.debugLog(`Set fan rotation speed: ${rotationSpeed}% -> ${fanSpeed}`);
225
+ return this.setFanSpeed(fanSpeed)
226
+ .then(() => {
227
+ this.fanSvc.updateCharacteristic(this.platform.Characteristic.RotationSpeed, rotationSpeed);
228
+ })
229
+ .catch((err) => {
230
+ this.errorLog(`handleSetFanRotationSpeed failed: ${err.message}`);
231
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
232
+ });
233
+ }
234
+ handleGetLightOn() {
235
+ return this.getLightLevel()
236
+ .then((lightLevel) => {
237
+ const isOn = lightLevel !== LightLevel.OFF;
238
+ this.debugLog(`Get light on: ${isOn}`);
239
+ return isOn;
240
+ })
241
+ .catch((err) => {
242
+ this.errorLog(`handleGetLightOn failed: ${err.message}`);
243
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
244
+ });
245
+ }
246
+ handleSetLightOn(value) {
247
+ const isOn = value;
248
+ const lightLevel = isOn ? LightLevel.DIM : LightLevel.OFF;
249
+ this.debugLog(`Set light on: ${isOn}`);
250
+ return this.setLightLevel(lightLevel)
251
+ .then(() => {
252
+ const brightness = isOn ? 50 : 0;
253
+ this.lightSvc.updateCharacteristic(this.platform.Characteristic.Brightness, brightness);
254
+ })
255
+ .catch((err) => {
256
+ this.errorLog(`handleSetLightOn failed: ${err.message}`);
257
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
258
+ });
259
+ }
260
+ handleGetLightBrightness() {
261
+ return this.getLightLevel()
262
+ .then((lightLevel) => {
263
+ const brightness = this.lightLevelToBrightness(lightLevel);
264
+ this.debugLog(`Get light brightness: ${brightness}% (${lightLevel})`);
265
+ return brightness;
266
+ })
267
+ .catch((err) => {
268
+ this.errorLog(`handleGetLightBrightness failed: ${err.message}`);
269
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
270
+ });
271
+ }
272
+ handleSetLightBrightness(value) {
273
+ const brightness = value;
274
+ const lightLevel = this.brightnessToLightLevel(brightness);
275
+ this.debugLog(`Set light brightness: ${brightness}% -> ${lightLevel}`);
276
+ return this.setLightLevel(lightLevel)
277
+ .then(() => {
278
+ this.lightSvc.updateCharacteristic(this.platform.Characteristic.Brightness, brightness);
279
+ })
280
+ .catch((err) => {
281
+ this.errorLog(`handleSetLightBrightness failed: ${err.message}`);
282
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
283
+ });
284
+ }
285
+ refreshState() {
286
+ return Promise.all([
287
+ this.getFanSpeed(),
288
+ this.getLightLevel(),
289
+ ])
290
+ .then(([fanSpeed, lightLevel]) => {
291
+ const isActive = fanSpeed !== FanSpeed.OFF;
292
+ const rotationSpeed = this.fanSpeedToRotationSpeed(fanSpeed);
293
+ const isOn = lightLevel !== LightLevel.OFF;
294
+ const brightness = this.lightLevelToBrightness(lightLevel);
295
+ this.fanSvc.updateCharacteristic(this.platform.Characteristic.Active, isActive ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
296
+ this.fanSvc.updateCharacteristic(this.platform.Characteristic.RotationSpeed, rotationSpeed);
297
+ this.lightSvc.updateCharacteristic(this.platform.Characteristic.On, isOn);
298
+ this.lightSvc.updateCharacteristic(this.platform.Characteristic.Brightness, brightness);
299
+ this.debugLog(`State refreshed - Fan: ${fanSpeed} (${rotationSpeed}%), Light: ${lightLevel} (${brightness}%)`);
300
+ })
301
+ .catch((err) => {
302
+ this.errorLog(`Failed to refresh state: ${err.message}`);
303
+ });
304
+ }
305
+ }
306
+ //# sourceMappingURL=hood.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hood.js","sourceRoot":"","sources":["../../src/devices/hood.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,IAAK,QAMJ;AAND,WAAK,QAAQ;IACX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AC,QAAQ,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;YAEvF,IAAI,CAAC,QAAQ,CAAC,0BAA0B,QAAQ,KAAK,aAAa,cAAc,UAAU,KAAK,UAAU,IAAI,CAAC,CAAA;QAChH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,IAAI,CAAC,QAAQ,CAAC,4BAA4B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;QAC1D,CAAC,CAAC,CAAA;IACN,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import type { PlatformAccessory } from 'homebridge';
2
+ import type { SmartHQPlatform } from '../platform.js';
3
+ import type { devicesConfig, SmartHqContext } from '../settings.js';
4
+ import { deviceBase } from './device.js';
5
+ export declare class SmartHQMicrowave extends deviceBase {
6
+ readonly platform: SmartHQPlatform;
7
+ readonly device: SmartHqContext['device'] & devicesConfig;
8
+ constructor(platform: SmartHQPlatform, accessory: PlatformAccessory<SmartHqContext>, device: SmartHqContext['device'] & devicesConfig);
9
+ }
10
+ //# sourceMappingURL=microwave.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microwave.d.ts","sourceRoot":"","sources":["../../src/devices/microwave.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,qBAAa,gBAAiB,SAAQ,UAAU;IAE5C,QAAQ,CAAC,QAAQ,EAAE,eAAe;IAElC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,aAAa;gBAFhD,QAAQ,EAAE,eAAe,EAClC,SAAS,EAAE,iBAAiB,CAAC,cAAc,CAAC,EACnC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,aAAa;CA0E5D"}
@@ -0,0 +1,84 @@
1
+ import { deviceBase } from './device.js';
2
+ export class SmartHQMicrowave extends deviceBase {
3
+ platform;
4
+ device;
5
+ constructor(platform, accessory, device) {
6
+ super(platform, accessory, device);
7
+ this.platform = platform;
8
+ this.device = device;
9
+ this.debugLog(`Microwave Features: ${JSON.stringify(accessory.context.device.features)}`);
10
+ // Microwave Light
11
+ const light = this.accessory.getService('Microwave Light') ?? this.accessory.addService(this.platform.Service.Lightbulb, 'Microwave Light', 'MicrowaveLight');
12
+ light.setCharacteristic(this.platform.Characteristic.Name, 'Microwave Light');
13
+ light
14
+ .getCharacteristic(this.platform.Characteristic.On)
15
+ .onGet(async () => {
16
+ try {
17
+ // TODO: Implement light state ERD
18
+ return false;
19
+ }
20
+ catch (error) {
21
+ this.warnLog?.(`Microwave Light error: ${error?.message ?? error}`);
22
+ return false;
23
+ }
24
+ })
25
+ .onSet(async (value) => {
26
+ try {
27
+ // TODO: Implement light control ERD
28
+ this.debugLog(`Microwave Light set to: ${value}`);
29
+ }
30
+ catch (error) {
31
+ this.warnLog?.(`Microwave Light set error: ${error?.message ?? error}`);
32
+ }
33
+ });
34
+ // Microwave Running State (Switch)
35
+ const runningSwitch = this.accessory.getService('Microwave') ?? this.accessory.addService(this.platform.Service.Switch, 'Microwave', 'Microwave');
36
+ runningSwitch.setCharacteristic(this.platform.Characteristic.Name, 'Microwave');
37
+ runningSwitch
38
+ .getCharacteristic(this.platform.Characteristic.On)
39
+ .onGet(async () => {
40
+ try {
41
+ // TODO: Implement running state ERD
42
+ return false;
43
+ }
44
+ catch (error) {
45
+ this.warnLog?.(`Microwave Running error: ${error?.message ?? error}`);
46
+ return false;
47
+ }
48
+ })
49
+ .onSet(async (value) => {
50
+ try {
51
+ // TODO: Implement running control ERD
52
+ this.debugLog(`Microwave Running set to: ${value}`);
53
+ }
54
+ catch (error) {
55
+ this.warnLog?.(`Microwave Running set error: ${error?.message ?? error}`);
56
+ }
57
+ });
58
+ // Ventilation Fan (if applicable)
59
+ const fan = this.accessory.getService('Microwave Fan') ?? this.accessory.addService(this.platform.Service.Fanv2, 'Microwave Fan', 'MicrowaveFan');
60
+ fan.setCharacteristic(this.platform.Characteristic.Name, 'Microwave Fan');
61
+ fan
62
+ .getCharacteristic(this.platform.Characteristic.Active)
63
+ .onGet(async () => {
64
+ try {
65
+ // TODO: Implement fan state ERD
66
+ return this.platform.Characteristic.Active.INACTIVE;
67
+ }
68
+ catch (error) {
69
+ this.warnLog?.(`Microwave Fan error: ${error?.message ?? error}`);
70
+ return this.platform.Characteristic.Active.INACTIVE;
71
+ }
72
+ })
73
+ .onSet(async (value) => {
74
+ try {
75
+ // TODO: Implement fan control ERD
76
+ this.debugLog(`Microwave Fan set to: ${value}`);
77
+ }
78
+ catch (error) {
79
+ this.warnLog?.(`Microwave Fan set error: ${error?.message ?? error}`);
80
+ }
81
+ });
82
+ }
83
+ }
84
+ //# sourceMappingURL=microwave.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microwave.js","sourceRoot":"","sources":["../../src/devices/microwave.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IAEnC;IAEA;IAHX,YACW,QAAyB,EAClC,SAA4C,EACnC,MAAgD;QAEzD,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;QAJzB,aAAQ,GAAR,QAAQ,CAAiB;QAEzB,WAAM,GAAN,MAAM,CAA0C;QAGzD,IAAI,CAAC,QAAQ,CAAC,uBAAuB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAEzF,kBAAkB;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,IA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AC;gBACpB,IAAI,CAAC,OAAO,EAAE,CAAC,wBAAwB,KAAK,EAAE,OAAO,IAAI,KAAK,EAAE,CAAC,CAAA;gBACjE,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAA;YACrD,CAAC;QACH,CAAC,CAAC;aACD,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YACrB,IAAI,CAAC;gBACH,kCAAkC;gBAClC,IAAI,CAAC,QAAQ,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAA;YACjD,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,OAAO,EAAE,CAAC,4BAA4B,KAAK,EAAE,OAAO,IAAI,KAAK,EAAE,CAAC,CAAA;YACvE,CAAC;QACH,CAAC,CAAC,CAAA;IACN,CAAC;CACF"}
@@ -6,7 +6,5 @@ export declare class SmartHQOven extends deviceBase {
6
6
  readonly platform: SmartHQPlatform;
7
7
  readonly device: SmartHqContext['device'] & devicesConfig;
8
8
  constructor(platform: SmartHQPlatform, accessory: PlatformAccessory<SmartHqContext>, device: SmartHqContext['device'] & devicesConfig);
9
- readErd(erd: string): Promise<string>;
10
- writeErd(erd: string, value: string | boolean): Promise<undefined>;
11
9
  }
12
10
  //# sourceMappingURL=oven.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oven.d.ts","sourceRoot":"","sources":["../../src/devices/oven.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAOnE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,qBAAa,WAAY,SAAQ,UAAU;IAEvC,QAAQ,CAAC,QAAQ,EAAE,eAAe;IAElC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,aAAa;gBAFhD,QAAQ,EAAE,eAAe,EAClC,SAAS,EAAE,iBAAiB,CAAC,cAAc,CAAC,EACnC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,aAAa;IAuCrD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMrC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;CAWpD"}
1
+ {"version":3,"file":"oven.d.ts","sourceRoot":"","sources":["../../src/devices/oven.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAKnE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,qBAAa,WAAY,SAAQ,UAAU;IAEvC,QAAQ,CAAC,QAAQ,EAAE,eAAe;IAElC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,aAAa;gBAFhD,QAAQ,EAAE,eAAe,EAClC,SAAS,EAAE,iBAAiB,CAAC,cAAc,CAAC,EACnC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,aAAa;CAkF5D"}
@@ -1,5 +1,4 @@
1
1
  import { Buffer } from 'node:buffer';
2
- import axios from 'axios';
3
2
  import { ERD_TYPES } from '../settings.js';
4
3
  import { deviceBase } from './device.js';
5
4
  export class SmartHQOven extends deviceBase {
@@ -10,55 +9,91 @@ export class SmartHQOven extends deviceBase {
10
9
  this.platform = platform;
11
10
  this.device = device;
12
11
  this.debugLog(`Oven Features: ${JSON.stringify(accessory.context.device.features)}`);
13
- accessory.context.device.features.forEach((feature) => {
14
- switch (feature) {
15
- case 'COOKING_V1_UPPER_OVEN_FOUNDATION': {
16
- const ovenLight = this.accessory.getService(accessory.displayName) ?? this.accessory.addService(this.platform.Service.Lightbulb, accessory.displayName, 'Oven');
17
- ovenLight
18
- .getCharacteristic(this.platform.Characteristic.On)
19
- .onGet(() => this.readErd(ERD_TYPES.UPPER_OVEN_LIGHT).then(r => Number.parseInt(r) !== 0))
20
- .onSet(value => this.writeErd(ERD_TYPES.UPPER_OVEN_LIGHT, value));
21
- break;
22
- }
23
- case 'COOKING_V1_EXTENDED_COOKTOP_FOUNDATION': {
24
- this.accessory.getService(accessory.displayName) ?? this.accessory.addService(this.platform.Service.StatefulProgrammableSwitch, accessory.displayName, 'Oven')
25
- .getCharacteristic(this.platform.Characteristic.TargetTemperature)
26
- .onGet(async () => {
27
- const erdVal = await this.readErd(ERD_TYPES.UPPER_OVEN_COOK_MODE);
28
- const b = Buffer.from(erdVal, 'hex');
29
- return fToC(b.readUint16BE(1));
30
- })
31
- .onSet(async (value) => {
32
- const fTarget = cToF(value);
33
- const erdVal = await this.readErd(ERD_TYPES.UPPER_OVEN_COOK_MODE);
34
- const b = Buffer.from(erdVal, 'hex');
35
- b.writeUint16BE(fTarget, 1);
36
- return this.writeErd(ERD_TYPES.UPPER_OVEN_COOK_MODE, b.toString('hex'));
37
- });
12
+ // Oven Light
13
+ const ovenLight = this.accessory.getService('Oven Light') ?? this.accessory.addService(this.platform.Service.Lightbulb, 'Oven Light', 'OvenLight');
14
+ ovenLight.setCharacteristic(this.platform.Characteristic.Name, 'Oven Light');
15
+ ovenLight
16
+ .getCharacteristic(this.platform.Characteristic.On)
17
+ .onGet(async () => {
18
+ try {
19
+ const r = await this.readErd(ERD_TYPES.UPPER_OVEN_LIGHT);
20
+ return r ? Number.parseInt(r) !== 0 : false;
21
+ }
22
+ catch (error) {
23
+ this.warnLog?.(`Oven Light handleGetOn error: ${error?.message ?? error}`);
24
+ return false;
25
+ }
26
+ })
27
+ .onSet(async (value) => {
28
+ try {
29
+ await this.writeErd(ERD_TYPES.UPPER_OVEN_LIGHT, value);
30
+ }
31
+ catch (error) {
32
+ this.warnLog?.(`Oven Light handleSetOn error: ${error?.message ?? error}`);
33
+ }
34
+ });
35
+ // Oven Current Temperature Sensor
36
+ const ovenTempSensor = this.accessory.getService('Oven Temperature') ?? this.accessory.addService(this.platform.Service.TemperatureSensor, 'Oven Temperature', 'OvenTemp');
37
+ ovenTempSensor.setCharacteristic(this.platform.Characteristic.Name, 'Oven Temperature');
38
+ ovenTempSensor
39
+ .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
40
+ .onGet(async () => {
41
+ try {
42
+ const erdVal = await this.readErd(ERD_TYPES.UPPER_OVEN_COOK_MODE);
43
+ if (!erdVal) {
44
+ return 0;
38
45
  }
46
+ const b = Buffer.from(erdVal, 'hex');
47
+ return fToC(b.readUint16BE(1));
48
+ }
49
+ catch (error) {
50
+ this.warnLog?.(`Oven Temperature error: ${error?.message ?? error}`);
51
+ return 0;
39
52
  }
40
53
  });
41
- }
42
- async readErd(erd) {
43
- const d = await axios
44
- .get(`/appliance/${this.accessory.context.device.applianceId}/erd/${erd}`);
45
- return String(d.data.value);
46
- }
47
- async writeErd(erd, value) {
48
- await axios
49
- .post(`/appliance/${this.accessory.context.device.applianceId}/erd/${erd}`, {
50
- kind: 'appliance#erdListEntry',
51
- userId: this.accessory.context.userId,
52
- applianceId: this.accessory.context.device.applianceId,
53
- erd,
54
- value: typeof value === 'boolean' ? (value ? '01' : '00') : value,
54
+ // Oven Door Lock (Security System for lock state)
55
+ const ovenDoorLock = this.accessory.getService('Oven Door Lock') ?? this.accessory.addService(this.platform.Service.LockMechanism, 'Oven Door Lock', 'OvenDoorLock');
56
+ ovenDoorLock.setCharacteristic(this.platform.Characteristic.Name, 'Oven Door Lock');
57
+ ovenDoorLock
58
+ .getCharacteristic(this.platform.Characteristic.LockCurrentState)
59
+ .onGet(async () => {
60
+ try {
61
+ // TODO: Use actual ERD for door lock state when available
62
+ return this.platform.Characteristic.LockCurrentState.UNSECURED;
63
+ }
64
+ catch (error) {
65
+ this.warnLog?.(`Oven Door Lock error: ${error?.message ?? error}`);
66
+ return this.platform.Characteristic.LockCurrentState.UNSECURED;
67
+ }
68
+ });
69
+ ovenDoorLock
70
+ .getCharacteristic(this.platform.Characteristic.LockTargetState)
71
+ .onGet(async () => {
72
+ try {
73
+ // TODO: Use actual ERD for door lock state when available
74
+ return this.platform.Characteristic.LockTargetState.UNSECURED;
75
+ }
76
+ catch (error) {
77
+ this.warnLog?.(`Oven Door Lock error: ${error?.message ?? error}`);
78
+ return this.platform.Characteristic.LockTargetState.UNSECURED;
79
+ }
80
+ })
81
+ .onSet(async (value) => {
82
+ try {
83
+ // TODO: Implement door lock control when ERD is available
84
+ this.debugLog(`Oven Door Lock set to: ${value}`);
85
+ }
86
+ catch (error) {
87
+ this.warnLog?.(`Oven Door Lock set error: ${error?.message ?? error}`);
88
+ }
55
89
  });
56
- return undefined;
57
90
  }
58
91
  }
59
- function cToF(celsius) {
60
- return (celsius * 9) / 5 + 32;
92
+ /*
93
+ function cToF(celsius: number) {
94
+ return (celsius * 9) / 5 + 32
61
95
  }
96
+ */
62
97
  function fToC(fahrenheit) {
63
98
  return ((fahrenheit - 32) * 5) / 9;
64
99
  }