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,204 @@
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 Refrigerator {
8
+ platform;
9
+ accessory;
10
+ deviceServices;
11
+ deviceId;
12
+ // Default temperatures for a GE Profile Refrigerator
13
+ refrigeratorTargetTemperature = 2.78; // Default 37F in Celsius
14
+ smartHqApi;
15
+ log;
16
+ constructor(platform, accessory, deviceServices, deviceId) {
17
+ this.platform = platform;
18
+ this.accessory = accessory;
19
+ this.deviceServices = deviceServices;
20
+ this.deviceId = deviceId;
21
+ this.platform = platform;
22
+ this.accessory = accessory;
23
+ this.deviceServices = deviceServices;
24
+ this.deviceId = deviceId;
25
+ this.log = platform.log;
26
+ this.smartHqApi = new SmartHqApi(this.platform);
27
+ this.platform.debug('green', 'Adding Refrigerator Thermostat');
28
+ // set accessory information
29
+ this.accessory.getService(this.platform.Service.AccessoryInformation)
30
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'GE')
31
+ .setCharacteristic(this.platform.Characteristic.Model, accessory.context.device.model || 'Default-Model')
32
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.context.device.serial || 'Default-Serial');
33
+ //=====================================================================================
34
+ // create a new Thermostat service for the Refrigerator
35
+ //=====================================================================================
36
+ const displayName = "Refrigerator";
37
+ const refrigeratorThermostat = this.accessory.getService(displayName)
38
+ || this.accessory.addService(this.platform.Service.Thermostat, displayName, 'fridge-thermo1');
39
+ // set the service name, this is what is displayed as the default name on the Home app
40
+ refrigeratorThermostat.setCharacteristic(this.platform.Characteristic.Name, displayName);
41
+ refrigeratorThermostat.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
42
+ refrigeratorThermostat.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
43
+ const currentHeatCoolCharacteristic = refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState);
44
+ const targetHeatCoolCharacteristic = refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState);
45
+ const currentTempCharacteristic = refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.CurrentTemperature);
46
+ const targetTempCharacteristic = refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.TargetTemperature);
47
+ // Now modify the properties for each characteristic to match the refrigerator capabilities
48
+ // Only allow COOL mode for refrigerator
49
+ currentHeatCoolCharacteristic.setProps({
50
+ minValue: this.platform.Characteristic.CurrentHeatingCoolingState.OFF,
51
+ maxValue: this.platform.Characteristic.CurrentHeatingCoolingState.COOL,
52
+ validValues: [this.platform.Characteristic.CurrentHeatingCoolingState.COOL]
53
+ });
54
+ // Only allow COOL mode for refrigerator
55
+ targetHeatCoolCharacteristic.setProps({
56
+ minValue: this.platform.Characteristic.TargetHeatingCoolingState.OFF,
57
+ maxValue: this.platform.Characteristic.TargetHeatingCoolingState.COOL,
58
+ validValues: [this.platform.Characteristic.TargetHeatingCoolingState.COOL]
59
+ });
60
+ try {
61
+ currentTempCharacteristic.setProps({
62
+ minValue: 0,
63
+ maxValue: 8.0,
64
+ minStep: 0.1
65
+ });
66
+ }
67
+ catch (error) {
68
+ this.platform.debug('blue', 'Error setting Refrigerator Current Temperature properties: ' + error);
69
+ }
70
+ // Change properties for the characteristic for a GE Profile Refrigerator temperature range is 1.111C (34F) to 5.556C (42F)
71
+ // Values obtained from SmartHQ Api service config for refrigerator.freshfood.temperature see HB log output when debug is enabled
72
+ try {
73
+ targetTempCharacteristic.setProps({
74
+ minValue: 1.111,
75
+ maxValue: 5.556,
76
+ minStep: 0.1
77
+ });
78
+ }
79
+ catch (error) {
80
+ this.platform.debug('blue', 'Error setting Refrigerator Target Temperature properties: ' + error);
81
+ }
82
+ // create handlers for required characteristics
83
+ refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState)
84
+ .onGet(this.getCurrentHeatingCoolingState.bind(this));
85
+ // Only allow COOL mode for refrigerator
86
+ refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState)
87
+ .onGet(this.setTargetHeatingCoolingState.bind(this))
88
+ .onSet(this.setTargetHeatingCoolingState.bind(this));
89
+ refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
90
+ .onGet(this.getFridgeTemperature.bind(this));
91
+ refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.TargetTemperature)
92
+ .onGet(this.getFridgeTemperature.bind(this))
93
+ .onSet(this.setFridgeTemperature.bind(this));
94
+ refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits)
95
+ .onGet(this.handleTemperatureDisplayUnitsGet.bind(this))
96
+ .onSet(this.handleTemperatureDisplayUnitsSet.bind(this));
97
+ //=====================================================================================
98
+ // Updating characteristics values asynchronously.
99
+ //=====================================================================================
100
+ setInterval(() => {
101
+ // push the new value to HomeKit
102
+ this.getFridgeTemperature().then(temp => {
103
+ refrigeratorThermostat.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(temp);
104
+ });
105
+ }, 5000);
106
+ }
107
+ //=====================================================================================
108
+ // Refrigerator Temperature Handlers using SmartHQ API commands in smartHqApi.ts
109
+ //=====================================================================================
110
+ async getFridgeTemperature() {
111
+ let temp = 0;
112
+ for (const service of this.deviceServices) {
113
+ if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator.freshfood'
114
+ && service.serviceType === 'cloud.smarthq.service.temperature') {
115
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
116
+ if (state?.celsiusConverted == null) {
117
+ this.platform.debug('blue', 'No state.celsiusConverted returned from getFridgeTemperature state');
118
+ return 2.78; // Return 2.78C (37F) if no data
119
+ }
120
+ temp = state?.celsiusConverted;
121
+ break;
122
+ }
123
+ }
124
+ // if you need to return an error to show the device as "Not Responding" in the Home app:
125
+ // throw new this.platform.api.hap.HapStatusError(this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE);
126
+ return temp;
127
+ }
128
+ //=====================================================================================
129
+ async setFridgeTemperature(value) {
130
+ if (this.platform.config.debug) {
131
+ this.log.info("Triggered setTemperature");
132
+ }
133
+ this.refrigeratorTargetTemperature = value;
134
+ const cmdBody = {
135
+ command: {
136
+ commandType: 'cloud.smarthq.command.temperature.set',
137
+ celsius: value
138
+ },
139
+ kind: 'service#command',
140
+ deviceId: this.deviceId,
141
+ serviceDeviceType: 'cloud.smarthq.device.refrigerator.freshfood',
142
+ serviceType: 'cloud.smarthq.service.temperature',
143
+ domainType: 'cloud.smarthq.domain.setpoint'
144
+ };
145
+ const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
146
+ if (response == null) {
147
+ this.platform.debug('blue', 'No response from setFridgeTemperature command');
148
+ return;
149
+ }
150
+ }
151
+ ;
152
+ //=====================================================================================
153
+ getCurrentHeatingCoolingState() {
154
+ // set this to a valid value for CurrentHeatingCoolingState
155
+ const currentValue = this.platform.Characteristic.CurrentHeatingCoolingState.COOL;
156
+ return currentValue;
157
+ }
158
+ /**
159
+ * Handle requests to get the current value of the "Target Heating Cooling State" characteristic
160
+ */
161
+ //=====================================================================================
162
+ setCurrentHeatingCoolingState() {
163
+ // set this to a valid value for TargetHeatingCoolingState
164
+ const currentValue = this.platform.Characteristic.TargetHeatingCoolingState.COOL;
165
+ return currentValue;
166
+ }
167
+ /**
168
+ * Handle requests to set the "Target Heating Cooling State" characteristic
169
+ */
170
+ //=====================================================================================
171
+ setTargetHeatingCoolingState(value) {
172
+ // Nothing to do since refrigerator can only be in COOL mode
173
+ this.platform.debug('green', 'setTargetHeatingCoolingState called with value: ' + value);
174
+ const currentValue = this.platform.Characteristic.TargetHeatingCoolingState.COOL;
175
+ return currentValue;
176
+ }
177
+ /**
178
+ * Handle requests to get the current value of the "Target Temperature" characteristic
179
+ */
180
+ //=====================================================================================
181
+ getTargetTemperatureGet() {
182
+ const currentValue = this.refrigeratorTargetTemperature;
183
+ return currentValue;
184
+ }
185
+ /**
186
+ * Handle requests to get the current value of the "Temperature Display Units" characteristic
187
+ */
188
+ //=====================================================================================
189
+ handleTemperatureDisplayUnitsGet() {
190
+ // set this to a valid value for TemperatureDisplayUnits
191
+ const currentValue = this.platform.Characteristic.TemperatureDisplayUnits.CELSIUS;
192
+ return currentValue;
193
+ }
194
+ /**
195
+ * Handle requests to set the "Temperature Display Units" characteristic
196
+ */
197
+ //=====================================================================================
198
+ handleTemperatureDisplayUnitsSet(value) {
199
+ if (value === this.platform.Characteristic.TemperatureDisplayUnits.FAHRENHEIT) {
200
+ this.platform.debug('green', 'Temperature Display Units set to FAHRENHEIT');
201
+ }
202
+ }
203
+ }
204
+ //# sourceMappingURL=refrigerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refrigerator.js","sourceRoot":"","sources":["../../src/refrigerator/refrigerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAQJ;IACA;IACD;IACA;IAVlB,qDAAqD;IAC7C,6BAA6B,GAAG,IAAI,CAAC,CAAC,yBAAyB;IAEtD,UAAU,CAAa;IAChC,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,GAA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B,CAAC,IAAI,CAAC;QAElF,OAAO,YAAY,CAAC;IACtB,CAAC;IACD;;OAEG;IACH,uFAAuF;IACvF,6BAA6B;QAE3B,0DAA0D;QAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,yBAAyB,CAAC,IAAI,CAAC;QAEjF,OAAO,YAAY,CAAC;IACtB,CAAC;IACD;;OAEG;IACH,uFAAuF;IACvF,4BAA4B,CAAC,KAA0B;QACrD,4DAA4D;QAC5D,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,kDAAkD,GAAG,KAAK,CAAC,CAAC;QACzF,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,yBAAyB,CAAC,IAAI,CAAC;QAEjF,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,uFAAuF;IACvF,uBAAuB;QACrB,MAAM,YAAY,GAAG,IAAI,CAAC,6BAA6B,CAAA;QAEvD,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,uFAAuF;IACvF,gCAAgC;QAE9B,wDAAwD;QACxD,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,uBAAuB,CAAC,OAAO,CAAC;QAElF,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,uFAAuF;IACvF,gCAAgC,CAAC,KAA0B;QACzD,IAAI,KAAK,KAAK,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,uBAAuB,CAAC,UAAU,EAAE,CAAC;YAC9E,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,6CAA6C,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,36 @@
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
+ * These switches can be used with Pushover switches in Homekit automations to send notifications to your iOS devices
8
+ */
9
+ export declare class RefrigeratorAlerts {
10
+ private readonly platform;
11
+ private readonly accessory;
12
+ readonly deviceServices: DevService[];
13
+ readonly deviceId: string;
14
+ private alertDoorState;
15
+ private alertLeakState;
16
+ private alertFilterState;
17
+ private alertTemperatureState;
18
+ private alertUpdateState;
19
+ private readonly smartHqApi;
20
+ private log;
21
+ constructor(platform: SmartHqPlatform, accessory: PlatformAccessory, deviceServices: DevService[], deviceId: string);
22
+ checkForAlerts(): Promise<void>;
23
+ getAlertDoorOn(): Promise<CharacteristicValue>;
24
+ getAlertTemperatureOn(): Promise<CharacteristicValue>;
25
+ getAlertFilterOn(): Promise<CharacteristicValue>;
26
+ getAlertUpdateOn(): Promise<CharacteristicValue>;
27
+ getAlertLeakOn(): Promise<CharacteristicValue>;
28
+ /**
29
+ * Handle requests to set the "On" characteristic
30
+ */
31
+ setAlertDoorOn(value: CharacteristicValue): void;
32
+ setAlertTemperatureOn(value: CharacteristicValue): void;
33
+ setAlertFilterOn(value: CharacteristicValue): void;
34
+ setAlertUpdateOn(value: CharacteristicValue): void;
35
+ setAlertLeakOn(value: CharacteristicValue): void;
36
+ }
@@ -0,0 +1,204 @@
1
+ import { SmartHqApi } from '../smartHqApi.js';
2
+ import chalk from 'chalk';
3
+ /**
4
+ * Platform Accessory
5
+ * An instance of this class is created for each accessory your platform registers
6
+ * These switches can be used with Pushover switches in Homekit automations to send notifications to your iOS devices
7
+ */
8
+ export class RefrigeratorAlerts {
9
+ platform;
10
+ accessory;
11
+ deviceServices;
12
+ deviceId;
13
+ alertDoorState = false;
14
+ alertLeakState = false;
15
+ alertFilterState = false;
16
+ alertTemperatureState = false;
17
+ alertUpdateState = false;
18
+ smartHqApi;
19
+ log;
20
+ constructor(platform, accessory, deviceServices, deviceId) {
21
+ this.platform = platform;
22
+ this.accessory = accessory;
23
+ this.deviceServices = deviceServices;
24
+ this.deviceId = deviceId;
25
+ this.platform = platform;
26
+ this.accessory = accessory;
27
+ this.deviceServices = deviceServices;
28
+ this.deviceId = deviceId;
29
+ this.log = platform.log;
30
+ this.smartHqApi = new SmartHqApi(this.platform);
31
+ this.platform.debug('green', 'Adding alert/notification Switches');
32
+ // set accessory information
33
+ this.accessory.getService(this.platform.Service.AccessoryInformation)
34
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'GE')
35
+ .setCharacteristic(this.platform.Characteristic.Model, accessory.context.device.model || 'Default-Model')
36
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.context.device.serial || 'Default-Serial');
37
+ //=====================================================================================
38
+ // create new Switch services for notifications/alerts.
39
+ // These switches can be used with Pushover switches in Homekit automations to send notifications to your iOS devices
40
+ // Switches created here will be turned ON when an alert is detected and can be reset to OFF automatically or manually
41
+ // Alerts include: Door Open Alarms, High Temperature Alarms, Water Leak Alerts, Water Filter Change Alerts, OTA Updates(firmware)
42
+ //=====================================================================================
43
+ let displayName = "Alert Door";
44
+ const alertDoor = this.accessory.getService(displayName)
45
+ || this.accessory.addService(this.platform.Service.Switch, displayName, displayName);
46
+ alertDoor.setCharacteristic(this.platform.Characteristic.Name, displayName);
47
+ alertDoor.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
48
+ alertDoor.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
49
+ alertDoor.getCharacteristic(this.platform.Characteristic.On)
50
+ .onGet(this.getAlertDoorOn.bind(this))
51
+ .onSet(this.setAlertDoorOn.bind(this));
52
+ displayName = "Alert Temp";
53
+ const alertTemp = this.accessory.getService(displayName)
54
+ || this.accessory.addService(this.platform.Service.Switch, displayName, displayName);
55
+ alertTemp.setCharacteristic(this.platform.Characteristic.Name, displayName);
56
+ alertTemp.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
57
+ alertTemp.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
58
+ alertTemp.getCharacteristic(this.platform.Characteristic.On)
59
+ .onGet(this.getAlertTemperatureOn.bind(this))
60
+ .onSet(this.setAlertTemperatureOn.bind(this));
61
+ displayName = "Alert Leak";
62
+ const alertLeak = this.accessory.getService(displayName)
63
+ || this.accessory.addService(this.platform.Service.Switch, displayName, displayName);
64
+ alertLeak.setCharacteristic(this.platform.Characteristic.Name, displayName);
65
+ alertLeak.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
66
+ alertLeak.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
67
+ alertLeak.getCharacteristic(this.platform.Characteristic.On)
68
+ .onGet(this.getAlertLeakOn.bind(this))
69
+ .onSet(this.setAlertLeakOn.bind(this));
70
+ displayName = "Alert Filter";
71
+ const alertFilter = this.accessory.getService(displayName)
72
+ || this.accessory.addService(this.platform.Service.Switch, displayName, displayName);
73
+ alertFilter.setCharacteristic(this.platform.Characteristic.Name, displayName);
74
+ alertFilter.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
75
+ alertFilter.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
76
+ alertFilter.getCharacteristic(this.platform.Characteristic.On)
77
+ .onGet(this.getAlertFilterOn.bind(this))
78
+ .onSet(this.setAlertFilterOn.bind(this));
79
+ displayName = "Alert Firm";
80
+ const alertFirm = this.accessory.getService(displayName)
81
+ || this.accessory.addService(this.platform.Service.Switch, displayName, displayName);
82
+ alertFirm.setCharacteristic(this.platform.Characteristic.Name, displayName);
83
+ alertFirm.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
84
+ alertFirm.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
85
+ alertFirm.getCharacteristic(this.platform.Characteristic.On)
86
+ .onGet(this.getAlertUpdateOn.bind(this))
87
+ .onSet(this.setAlertUpdateOn.bind(this));
88
+ //=====================================================================================
89
+ // Updating characteristics values asynchronously.
90
+ //=====================================================================================
91
+ setInterval(() => {
92
+ // push the new value to HomeKit
93
+ this.getAlertDoorOn().then(state => {
94
+ alertDoor.getCharacteristic(this.platform.Characteristic.On).updateValue(state);
95
+ if (state) {
96
+ this.setAlertDoorOn(false);
97
+ }
98
+ });
99
+ this.getAlertTemperatureOn().then(state => {
100
+ alertTemp.getCharacteristic(this.platform.Characteristic.On).updateValue(state);
101
+ if (state) {
102
+ this.setAlertTemperatureOn(false);
103
+ }
104
+ });
105
+ this.getAlertLeakOn().then(state => {
106
+ alertLeak.getCharacteristic(this.platform.Characteristic.On).updateValue(state);
107
+ if (state) {
108
+ this.setAlertLeakOn(false);
109
+ }
110
+ });
111
+ this.getAlertFilterOn().then(state => {
112
+ alertFilter.getCharacteristic(this.platform.Characteristic.On).updateValue(state);
113
+ if (state) {
114
+ this.setAlertFilterOn(false);
115
+ }
116
+ });
117
+ this.getAlertUpdateOn().then(state => {
118
+ alertFirm.getCharacteristic(this.platform.Characteristic.On).updateValue(state);
119
+ if (state) {
120
+ this.setAlertUpdateOn(false);
121
+ }
122
+ });
123
+ }, 5000);
124
+ setInterval(() => {
125
+ this.checkForAlerts();
126
+ }, 60000);
127
+ }
128
+ //=====================================================================================
129
+ // Check for any alerts - filter for last minute
130
+ //=====================================================================================
131
+ async checkForAlerts() {
132
+ const alerts = await this.smartHqApi.getRecentAlerts();
133
+ if (alerts == null) {
134
+ return;
135
+ }
136
+ for (const alert of alerts) {
137
+ const type = alert.alertType;
138
+ if (type.includes('door.alarm')) {
139
+ this.log.warn(chalk.yellow(`Alert: ${alert.alertType} `));
140
+ this.setAlertDoorOn(true);
141
+ }
142
+ else if (type.includes('temperature.high')) {
143
+ this.log.warn(chalk.red(`Alert: ${alert.alertType} `));
144
+ this.setAlertTemperatureOn(true);
145
+ }
146
+ else if (type.includes('leak')) {
147
+ this.log.warn(chalk.red(`Alert: ${alert.alertType} `));
148
+ this.setAlertLeakOn(true);
149
+ }
150
+ else if (type.includes('filter')) {
151
+ this.log.warn(chalk.red(`Alert: ${alert.alertType} `));
152
+ this.setAlertFilterOn(true);
153
+ }
154
+ else if (type.includes('ota.update')) {
155
+ this.log.warn(chalk.red(`Alert: ${alert.alertType} `));
156
+ this.setAlertUpdateOn(true);
157
+ }
158
+ }
159
+ }
160
+ getAlertDoorOn() {
161
+ const currentValue = this.alertDoorState;
162
+ return Promise.resolve(currentValue);
163
+ }
164
+ getAlertTemperatureOn() {
165
+ const currentValue = this.alertTemperatureState;
166
+ return Promise.resolve(currentValue);
167
+ }
168
+ getAlertFilterOn() {
169
+ const currentValue = this.alertFilterState;
170
+ return Promise.resolve(currentValue);
171
+ }
172
+ getAlertUpdateOn() {
173
+ const currentValue = this.alertUpdateState;
174
+ return Promise.resolve(currentValue);
175
+ }
176
+ getAlertLeakOn() {
177
+ const currentValue = this.alertLeakState;
178
+ return Promise.resolve(currentValue);
179
+ }
180
+ /**
181
+ * Handle requests to set the "On" characteristic
182
+ */
183
+ setAlertDoorOn(value) {
184
+ this.alertDoorState = value;
185
+ // Will reset the alert (turn switch OFF) after 5 seconds by code in the setInterval function above
186
+ }
187
+ setAlertTemperatureOn(value) {
188
+ this.alertTemperatureState = value;
189
+ // Will reset the alert (turn switch OFF) after 5 seconds by code in the setInterval function above
190
+ }
191
+ setAlertFilterOn(value) {
192
+ this.alertFilterState = value;
193
+ // Will reset the alert (turn switch OFF) after 5 seconds by code in the setInterval function above
194
+ }
195
+ setAlertUpdateOn(value) {
196
+ this.alertUpdateState = value;
197
+ // Will reset the alert (turn switch OFF) after 5 seconds by code in the setInterval function above
198
+ }
199
+ setAlertLeakOn(value) {
200
+ this.alertLeakState = value;
201
+ // Will reset the alert (turn switch OFF) after 5 seconds by code in the setInterval function above
202
+ }
203
+ }
204
+ //# sourceMappingURL=refrigeratorAlerts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refrigeratorAlerts.js","sourceRoot":"","sources":["../../src/refrigerator/refrigeratorAlerts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAY,kBAAkB,CAAC;AACpD,OAAO,KAAK,MAAqB,OAAO,CAAC;AAGzC;;;;GAIG;A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AAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IACD,gBAAgB;QACd,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAE3C,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IACD,gBAAgB;QACd,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAE3C,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IACD,cAAc;QACZ,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC;QAEzC,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,KAA0B;QACvC,IAAI,CAAC,cAAc,GAAG,KAAgB,CAAC;QACvC,mGAAmG;IACrG,CAAC;IACD,qBAAqB,CAAC,KAA0B;QAC9C,IAAI,CAAC,qBAAqB,GAAG,KAAgB,CAAC;QAC9C,mGAAmG;IACrG,CAAC;IACD,gBAAgB,CAAC,KAA0B;QACzC,IAAI,CAAC,gBAAgB,GAAG,KAAgB,CAAC;QACzC,mGAAmG;IACrG,CAAC;IACD,gBAAgB,CAAC,KAA0B;QACzC,IAAI,CAAC,gBAAgB,GAAG,KAAgB,CAAC;QACzC,mGAAmG;IACrG,CAAC;IACD,cAAc,CAAC,KAA0B;QACvC,IAAI,CAAC,cAAc,GAAG,KAAgB,CAAC;QACvC,mGAAmG;IACrG,CAAC;CACF"}
@@ -0,0 +1,20 @@
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 SabbathMode {
10
+ private readonly platform;
11
+ private readonly accessory;
12
+ readonly deviceServices: DevService[];
13
+ readonly deviceId: string;
14
+ static sabbathModeStatus: boolean;
15
+ private readonly smartHqApi;
16
+ private log;
17
+ constructor(platform: SmartHqPlatform, accessory: PlatformAccessory, deviceServices: DevService[], deviceId: string);
18
+ getSabbathMode(): Promise<CharacteristicValue>;
19
+ setSabbathMode(value: CharacteristicValue): Promise<void>;
20
+ }
@@ -0,0 +1,91 @@
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 SabbathMode {
8
+ platform;
9
+ accessory;
10
+ deviceServices;
11
+ deviceId;
12
+ static sabbathModeStatus = false;
13
+ smartHqApi;
14
+ log;
15
+ constructor(platform, accessory, deviceServices, deviceId) {
16
+ this.platform = platform;
17
+ this.accessory = accessory;
18
+ this.deviceServices = deviceServices;
19
+ this.deviceId = deviceId;
20
+ this.platform = platform;
21
+ this.accessory = accessory;
22
+ this.deviceServices = deviceServices;
23
+ this.deviceId = deviceId;
24
+ this.log = platform.log;
25
+ this.smartHqApi = new SmartHqApi(this.platform);
26
+ //=====================================================================================
27
+ // Check to see if the device has any supported Sabbath Mode services
28
+ // If not, then don't add services for device that doesn't support it
29
+ //=====================================================================================
30
+ if (!this.platform.deviceSupportsThisService(this.deviceServices, 'cloud.smarthq.device.appliance', 'cloud.smarthq.service.toggle', 'cloud.smarthq.domain.sabbath')) {
31
+ this.log.info('No supported Sabbath Mode service found for device: ' + this.accessory.displayName);
32
+ return;
33
+ }
34
+ this.platform.debug('green', 'Adding Sabbath Mode Switch');
35
+ // set accessory information
36
+ this.accessory.getService(this.platform.Service.AccessoryInformation)
37
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'GE')
38
+ .setCharacteristic(this.platform.Characteristic.Model, accessory.context.device.model || 'Default-Model')
39
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.context.device.serial || 'Default-Serial');
40
+ //=====================================================================================
41
+ // create a sabbath mode switch for the Refrigerator
42
+ //=====================================================================================
43
+ const displayName = "Sabbath Mode";
44
+ const sabbathMode = this.accessory.getService(displayName)
45
+ || this.accessory.addService(this.platform.Service.Switch, displayName, 'sabbathmode123');
46
+ sabbathMode.setCharacteristic(this.platform.Characteristic.Name, displayName);
47
+ sabbathMode.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
48
+ sabbathMode.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
49
+ sabbathMode.getCharacteristic(this.platform.Characteristic.On)
50
+ .onGet(this.getSabbathMode.bind(this))
51
+ .onSet(this.setSabbathMode.bind(this));
52
+ }
53
+ //=====================================================================================
54
+ async getSabbathMode() {
55
+ for (const service of this.deviceServices) {
56
+ if (service.serviceDeviceType === 'cloud.smarthq.device.appliance'
57
+ && service.serviceType === 'cloud.smarthq.service.toggle'
58
+ && service.domainType === 'cloud.smarthq.domain.sabbath') {
59
+ const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
60
+ if (state?.on == null) {
61
+ this.platform.debug('blue', 'No state.on returned from getSabbathMode state');
62
+ return false;
63
+ }
64
+ SabbathMode.sabbathModeStatus = state?.on;
65
+ break;
66
+ }
67
+ }
68
+ return SabbathMode.sabbathModeStatus;
69
+ }
70
+ //=====================================================================================
71
+ async setSabbathMode(value) {
72
+ value = SabbathMode.sabbathModeStatus ? false : true;
73
+ const cmdBody = {
74
+ command: {
75
+ commandType: 'cloud.smarthq.command.toggle.set',
76
+ on: value
77
+ },
78
+ kind: 'service#command',
79
+ deviceId: this.deviceId,
80
+ serviceDeviceType: 'cloud.smarthq.device.appliance',
81
+ serviceType: 'cloud.smarthq.service.toggle',
82
+ domainType: 'cloud.smarthq.domain.sabbath'
83
+ };
84
+ const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
85
+ if (response == null) {
86
+ this.platform.debug('blue', 'No response from setSabbathMode command');
87
+ return;
88
+ }
89
+ }
90
+ }
91
+ //# sourceMappingURL=sabbathMode.js.map
@@ -0,0 +1 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rB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,yCAAyC,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;IACH,CAAC"}
@@ -0,0 +1,21 @@
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 TemperatureUnits {
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
+ getunitsCelsius(): Promise<CharacteristicValue>;
18
+ setunitsCelsius(value: CharacteristicValue): Promise<void>;
19
+ getunitsFahrenheit(): Promise<CharacteristicValue>;
20
+ setunitsFahrenheit(value: CharacteristicValue): Promise<void>;
21
+ }