homebridge-smarthq-client 1.0.0

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 (84) hide show
  1. package/LICENSE +21 -0
  2. package/Readme.md +138 -0
  3. package/config.schema.json +146 -0
  4. package/dist/index.d.ts +6 -0
  5. package/dist/index.js +9 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/platform.d.ts +40 -0
  8. package/dist/platform.js +243 -0
  9. package/dist/platform.js.map +1 -0
  10. package/dist/refrigerator/controlLock.d.ts +19 -0
  11. package/dist/refrigerator/controlLock.js +85 -0
  12. package/dist/refrigerator/controlLock.js.map +1 -0
  13. package/dist/refrigerator/convertibleDrawer.d.ts +27 -0
  14. package/dist/refrigerator/convertibleDrawer.js +317 -0
  15. package/dist/refrigerator/convertibleDrawer.js.map +1 -0
  16. package/dist/refrigerator/dispenserLight.d.ts +19 -0
  17. package/dist/refrigerator/dispenserLight.js +85 -0
  18. package/dist/refrigerator/dispenserLight.js.map +1 -0
  19. package/dist/refrigerator/energy.d.ts +19 -0
  20. package/dist/refrigerator/energy.js +93 -0
  21. package/dist/refrigerator/energy.js.map +1 -0
  22. package/dist/refrigerator/freezer.d.ts +41 -0
  23. package/dist/refrigerator/freezer.js +188 -0
  24. package/dist/refrigerator/freezer.js.map +1 -0
  25. package/dist/refrigerator/iceMaker.d.ts +19 -0
  26. package/dist/refrigerator/iceMaker.js +81 -0
  27. package/dist/refrigerator/iceMaker.js.map +1 -0
  28. package/dist/refrigerator/interiorLight.d.ts +21 -0
  29. package/dist/refrigerator/interiorLight.js +100 -0
  30. package/dist/refrigerator/interiorLight.js.map +1 -0
  31. package/dist/refrigerator/refrigerator.d.ts +41 -0
  32. package/dist/refrigerator/refrigerator.js +204 -0
  33. package/dist/refrigerator/refrigerator.js.map +1 -0
  34. package/dist/refrigerator/refrigeratorAlerts.d.ts +36 -0
  35. package/dist/refrigerator/refrigeratorAlerts.js +204 -0
  36. package/dist/refrigerator/refrigeratorAlerts.js.map +1 -0
  37. package/dist/refrigerator/sabbathMode.d.ts +20 -0
  38. package/dist/refrigerator/sabbathMode.js +91 -0
  39. package/dist/refrigerator/sabbathMode.js.map +1 -0
  40. package/dist/refrigerator/temperatureUnits.d.ts +21 -0
  41. package/dist/refrigerator/temperatureUnits.js +147 -0
  42. package/dist/refrigerator/temperatureUnits.js.map +1 -0
  43. package/dist/refrigerator/turboCoolMode.d.ts +23 -0
  44. package/dist/refrigerator/turboCoolMode.js +134 -0
  45. package/dist/refrigerator/turboCoolMode.js.map +1 -0
  46. package/dist/refrigerator/waterFilter.d.ts +19 -0
  47. package/dist/refrigerator/waterFilter.js +89 -0
  48. package/dist/refrigerator/waterFilter.js.map +1 -0
  49. package/dist/refrigeratorServices.d.ts +5 -0
  50. package/dist/refrigeratorServices.js +54 -0
  51. package/dist/refrigeratorServices.js.map +1 -0
  52. package/dist/settings.d.ts +12 -0
  53. package/dist/settings.js +13 -0
  54. package/dist/settings.js.map +1 -0
  55. package/dist/smartHqApi.d.ts +29 -0
  56. package/dist/smartHqApi.js +267 -0
  57. package/dist/smartHqApi.js.map +1 -0
  58. package/dist/smarthq-types.d.ts +29 -0
  59. package/dist/smarthq-types.js +2 -0
  60. package/dist/smarthq-types.js.map +1 -0
  61. package/eslint.config.js +12 -0
  62. package/images/homebridge.svg +1 -0
  63. package/package.json +61 -0
  64. package/src/@types/homebridge-lib.d.ts +14 -0
  65. package/src/index.ts +11 -0
  66. package/src/platform.ts +300 -0
  67. package/src/refrigerator/controlLock.ts +103 -0
  68. package/src/refrigerator/convertibleDrawer.ts +381 -0
  69. package/src/refrigerator/dispenserLight.ts +103 -0
  70. package/src/refrigerator/energy.ts +106 -0
  71. package/src/refrigerator/freezer.ts +227 -0
  72. package/src/refrigerator/iceMaker.ts +100 -0
  73. package/src/refrigerator/interiorLight.ts +118 -0
  74. package/src/refrigerator/refrigerator.ts +241 -0
  75. package/src/refrigerator/refrigeratorAlerts.ts +228 -0
  76. package/src/refrigerator/sabbathMode.ts +111 -0
  77. package/src/refrigerator/temperatureUnits.ts +178 -0
  78. package/src/refrigerator/turboCoolMode.ts +164 -0
  79. package/src/refrigerator/waterFilter.ts +107 -0
  80. package/src/refrigeratorServices.ts +60 -0
  81. package/src/settings.ts +14 -0
  82. package/src/smartHqApi.ts +305 -0
  83. package/src/smarthq-types.ts +31 -0
  84. package/tsconfig.json +24 -0
@@ -0,0 +1,85 @@
1
+ import { SmartHqApi } from '../smartHqApi.js';
2
+ /**
3
+ * Platform Accessory
4
+ * An instance of this class is created for each accessory your platform registers
5
+ * Each accessory may expose multiple services of different service types.
6
+ */
7
+ export class ControlLock {
8
+ platform;
9
+ accessory;
10
+ deviceServices;
11
+ deviceId;
12
+ smartHqApi;
13
+ log;
14
+ constructor(platform, accessory, deviceServices, deviceId) {
15
+ this.platform = platform;
16
+ this.accessory = accessory;
17
+ this.deviceServices = deviceServices;
18
+ this.deviceId = deviceId;
19
+ this.platform = platform;
20
+ this.accessory = accessory;
21
+ this.deviceServices = deviceServices;
22
+ this.deviceId = deviceId;
23
+ this.log = platform.log;
24
+ this.smartHqApi = new SmartHqApi(this.platform);
25
+ //=====================================================================================
26
+ // Check to see if the device has any supported Convertible Drawer services
27
+ // If not, then don't add services for device that doesn't support it
28
+ //=====================================================================================
29
+ if (!this.platform.deviceSupportsThisService(this.deviceServices, 'cloud.smarthq.device.appliance', 'cloud.smarthq.service.toggle', 'cloud.smarthq.domain.controls.lock')) {
30
+ this.log.info('No supported Control Lock service found for device: ' + this.accessory.displayName);
31
+ return;
32
+ }
33
+ this.platform.debug('green', 'Adding Controls Lock Switch');
34
+ //=====================================================================================
35
+ // create a Control Lock switch for the Refrigerator
36
+ //=====================================================================================
37
+ const displayName = "Controls Lock";
38
+ const controlsLock = this.accessory.getService(displayName)
39
+ || this.accessory.addService(this.platform.Service.Switch, displayName, 'control-lock-123');
40
+ controlsLock.setCharacteristic(this.platform.Characteristic.Name, displayName);
41
+ controlsLock.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
42
+ controlsLock.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
43
+ controlsLock.getCharacteristic(this.platform.Characteristic.On)
44
+ .onGet(this.getcontrolsLock.bind(this))
45
+ .onSet(this.setcontrolsLock.bind(this));
46
+ }
47
+ //=====================================================================================
48
+ async getcontrolsLock() {
49
+ let isOn = false;
50
+ for (const service of this.deviceServices) {
51
+ if (service.serviceDeviceType === 'cloud.smarthq.device.appliance'
52
+ && service.serviceType === 'cloud.smarthq.service.toggle'
53
+ && service.domainType === 'cloud.smarthq.domain.controls.lock') {
54
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
55
+ if (state?.on == null) {
56
+ this.platform.debug('blue', 'No response from setcontrolsLock command');
57
+ return false;
58
+ }
59
+ isOn = state?.on;
60
+ }
61
+ }
62
+ return isOn;
63
+ }
64
+ //=====================================================================================
65
+ async setcontrolsLock(value) {
66
+ const cmdBody = {
67
+ command: {
68
+ commandType: 'cloud.smarthq.command.toggle.set',
69
+ on: value
70
+ },
71
+ kind: 'service#command',
72
+ deviceId: this.deviceId,
73
+ serviceDeviceType: 'cloud.smarthq.device.appliance',
74
+ serviceType: 'cloud.smarthq.service.toggle',
75
+ domainType: 'cloud.smarthq.domain.controls.lock'
76
+ };
77
+ const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
78
+ if (response == null) {
79
+ this.platform.debug('blue', 'No response from setcontrolsLock command');
80
+ return;
81
+ }
82
+ this.platform.debug('blue', 'setcontrolsLock response: ' + response.outcome);
83
+ }
84
+ }
85
+ //# sourceMappingURL=controlLock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controlLock.js","sourceRoot":"","sources":["../../src/refrigerator/controlLock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAKH;IACA;IACD;IACA;IAPH,UAAU,CAAa;IA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M,OAAO,GAAG;YACd,OAAO,EAAE;gBACP,WAAW,EAAE,kCAAkC;gBAC/C,EAAE,EAAE,KAAK;aACV;YACD,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,iBAAiB,EAAE,gCAAgC;YACnD,WAAW,EAAE,8BAA8B;YAC3C,UAAU,EAAE,oCAAoC;SACjD,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAExE,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,0CAA0C,CAAC,CAAC;YACxE,OAAO;QACT,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,4BAA4B,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/E,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ import { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
+ import { SmartHqPlatform } from '../platform.js';
3
+ import { DevService } from '../smarthq-types.js';
4
+ /**
5
+ * Platform Accessory
6
+ * An instance of this class is created for each accessory your platform registers
7
+ * Each accessory may expose multiple services of different service types.
8
+ */
9
+ export declare class ConvertibleDrawer {
10
+ private readonly platform;
11
+ private readonly accessory;
12
+ readonly deviceServices: DevService[];
13
+ readonly deviceId: string;
14
+ private readonly smartHqApi;
15
+ private convertibleDrawerMode;
16
+ private log;
17
+ constructor(platform: SmartHqPlatform, accessory: PlatformAccessory, deviceServices: DevService[], deviceId: string);
18
+ getDrawerTemperature(): Promise<CharacteristicValue>;
19
+ getConvertibleDrawerSnacks(): Promise<CharacteristicValue>;
20
+ getConvertibleDrawerMeat(): Promise<CharacteristicValue>;
21
+ getConvertibleDrawerBeverages(): Promise<CharacteristicValue>;
22
+ getConvertibleDrawerWine(): Promise<CharacteristicValue>;
23
+ setConvertibleDrawerMeat(value: CharacteristicValue): Promise<void>;
24
+ setConvertibleDrawerBeverages(value: CharacteristicValue): Promise<void>;
25
+ setConvertibleDrawerSnacks(value: CharacteristicValue): Promise<void>;
26
+ setConvertibleDrawerWine(value: CharacteristicValue): Promise<void>;
27
+ }
@@ -0,0 +1,317 @@
1
+ import { SmartHqApi } from '../smartHqApi.js';
2
+ /**
3
+ * Platform Accessory
4
+ * An instance of this class is created for each accessory your platform registers
5
+ * Each accessory may expose multiple services of different service types.
6
+ */
7
+ export class ConvertibleDrawer {
8
+ platform;
9
+ accessory;
10
+ deviceServices;
11
+ deviceId;
12
+ smartHqApi;
13
+ //------------------- Convertible Drawer Temperature Service -----------------------
14
+ convertibleDrawerMode = {
15
+ MEAT: "cloud.smarthq.type.mode.convertibledrawer.mode3",
16
+ BEVERAGES: "cloud.smarthq.type.mode.convertibledrawer.mode4",
17
+ SNACKS: "cloud.smarthq.type.mode.convertibledrawer.mode5",
18
+ WINE: "cloud.smarthq.type.mode.convertibledrawer.mode6",
19
+ };
20
+ log;
21
+ constructor(platform, accessory, deviceServices, deviceId) {
22
+ this.platform = platform;
23
+ this.accessory = accessory;
24
+ this.deviceServices = deviceServices;
25
+ this.deviceId = deviceId;
26
+ this.platform = platform;
27
+ this.accessory = accessory;
28
+ this.deviceServices = deviceServices;
29
+ this.deviceId = deviceId;
30
+ this.log = platform.log;
31
+ this.smartHqApi = new SmartHqApi(this.platform);
32
+ //=====================================================================================
33
+ // Check to see if the device has any supported Convertible Drawer services
34
+ // If not, then don't add services for device that doesn't support it
35
+ //=====================================================================================
36
+ if (!this.platform.deviceSupportsThisService(this.deviceServices, 'cloud.smarthq.device.refrigerator.convertibledrawer', 'cloud.smarthq.service.mode', 'cloud.smarthq.domain.mode.selection')) {
37
+ this.log.info('No supported Convertible Drawer services found for device: ' + this.accessory.displayName);
38
+ return;
39
+ }
40
+ this.platform.debug('green', 'Adding Convertible Drawer Switches');
41
+ // set accessory information
42
+ this.accessory.getService(this.platform.Service.AccessoryInformation)
43
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'GE')
44
+ .setCharacteristic(this.platform.Characteristic.Model, accessory.context.device.model || 'Default-Model')
45
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.context.device.serial || 'Default-Serial');
46
+ //=====================================================================================
47
+ // create some new Switch services for the Refrigerator to be used like radio buttons
48
+ // to set the Convertible Drawer modes (Snacks, Meat, Beverages, Wine)
49
+ //=====================================================================================
50
+ let displayName = "Drawer Meat";
51
+ const convertibleDrawerMeat = this.accessory.getService(displayName)
52
+ || this.accessory.addService(this.platform.Service.Switch, displayName, 'drawer-mode-3');
53
+ convertibleDrawerMeat.setCharacteristic(this.platform.Characteristic.Name, displayName);
54
+ convertibleDrawerMeat.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
55
+ convertibleDrawerMeat.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
56
+ displayName = "Drawer Beverages";
57
+ const convertibleDrawerBeverages = this.accessory.getService(displayName)
58
+ || this.accessory.addService(this.platform.Service.Switch, displayName, 'drawer-mode-4');
59
+ convertibleDrawerBeverages.setCharacteristic(this.platform.Characteristic.Name, displayName);
60
+ convertibleDrawerBeverages.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
61
+ convertibleDrawerBeverages.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
62
+ displayName = "Drawer Snacks";
63
+ const convertibleDrawerSnacks = this.accessory.getService(displayName)
64
+ || this.accessory.addService(this.platform.Service.Switch, displayName, 'drawer-mode-5');
65
+ convertibleDrawerSnacks.setCharacteristic(this.platform.Characteristic.Name, displayName);
66
+ convertibleDrawerSnacks.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
67
+ convertibleDrawerSnacks.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
68
+ displayName = "Drawer Wine";
69
+ const convertibleDrawerWine = this.accessory.getService(displayName)
70
+ || this.accessory.addService(this.platform.Service.Switch, displayName, 'drawer-mode-6');
71
+ convertibleDrawerWine.setCharacteristic(this.platform.Characteristic.Name, displayName);
72
+ convertibleDrawerWine.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
73
+ convertibleDrawerWine.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
74
+ // create handlers for required characteristics
75
+ convertibleDrawerSnacks.getCharacteristic(this.platform.Characteristic.On)
76
+ .onGet(this.getConvertibleDrawerSnacks.bind(this))
77
+ .onSet(this.setConvertibleDrawerSnacks.bind(this));
78
+ convertibleDrawerMeat.getCharacteristic(this.platform.Characteristic.On)
79
+ .onGet(this.getConvertibleDrawerMeat.bind(this))
80
+ .onSet(this.setConvertibleDrawerMeat.bind(this));
81
+ convertibleDrawerBeverages.getCharacteristic(this.platform.Characteristic.On)
82
+ .onGet(this.getConvertibleDrawerBeverages.bind(this))
83
+ .onSet(this.setConvertibleDrawerBeverages.bind(this));
84
+ convertibleDrawerWine.getCharacteristic(this.platform.Characteristic.On)
85
+ .onGet(this.getConvertibleDrawerWine.bind(this))
86
+ .onSet(this.setConvertibleDrawerWine.bind(this));
87
+ // Service for Convertible Drawer Temperature Sensor
88
+ displayName = "Drawer Temp";
89
+ const drawerTemperature = this.accessory.getService(displayName)
90
+ || this.accessory.addService(this.platform.Service.TemperatureSensor, displayName, 'drawer-temp-1');
91
+ drawerTemperature.setCharacteristic(this.platform.Characteristic.Name, displayName);
92
+ drawerTemperature.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
93
+ drawerTemperature.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
94
+ drawerTemperature.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
95
+ .onGet(this.getDrawerTemperature.bind(this));
96
+ }
97
+ //=====================================================================================
98
+ async getDrawerTemperature() {
99
+ let temp = 0;
100
+ let mode = '0';
101
+ // First you need to find which mode is set for the Convertible Drawer
102
+ for (const service of this.deviceServices) {
103
+ if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator.convertibledrawer'
104
+ && service.serviceType === 'cloud.smarthq.service.mode') {
105
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
106
+ if (state == null || !state?.mode) {
107
+ this.platform.debug('blue', 'No mode returned from getDrawerTemperature state');
108
+ break; // an invalid mode value will be used below so no match will be found
109
+ }
110
+ const result = state?.mode.lastIndexOf(".");
111
+ mode = state?.mode.slice(result + 1);
112
+ break;
113
+ }
114
+ }
115
+ // Add the 'mode' to serviceDeviceType to get the correct temperature service
116
+ for (const service of this.deviceServices) {
117
+ if (service.serviceDeviceType === `cloud.smarthq.device.refrigerator.convertibledrawer.${mode}`
118
+ && service.serviceType === 'cloud.smarthq.service.temperature') {
119
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
120
+ if (state == null || !state?.celsiusConverted) {
121
+ this.platform.debug('blue', 'No celsiusConverted returned from getDrawerTemperature state');
122
+ return false;
123
+ }
124
+ temp = state?.celsiusConverted;
125
+ break;
126
+ }
127
+ }
128
+ return temp;
129
+ }
130
+ //=====================================================================================
131
+ async getConvertibleDrawerSnacks() {
132
+ // Find current mode and return true if = mode5 (Snacks)
133
+ const snacks = 'cloud.smarthq.type.mode.convertibledrawer.mode5';
134
+ let isOn = false;
135
+ for (const service of this.deviceServices) {
136
+ if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator.convertibledrawer'
137
+ && service.serviceType === 'cloud.smarthq.service.mode') {
138
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
139
+ if (state == null || !state?.mode) {
140
+ this.platform.debug('blue', 'No mode returned from getConvertibleDrawerSnacks state');
141
+ return false;
142
+ }
143
+ if (state?.mode === snacks) {
144
+ isOn = true;
145
+ }
146
+ break;
147
+ }
148
+ }
149
+ return isOn;
150
+ }
151
+ //=====================================================================================
152
+ async getConvertibleDrawerMeat() {
153
+ const meat = 'cloud.smarthq.type.mode.convertibledrawer.mode3';
154
+ // Find current mode and return true if = mode3 (Meat)
155
+ let isOn = false;
156
+ for (const service of this.deviceServices) {
157
+ if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator.convertibledrawer'
158
+ && service.serviceType === 'cloud.smarthq.service.mode') {
159
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
160
+ if (state == null || !state?.mode) {
161
+ this.platform.debug('blue', 'No mode returned from getConvertibleDrawerMeat state');
162
+ return false;
163
+ }
164
+ if (state?.mode === meat) {
165
+ isOn = true;
166
+ }
167
+ break;
168
+ }
169
+ }
170
+ return isOn;
171
+ }
172
+ //=====================================================================================
173
+ async getConvertibleDrawerBeverages() {
174
+ const beverages = 'cloud.smarthq.type.mode.convertibledrawer.mode4';
175
+ // Find current mode and return true if = mode4 (Beverages)
176
+ let isOn = false;
177
+ for (const service of this.deviceServices) {
178
+ if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator.convertibledrawer'
179
+ && service.serviceType === 'cloud.smarthq.service.mode') {
180
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
181
+ if (state == null || !state?.mode) {
182
+ this.platform.debug('blue', 'No mode returned from getConvertibleDrawerBeverages state');
183
+ return false;
184
+ }
185
+ if (state.mode === beverages) {
186
+ isOn = true;
187
+ }
188
+ break;
189
+ }
190
+ }
191
+ return isOn;
192
+ }
193
+ //=====================================================================================
194
+ async getConvertibleDrawerWine() {
195
+ const wine = 'cloud.smarthq.type.mode.convertibledrawer.mode6';
196
+ // Find current mode and return true if = mode6 (Wine)
197
+ let isOn = false;
198
+ for (const service of this.deviceServices) {
199
+ if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator.convertibledrawer'
200
+ && service.serviceType === 'cloud.smarthq.service.mode') {
201
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
202
+ if (state == null || !state?.mode) {
203
+ this.platform.debug('blue', 'No mode returned from getConvertibleDrawerWine state');
204
+ return false;
205
+ }
206
+ if (state.mode === wine) {
207
+ isOn = true;
208
+ }
209
+ break;
210
+ }
211
+ }
212
+ return isOn;
213
+ }
214
+ //=====================================================================================
215
+ async setConvertibleDrawerMeat(value) {
216
+ this.platform.debug('blue', "Triggered setConvertibleDrawerMeat");
217
+ if (value === true) {
218
+ const cmdBody = {
219
+ command: {
220
+ commandType: 'cloud.smarthq.command.mode.set',
221
+ mode: this.convertibleDrawerMode.MEAT
222
+ },
223
+ kind: 'service#command',
224
+ deviceId: this.deviceId,
225
+ serviceDeviceType: 'cloud.smarthq.device.refrigerator.convertibledrawer',
226
+ serviceType: 'cloud.smarthq.service.mode',
227
+ domainType: 'cloud.smarthq.domain.mode.selection'
228
+ };
229
+ const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
230
+ if (response != null) {
231
+ // Update the switches for Wine, Snacks, Beverages to off
232
+ const switchSnacks = this.accessory.getService("Drawer Snacks");
233
+ switchSnacks?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
234
+ const switchBeverages = this.accessory.getService("Drawer Beverages");
235
+ switchBeverages?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
236
+ const switchWine = this.accessory.getService("Drawer Wine");
237
+ switchWine?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
238
+ }
239
+ }
240
+ }
241
+ //=====================================================================================
242
+ async setConvertibleDrawerBeverages(value) {
243
+ this.platform.debug('blue', "Triggered setConvertibleDrawerBeverages value: " + value);
244
+ const cmdBody = {
245
+ command: {
246
+ commandType: 'cloud.smarthq.command.mode.set',
247
+ mode: this.convertibleDrawerMode.BEVERAGES
248
+ },
249
+ kind: 'service#command',
250
+ deviceId: this.deviceId,
251
+ serviceDeviceType: 'cloud.smarthq.device.refrigerator.convertibledrawer',
252
+ serviceType: 'cloud.smarthq.service.mode',
253
+ domainType: 'cloud.smarthq.domain.mode.selection'
254
+ };
255
+ const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
256
+ if (response != null) {
257
+ // Update the switches for Wine, Snacks, Meat to off
258
+ const switchSnacks = this.accessory.getService("Drawer Snacks");
259
+ switchSnacks?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
260
+ const switchWine = this.accessory.getService("Drawer Wine");
261
+ switchWine?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
262
+ const switchMeat = this.accessory.getService("Drawer Meat");
263
+ switchMeat?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
264
+ }
265
+ }
266
+ //=====================================================================================
267
+ async setConvertibleDrawerSnacks(value) {
268
+ this.platform.debug('blue', "Triggered setConvertibleDrawerSnacks value: " + value);
269
+ const cmdBody = {
270
+ command: {
271
+ commandType: 'cloud.smarthq.command.mode.set',
272
+ mode: this.convertibleDrawerMode.SNACKS
273
+ },
274
+ kind: 'service#command',
275
+ deviceId: this.deviceId,
276
+ serviceDeviceType: 'cloud.smarthq.device.refrigerator.convertibledrawer',
277
+ serviceType: 'cloud.smarthq.service.mode',
278
+ domainType: 'cloud.smarthq.domain.mode.selection'
279
+ };
280
+ const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
281
+ if (response != null) {
282
+ // Update the switches for Wine, Meat, Beverages to off
283
+ const switchMeat = this.accessory.getService("Drawer Meat");
284
+ switchMeat?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
285
+ const switchBeverages = this.accessory.getService("Drawer Beverages");
286
+ switchBeverages?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
287
+ const switchWine = this.accessory.getService("Drawer Wine");
288
+ switchWine?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
289
+ }
290
+ }
291
+ //=====================================================================================
292
+ async setConvertibleDrawerWine(value) {
293
+ this.platform.debug('blue', "Triggered setConvertibleDrawerWine value: " + value);
294
+ const cmdBody = {
295
+ command: {
296
+ commandType: 'cloud.smarthq.command.mode.set',
297
+ mode: this.convertibleDrawerMode.WINE
298
+ },
299
+ kind: 'service#command',
300
+ deviceId: this.deviceId,
301
+ serviceDeviceType: 'cloud.smarthq.device.refrigerator.convertibledrawer',
302
+ serviceType: 'cloud.smarthq.service.mode',
303
+ domainType: 'cloud.smarthq.domain.mode.selection'
304
+ };
305
+ const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
306
+ if (response != null) {
307
+ // Update the switches for Meat, Snacks, Beverages to off
308
+ const switchSnacks = this.accessory.getService("Drawer Snacks");
309
+ switchSnacks?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
310
+ const switchBeverages = this.accessory.getService("Drawer Beverages");
311
+ switchBeverages?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
312
+ const switchMeat = this.accessory.getService("Drawer Meat");
313
+ switchMeat?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
314
+ }
315
+ }
316
+ }
317
+ //# sourceMappingURL=convertibleDrawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertibleDrawer.js","sourceRoot":"","sources":["../../src/refrigerator/convertibleDrawer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAcT;IACA;IACD;IACA;IAhBD,UAAU,CAAa;IAExC,qFAAqF;IAC7E,qBAAqB,GAAG;QAC9B,IAAI,EAAE,iDAAiD;QACvD,SAAS,EAAE,iDAAiD;QAC5D,MAAM,EAAE,iDAAiD;QACzD,IAAI,EAAE,iDAAiD;KAC1D,CAAC;IAEQ,GAAG,CAAW;IAEtB,YACmB,QAAyB,EACzB,SAA4B,EAC7B,cAA4B,EAC5B,QAAgB;QAHf,aAAQ,GAAR,QAAQ,CAAiB;QACzB,cAAS,GAAT,SAAS,CAAmB;QAC7B,mBAAc,GAAd,cAAc,CAAc;QAC5B,aAAQ,GAAR,QAAQ,CAAQ;QAEhC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,GAAG,GA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AC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAExE,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACvB,yDAAyD;YACvD,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YAChE,YAAY,EAAE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACpF,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;YACtE,eAAe,EAAE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACvF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YAC5D,UAAU,EAAE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
+ import { SmartHqPlatform } from '../platform.js';
3
+ import { DevService } from '../smarthq-types.js';
4
+ /**
5
+ * Platform Accessory
6
+ * An instance of this class is created for each accessory your platform registers
7
+ * Each accessory may expose multiple services of different service types.
8
+ */
9
+ export declare class DispenserLight {
10
+ private readonly platform;
11
+ private readonly accessory;
12
+ readonly deviceServices: DevService[];
13
+ readonly deviceId: string;
14
+ private readonly smartHqApi;
15
+ private log;
16
+ constructor(platform: SmartHqPlatform, accessory: PlatformAccessory, deviceServices: DevService[], deviceId: string);
17
+ getdispenserLight(): Promise<CharacteristicValue>;
18
+ setdispenserLight(value: CharacteristicValue): Promise<void>;
19
+ }
@@ -0,0 +1,85 @@
1
+ import { SmartHqApi } from '../smartHqApi.js';
2
+ /**
3
+ * Platform Accessory
4
+ * An instance of this class is created for each accessory your platform registers
5
+ * Each accessory may expose multiple services of different service types.
6
+ */
7
+ export class DispenserLight {
8
+ platform;
9
+ accessory;
10
+ deviceServices;
11
+ deviceId;
12
+ smartHqApi;
13
+ log;
14
+ constructor(platform, accessory, deviceServices, deviceId) {
15
+ this.platform = platform;
16
+ this.accessory = accessory;
17
+ this.deviceServices = deviceServices;
18
+ this.deviceId = deviceId;
19
+ this.platform = platform;
20
+ this.accessory = accessory;
21
+ this.deviceServices = deviceServices;
22
+ this.deviceId = deviceId;
23
+ this.log = platform.log;
24
+ this.smartHqApi = new SmartHqApi(this.platform);
25
+ //=====================================================================================
26
+ // Check to see if the device has any supported Convertible Drawer services
27
+ // If not, then don't add services for device that doesn't support it
28
+ //=====================================================================================
29
+ if (!this.platform.deviceSupportsThisService(this.deviceServices, 'cloud.smarthq.device.refrigerator.dispenser.light', 'cloud.smarthq.service.toggle', 'cloud.smarthq.domain.activate.motion')) {
30
+ this.log.info('No supported Dispenser Light service found for device: ' + this.accessory.displayName);
31
+ return;
32
+ }
33
+ this.platform.debug('green', 'Adding Dispenser Light Switch');
34
+ //=====================================================================================
35
+ // create a Dispenser Light switch for the Refrigerator
36
+ //=====================================================================================
37
+ const displayName = "Dispenser Light";
38
+ const dispenserLight = this.accessory.getService(displayName)
39
+ || this.accessory.addService(this.platform.Service.Switch, displayName, 'dispenser-light-123');
40
+ dispenserLight.setCharacteristic(this.platform.Characteristic.Name, displayName);
41
+ dispenserLight.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
42
+ dispenserLight.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
43
+ dispenserLight.getCharacteristic(this.platform.Characteristic.On)
44
+ .onGet(this.getdispenserLight.bind(this))
45
+ .onSet(this.setdispenserLight.bind(this));
46
+ }
47
+ //=====================================================================================
48
+ async getdispenserLight() {
49
+ let isOn = false;
50
+ for (const service of this.deviceServices) {
51
+ if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator.dispenser.light'
52
+ && service.serviceType === 'cloud.smarthq.service.toggle'
53
+ && service.domainType === 'cloud.smarthq.domain.activate.motion') {
54
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
55
+ if (state?.on == null) {
56
+ this.platform.debug('blue', 'No On returned from getdispenserLight state');
57
+ return false;
58
+ }
59
+ isOn = state?.on;
60
+ }
61
+ }
62
+ return isOn;
63
+ }
64
+ //=====================================================================================
65
+ async setdispenserLight(value) {
66
+ const cmdBody = {
67
+ command: {
68
+ commandType: 'cloud.smarthq.command.toggle.set',
69
+ on: value
70
+ },
71
+ kind: 'service#command',
72
+ deviceId: this.deviceId,
73
+ serviceDeviceType: 'cloud.smarthq.device.refrigerator.dispenser.light',
74
+ serviceType: 'cloud.smarthq.service.toggle',
75
+ domainType: 'cloud.smarthq.domain.activate.motion'
76
+ };
77
+ const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
78
+ if (response == null) {
79
+ this.platform.debug('blue', 'No response from setdispenserLight command');
80
+ return;
81
+ }
82
+ this.platform.debug('blue', 'setdispenserLight response: ' + response.outcome);
83
+ }
84
+ }
85
+ //# sourceMappingURL=dispenserLight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispenserLight.js","sourceRoot":"","sources":["../../src/refrigerator/dispenserLight.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAKN;IACA;IACD;IACA;IAPH,UAAU,CAAa;IAC9B,GAAG,CAAW;IAEtB,YACmB,QAAyB,EACzB,SAA4B,EAC7B,cAA4B,EAC5B,QAAgB;QAHf,aAAQ,GAAR,QAAQ,CAAiB;QACzB,cAAS,GAAT,SAAS,CAAmB;QAC7B,mBAAc,GAAd,cAAc,CAAc;QAC5B,aAAQ,GAAR,QAAQ,CAAQ;QAEhC,IAAI,CAAC,QAAQ,GAAG,QAAQ,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D,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAExE,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,4CAA4C,CAAC,CAAC;YAC1E,OAAO;QACT,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,8BAA8B,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjF,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
+ import { SmartHqPlatform } from '../platform.js';
3
+ import { DevService } from '../smarthq-types.js';
4
+ /**
5
+ * Platform Accessory
6
+ * An instance of this class is created for each accessory your platform registers
7
+ * Each accessory may expose multiple services of different service types.
8
+ */
9
+ export declare class EnergySensor {
10
+ private readonly platform;
11
+ private readonly accessory;
12
+ readonly deviceServices: DevService[];
13
+ readonly deviceId: string;
14
+ private readonly smartHqApi;
15
+ private log;
16
+ private prevKwhReading;
17
+ constructor(platform: SmartHqPlatform, accessory: PlatformAccessory, deviceServices: DevService[], deviceId: string);
18
+ getEnergyChange(): Promise<CharacteristicValue>;
19
+ }