@mp-consulting/homebridge-lg-thinq 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 (241) hide show
  1. package/.claude/settings.local.json +15 -0
  2. package/CHANGELOG.md +98 -0
  3. package/LICENSE +176 -0
  4. package/README.md +114 -0
  5. package/config.schema.json +399 -0
  6. package/dist/__tests__/baseDevice.spec.d.ts +1 -0
  7. package/dist/__tests__/baseDevice.spec.js +96 -0
  8. package/dist/__tests__/baseDevice.spec.js.map +1 -0
  9. package/dist/__tests__/deviceControl.coercion.spec.d.ts +1 -0
  10. package/dist/__tests__/deviceControl.coercion.spec.js +53 -0
  11. package/dist/__tests__/deviceControl.coercion.spec.js.map +1 -0
  12. package/dist/__tests__/helper.spec.d.ts +1 -0
  13. package/dist/__tests__/helper.spec.js +74 -0
  14. package/dist/__tests__/helper.spec.js.map +1 -0
  15. package/dist/baseDevice.d.ts +40 -0
  16. package/dist/baseDevice.js +85 -0
  17. package/dist/baseDevice.js.map +1 -0
  18. package/dist/baseDevice.spec.d.ts +1 -0
  19. package/dist/baseDevice.spec.js +107 -0
  20. package/dist/baseDevice.spec.js.map +1 -0
  21. package/dist/characteristics/TotalConsumption.d.ts +2 -0
  22. package/dist/characteristics/TotalConsumption.js +17 -0
  23. package/dist/characteristics/TotalConsumption.js.map +1 -0
  24. package/dist/characteristics/index.d.ts +2 -0
  25. package/dist/characteristics/index.js +7 -0
  26. package/dist/characteristics/index.js.map +1 -0
  27. package/dist/cli.d.ts +2 -0
  28. package/dist/cli.js +89 -0
  29. package/dist/cli.js.map +1 -0
  30. package/dist/devices/AeroTower.d.ts +24 -0
  31. package/dist/devices/AeroTower.js +113 -0
  32. package/dist/devices/AeroTower.js.map +1 -0
  33. package/dist/devices/AirConditioner.d.ts +425 -0
  34. package/dist/devices/AirConditioner.js +1253 -0
  35. package/dist/devices/AirConditioner.js.map +1 -0
  36. package/dist/devices/AirPurifier.d.ts +50 -0
  37. package/dist/devices/AirPurifier.js +281 -0
  38. package/dist/devices/AirPurifier.js.map +1 -0
  39. package/dist/devices/Dehumidifier.d.ts +28 -0
  40. package/dist/devices/Dehumidifier.js +175 -0
  41. package/dist/devices/Dehumidifier.js.map +1 -0
  42. package/dist/devices/Dishwasher.d.ts +64 -0
  43. package/dist/devices/Dishwasher.js +740 -0
  44. package/dist/devices/Dishwasher.js.map +1 -0
  45. package/dist/devices/Microwave.d.ts +128 -0
  46. package/dist/devices/Microwave.js +1939 -0
  47. package/dist/devices/Microwave.js.map +1 -0
  48. package/dist/devices/Oven.d.ts +148 -0
  49. package/dist/devices/Oven.js +1850 -0
  50. package/dist/devices/Oven.js.map +1 -0
  51. package/dist/devices/RangeHood.d.ts +16 -0
  52. package/dist/devices/RangeHood.js +99 -0
  53. package/dist/devices/RangeHood.js.map +1 -0
  54. package/dist/devices/Refrigerator.d.ts +50 -0
  55. package/dist/devices/Refrigerator.js +325 -0
  56. package/dist/devices/Refrigerator.js.map +1 -0
  57. package/dist/devices/Styler.d.ts +27 -0
  58. package/dist/devices/Styler.js +76 -0
  59. package/dist/devices/Styler.js.map +1 -0
  60. package/dist/devices/WasherDryer.d.ts +39 -0
  61. package/dist/devices/WasherDryer.js +170 -0
  62. package/dist/devices/WasherDryer.js.map +1 -0
  63. package/dist/devices/WasherDryer2.d.ts +9 -0
  64. package/dist/devices/WasherDryer2.js +16 -0
  65. package/dist/devices/WasherDryer2.js.map +1 -0
  66. package/dist/errors/AuthenticationError.d.ts +2 -0
  67. package/dist/errors/AuthenticationError.js +3 -0
  68. package/dist/errors/AuthenticationError.js.map +1 -0
  69. package/dist/errors/ManualProcessNeeded.d.ts +3 -0
  70. package/dist/errors/ManualProcessNeeded.js +4 -0
  71. package/dist/errors/ManualProcessNeeded.js.map +1 -0
  72. package/dist/errors/MonitorError.d.ts +2 -0
  73. package/dist/errors/MonitorError.js +3 -0
  74. package/dist/errors/MonitorError.js.map +1 -0
  75. package/dist/errors/NotConnectedError.d.ts +3 -0
  76. package/dist/errors/NotConnectedError.js +4 -0
  77. package/dist/errors/NotConnectedError.js.map +1 -0
  78. package/dist/errors/TokenError.d.ts +2 -0
  79. package/dist/errors/TokenError.js +3 -0
  80. package/dist/errors/TokenError.js.map +1 -0
  81. package/dist/errors/TokenExpiredError.d.ts +3 -0
  82. package/dist/errors/TokenExpiredError.js +4 -0
  83. package/dist/errors/TokenExpiredError.js.map +1 -0
  84. package/dist/errors/index.d.ts +6 -0
  85. package/dist/errors/index.js +7 -0
  86. package/dist/errors/index.js.map +1 -0
  87. package/dist/helper.d.ts +24 -0
  88. package/dist/helper.js +66 -0
  89. package/dist/helper.js.map +1 -0
  90. package/dist/helper.spec.d.ts +1 -0
  91. package/dist/helper.spec.js +74 -0
  92. package/dist/helper.spec.js.map +1 -0
  93. package/dist/index.d.ts +6 -0
  94. package/dist/index.js +9 -0
  95. package/dist/index.js.map +1 -0
  96. package/dist/lib/API.d.ts +141 -0
  97. package/dist/lib/API.js +362 -0
  98. package/dist/lib/API.js.map +1 -0
  99. package/dist/lib/API.spec.d.ts +1 -0
  100. package/dist/lib/API.spec.js +55 -0
  101. package/dist/lib/API.spec.js.map +1 -0
  102. package/dist/lib/Auth.d.ts +99 -0
  103. package/dist/lib/Auth.js +348 -0
  104. package/dist/lib/Auth.js.map +1 -0
  105. package/dist/lib/Auth.spec.d.ts +1 -0
  106. package/dist/lib/Auth.spec.js +111 -0
  107. package/dist/lib/Auth.spec.js.map +1 -0
  108. package/dist/lib/Device.d.ts +88 -0
  109. package/dist/lib/Device.js +95 -0
  110. package/dist/lib/Device.js.map +1 -0
  111. package/dist/lib/Device.spec.d.ts +1 -0
  112. package/dist/lib/Device.spec.js +53 -0
  113. package/dist/lib/Device.spec.js.map +1 -0
  114. package/dist/lib/DeviceModel.d.ts +164 -0
  115. package/dist/lib/DeviceModel.js +321 -0
  116. package/dist/lib/DeviceModel.js.map +1 -0
  117. package/dist/lib/DeviceModel.spec.d.ts +1 -0
  118. package/dist/lib/DeviceModel.spec.js +90 -0
  119. package/dist/lib/DeviceModel.spec.js.map +1 -0
  120. package/dist/lib/Gateway.d.ts +18 -0
  121. package/dist/lib/Gateway.js +25 -0
  122. package/dist/lib/Gateway.js.map +1 -0
  123. package/dist/lib/Gateway.spec.d.ts +1 -0
  124. package/dist/lib/Gateway.spec.js +35 -0
  125. package/dist/lib/Gateway.spec.js.map +1 -0
  126. package/dist/lib/Persist.d.ts +101 -0
  127. package/dist/lib/Persist.js +245 -0
  128. package/dist/lib/Persist.js.map +1 -0
  129. package/dist/lib/Persist.spec.d.ts +1 -0
  130. package/dist/lib/Persist.spec.js +90 -0
  131. package/dist/lib/Persist.spec.js.map +1 -0
  132. package/dist/lib/Session.d.ts +80 -0
  133. package/dist/lib/Session.js +100 -0
  134. package/dist/lib/Session.js.map +1 -0
  135. package/dist/lib/Session.spec.d.ts +1 -0
  136. package/dist/lib/Session.spec.js +43 -0
  137. package/dist/lib/Session.spec.js.map +1 -0
  138. package/dist/lib/ThinQ.d.ts +28 -0
  139. package/dist/lib/ThinQ.js +373 -0
  140. package/dist/lib/ThinQ.js.map +1 -0
  141. package/dist/lib/__tests__/API.spec.d.ts +1 -0
  142. package/dist/lib/__tests__/API.spec.js +55 -0
  143. package/dist/lib/__tests__/API.spec.js.map +1 -0
  144. package/dist/lib/__tests__/Auth.spec.d.ts +1 -0
  145. package/dist/lib/__tests__/Auth.spec.js +110 -0
  146. package/dist/lib/__tests__/Auth.spec.js.map +1 -0
  147. package/dist/lib/__tests__/Device.spec.d.ts +1 -0
  148. package/dist/lib/__tests__/Device.spec.js +53 -0
  149. package/dist/lib/__tests__/Device.spec.js.map +1 -0
  150. package/dist/lib/__tests__/DeviceModel.spec.d.ts +1 -0
  151. package/dist/lib/__tests__/DeviceModel.spec.js +90 -0
  152. package/dist/lib/__tests__/DeviceModel.spec.js.map +1 -0
  153. package/dist/lib/__tests__/Gateway.spec.d.ts +1 -0
  154. package/dist/lib/__tests__/Gateway.spec.js +35 -0
  155. package/dist/lib/__tests__/Gateway.spec.js.map +1 -0
  156. package/dist/lib/__tests__/Persist.spec.d.ts +1 -0
  157. package/dist/lib/__tests__/Persist.spec.js +90 -0
  158. package/dist/lib/__tests__/Persist.spec.js.map +1 -0
  159. package/dist/lib/__tests__/Session.spec.d.ts +1 -0
  160. package/dist/lib/__tests__/Session.spec.js +43 -0
  161. package/dist/lib/__tests__/Session.spec.js.map +1 -0
  162. package/dist/lib/constants.d.ts +95 -0
  163. package/dist/lib/constants.js +106 -0
  164. package/dist/lib/constants.js.map +1 -0
  165. package/dist/lib/request.d.ts +2 -0
  166. package/dist/lib/request.js +66 -0
  167. package/dist/lib/request.js.map +1 -0
  168. package/dist/platform.d.ts +41 -0
  169. package/dist/platform.js +229 -0
  170. package/dist/platform.js.map +1 -0
  171. package/dist/settings.d.ts +8 -0
  172. package/dist/settings.js +9 -0
  173. package/dist/settings.js.map +1 -0
  174. package/dist/status/BaseStatus.d.ts +48 -0
  175. package/dist/status/BaseStatus.js +59 -0
  176. package/dist/status/BaseStatus.js.map +1 -0
  177. package/dist/types/snapshots.d.ts +142 -0
  178. package/dist/types/snapshots.js +6 -0
  179. package/dist/types/snapshots.js.map +1 -0
  180. package/dist/utils/__tests__/normalize.spec.d.ts +1 -0
  181. package/dist/utils/__tests__/normalize.spec.js +95 -0
  182. package/dist/utils/__tests__/normalize.spec.js.map +1 -0
  183. package/dist/utils/normalize.d.ts +22 -0
  184. package/dist/utils/normalize.js +51 -0
  185. package/dist/utils/normalize.js.map +1 -0
  186. package/dist/v1/__tests__/prepareControlData.spec.d.ts +1 -0
  187. package/dist/v1/__tests__/prepareControlData.spec.js +48 -0
  188. package/dist/v1/__tests__/prepareControlData.spec.js.map +1 -0
  189. package/dist/v1/devices/AC.d.ts +13 -0
  190. package/dist/v1/devices/AC.js +112 -0
  191. package/dist/v1/devices/AC.js.map +1 -0
  192. package/dist/v1/devices/AirPurifier.d.ts +15 -0
  193. package/dist/v1/devices/AirPurifier.js +57 -0
  194. package/dist/v1/devices/AirPurifier.js.map +1 -0
  195. package/dist/v1/devices/RangeHood.d.ts +6 -0
  196. package/dist/v1/devices/RangeHood.js +12 -0
  197. package/dist/v1/devices/RangeHood.js.map +1 -0
  198. package/dist/v1/devices/Refrigerator.d.ts +17 -0
  199. package/dist/v1/devices/Refrigerator.js +69 -0
  200. package/dist/v1/devices/Refrigerator.js.map +1 -0
  201. package/dist/v1/devices/Washer.d.ts +10 -0
  202. package/dist/v1/devices/Washer.js +23 -0
  203. package/dist/v1/devices/Washer.js.map +1 -0
  204. package/dist/v1/devices/index.d.ts +6 -0
  205. package/dist/v1/devices/index.js +7 -0
  206. package/dist/v1/devices/index.js.map +1 -0
  207. package/dist/v1/helper.d.ts +14 -0
  208. package/dist/v1/helper.js +111 -0
  209. package/dist/v1/helper.js.map +1 -0
  210. package/dist/v1/transforms/AirPurifierState.d.ts +2 -0
  211. package/dist/v1/transforms/AirPurifierState.js +9 -0
  212. package/dist/v1/transforms/AirPurifierState.js.map +1 -0
  213. package/dist/v1/transforms/AirState.d.ts +9 -0
  214. package/dist/v1/transforms/AirState.js +55 -0
  215. package/dist/v1/transforms/AirState.js.map +1 -0
  216. package/dist/v1/transforms/HoodState.d.ts +17 -0
  217. package/dist/v1/transforms/HoodState.js +20 -0
  218. package/dist/v1/transforms/HoodState.js.map +1 -0
  219. package/dist/v1/transforms/RefState.d.ts +6 -0
  220. package/dist/v1/transforms/RefState.js +29 -0
  221. package/dist/v1/transforms/RefState.js.map +1 -0
  222. package/dist/v1/transforms/WasherDryer.d.ts +49 -0
  223. package/dist/v1/transforms/WasherDryer.js +56 -0
  224. package/dist/v1/transforms/WasherDryer.js.map +1 -0
  225. package/docs/authorization.md +40 -0
  226. package/docs/device-configuration.md +68 -0
  227. package/homebridge-ui/public/index.html +120 -0
  228. package/homebridge-ui/public/js/app.js +300 -0
  229. package/homebridge-ui/public/js/countries.js +233 -0
  230. package/homebridge-ui/public/styles.css +185 -0
  231. package/homebridge-ui/server.js +103 -0
  232. package/jest.config.ts +39 -0
  233. package/package.json +83 -0
  234. package/sample/README.md +10 -0
  235. package/sample/airconditioner-model.json +3080 -0
  236. package/sample/airconditioner-snapshot.json +49 -0
  237. package/sample/airconditioner.json +157 -0
  238. package/sample/dishwasher-model.json +869 -0
  239. package/sample/dishwasher.json +125 -0
  240. package/sample/washer_dryer-model.json +1294 -0
  241. package/sample/washer_dryer.json +126 -0
@@ -0,0 +1,1850 @@
1
+ /**
2
+ * Special thank to carlosgamezvillegas (https://github.com/carlosgamezvillegas) for the initial work on the Oven device.
3
+ */
4
+ import { BaseDevice } from '../baseDevice.js';
5
+ import { normalizeBoolean, normalizeNumber } from '../helper.js';
6
+ import { TWELVE_HOURS_IN_SECONDS, ONE_HOUR_IN_SECONDS, ONE_SECOND_MS, TEN_SECONDS_MS, TWO_MINUTES_MS, THIRTY_MINUTES_IN_SECONDS } from '../lib/constants.js';
7
+ var OvenState;
8
+ (function (OvenState) {
9
+ OvenState["INITIAL"] = "@OV_STATE_INITIAL_W";
10
+ OvenState["PREHEATING"] = "@OV_STATE_PREHEAT_W";
11
+ OvenState["COOKING_IN_PROGRESS"] = "@OV_STATE_COOK_W";
12
+ OvenState["DONE"] = "@OV_STATE_COOK_COMPLETE_W";
13
+ OvenState["COOLING"] = "@OV_TERM_COOLING_W";
14
+ OvenState["CLEANING"] = "@OV_STATE_CLEAN_W";
15
+ OvenState["CLEANING_DONE"] = "@OV_STATE_CLEAN_COMPLETE_W";
16
+ })(OvenState || (OvenState = {}));
17
+ /*
18
+ enum OvenMode {
19
+ NONE = '@NONE',
20
+ BAKE = '@OV_TERM_BAKE_W',
21
+ ROAST = '@OV_TERM_ROAST_W',
22
+ CONVECTION_BAKE = '@OV_TERM_CONV_BAKE_W',
23
+ CONVECTION_ROAST = '@OV_TERM_CONV_ROAST_W',
24
+ CRISP_CONVECTION = '@OV_TERM_CRISP_CONV_W',
25
+ FAVORITE = '@OV_TERM_COOKMODE_FAVORITE_W',
26
+ BROIL = '@OV_TERM_BROIL_W',
27
+ WARM = '@OV_TERM_WARM_W',
28
+ PROOF = '@OV_TERM_PROOF_W',
29
+ FROZEN_MEAL = '@OV_TERM_FROZEN_MEAL_W',
30
+ SLOW_COOK = '@OV_TERM_SLOW_COOK_W',
31
+ PROBE_SET = '@OV_TERM_PROBE_SET_W',
32
+ EASY_CLEAN = '@OV_TERM_EASY_CLEAN_W',
33
+ SPEED_BROIL = '@OV_TERM_SPEED_BROIL_W',
34
+ SELF_CLEAN = '@OV_TERM_SELF_CLEAN_W',
35
+ SPEED_ROAST = '@OV_TERM_SPEED_ROAST_W',
36
+ AIR_FRY = '@OV_TERM_AIR_FRY_W',
37
+ PIZZA = '@OV_TERM_PIZZA_W',
38
+ AIR_SOUSVIDE = '@OV_TERM_AIR_SOUSVIDE_W',
39
+ }
40
+ */
41
+ export default class Oven extends BaseDevice {
42
+ platform;
43
+ accessory;
44
+ inputNameStatus = 'Oven Status';
45
+ inputNameMode = 'Oven Mode';
46
+ probeName = 'Oven Probe Status';
47
+ inputNameTempString = 'Oven Temperature';
48
+ courseStartString = 'Oven Start Time Not Set';
49
+ courseTimeString = 'Oven Cook Time Not Set';
50
+ courseTimerString = 'Oven Timer Not Set';
51
+ courseTimeEndString = 'Oven End Time Not Set';
52
+ inputNameOptions = 'Oven Options';
53
+ inputNameBurner1 = 'Front Left Burner Status';
54
+ inputNameBurner2 = 'Back Left Burner Status';
55
+ inputNameBurner3 = 'Center Burner Status';
56
+ inputNameBurner4 = 'Front Right Burner Status';
57
+ inputNameBurner5 = 'Back Right Burner Status';
58
+ firstStart = true;
59
+ firstDuration = 0;
60
+ firstTimer = 0;
61
+ courseStartMS = 0;
62
+ inputID = 1;
63
+ temperatureFCommand = 0;
64
+ thermostatSel = 0;
65
+ timerAlarmSec = 0;
66
+ pauseUpdate = false;
67
+ firstPause = true;
68
+ localTemperature = 22;
69
+ localHumidity = 50;
70
+ ovenCommandList = {
71
+ ovenMode: 'BAKE',
72
+ ovenSetTemperature: 350,
73
+ tempUnits: 'FAHRENHEIT',
74
+ ovenSetDuration: THIRTY_MINUTES_IN_SECONDS,
75
+ probeTemperature: 0,
76
+ ovenKeepWarm: 'DISABLE',
77
+ };
78
+ monitorOnly = true;
79
+ homekitMonitorOnly = true;
80
+ waitingForCommand = false;
81
+ // flag
82
+ showProbe = false;
83
+ showTime = false;
84
+ showTimer = false;
85
+ showBurner1 = false;
86
+ showBurner2 = false;
87
+ showBurner3 = false;
88
+ showBurner4 = false;
89
+ showBurner5 = false;
90
+ /** service */
91
+ ovenService;
92
+ ovenState;
93
+ ovenMode;
94
+ ovenTemp;
95
+ probeService;
96
+ ovenOptions;
97
+ ovenStart;
98
+ ovenTimer;
99
+ ovenTime;
100
+ ovenEndTime;
101
+ burner1;
102
+ burner2;
103
+ burner3;
104
+ burner4;
105
+ burner5;
106
+ ovenTimerService;
107
+ ovenAlarmService;
108
+ bakeSwitch;
109
+ convectionBakeSwitch;
110
+ convectionRoastSwitch;
111
+ frozenMealSwitch;
112
+ airFrySwitch;
113
+ airSousvideSwitch;
114
+ warmModeSwitch;
115
+ cancelSwitch;
116
+ monitorOnlySwitch;
117
+ startOvenSwitch;
118
+ keepWarmSwitch;
119
+ ovenDoorOpened;
120
+ rangeOn;
121
+ remoteEnabled;
122
+ burnersOnNumber;
123
+ ovenTempControl;
124
+ probeTempControl;
125
+ createInputSourceService(name, subtype, identifier, configuredName, isShow) {
126
+ return this.accessory.getService(name) ||
127
+ this.accessory.addService(this.platform.Service.InputSource, name, subtype)
128
+ .setCharacteristic(this.platform.Characteristic.Identifier, identifier)
129
+ .setCharacteristic(this.platform.Characteristic.ConfiguredName, configuredName)
130
+ .setCharacteristic(this.platform.Characteristic.IsConfigured, this.platform.Characteristic.IsConfigured.CONFIGURED)
131
+ .setCharacteristic(this.platform.Characteristic.InputSourceType, this.platform.Characteristic.InputSourceType.APPLICATION)
132
+ .setCharacteristic(this.platform.Characteristic.TargetVisibilityState, isShow ? this.platform.Characteristic.TargetVisibilityState.SHOWN : this.platform.Characteristic.TargetVisibilityState.HIDDEN)
133
+ .setCharacteristic(this.platform.Characteristic.CurrentVisibilityState, isShow ? this.platform.Characteristic.CurrentVisibilityState.SHOWN : this.platform.Characteristic.CurrentVisibilityState.HIDDEN);
134
+ }
135
+ constructor(platform, accessory, logger) {
136
+ super(platform, accessory, logger);
137
+ this.platform = platform;
138
+ this.accessory = accessory;
139
+ const { Characteristic } = this.platform;
140
+ this.ovenService = this.accessory.getService(this.config.name) ||
141
+ this.accessory.addService(this.platform.Service.Television, this.config.name, 'NicoCataGaTa-OvenOven7');
142
+ this.ovenService.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'LG Range');
143
+ this.ovenService.setPrimaryService(true);
144
+ this.ovenService.setCharacteristic(this.platform
145
+ .Characteristic.SleepDiscoveryMode, this.platform.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE);
146
+ this.ovenService.getCharacteristic(this.platform.Characteristic.Active)
147
+ .on('get', (callback) => {
148
+ const currentValue = this.ovenServiceActive();
149
+ callback(null, currentValue);
150
+ })
151
+ .on('set', (value, callback) => {
152
+ const enabled = normalizeBoolean(value);
153
+ if (!enabled) {
154
+ this.stopOven();
155
+ }
156
+ else {
157
+ this.sendOvenCommand();
158
+ }
159
+ callback(null);
160
+ });
161
+ this.ovenService
162
+ .setCharacteristic(this.platform.Characteristic.ActiveIdentifier, this.inputID);
163
+ this.ovenService.getCharacteristic(this.platform.Characteristic.ActiveIdentifier)
164
+ .on('set', (inputIdentifier, callback) => {
165
+ const vNum = normalizeNumber(inputIdentifier);
166
+ if (vNum === null) {
167
+ this.logger.error('ActiveIdentifier is not a number');
168
+ callback();
169
+ return;
170
+ }
171
+ if (vNum > 14 || vNum < 1) {
172
+ this.inputID = 1;
173
+ }
174
+ else {
175
+ this.inputID = vNum;
176
+ }
177
+ callback();
178
+ })
179
+ .on('get', (callback) => {
180
+ const currentValue = this.inputID;
181
+ callback(null, currentValue);
182
+ });
183
+ this.ovenState = this.createInputSourceService('Oven Status', 'NicoCataGaTa-Oven1003', 1, this.ovenStatus(), true);
184
+ this.ovenState.getCharacteristic(this.platform.Characteristic.ConfiguredName)
185
+ .on('get', (callback) => {
186
+ const currentValue = this.ovenStatus();
187
+ callback(null, currentValue);
188
+ });
189
+ this.ovenService.addLinkedService(this.ovenState);
190
+ this.ovenMode = this.createInputSourceService('Oven Mode', 'NicoCataGaTa-Oven1004', 2, this.ovenModeName(), this.ovenOnStatus());
191
+ this.ovenMode.getCharacteristic(this.platform.Characteristic.ConfiguredName)
192
+ .on('get', (callback) => {
193
+ const currentValue = this.ovenModeName();
194
+ callback(null, currentValue);
195
+ });
196
+ this.ovenService.addLinkedService(this.ovenMode);
197
+ this.ovenTemp = this.createInputSourceService('Oven Temperature', 'NicoCataGaTa-Oven1004T', 3, this.ovenTemperature(), this.ovenOnStatus());
198
+ this.ovenTemp.getCharacteristic(this.platform.Characteristic.ConfiguredName)
199
+ .on('get', (callback) => {
200
+ const currentValue = this.ovenTemperature();
201
+ callback(null, currentValue);
202
+ });
203
+ this.ovenService.addLinkedService(this.ovenTemp);
204
+ this.probeService = this.createInputSourceService('Probe Status', 'NicoCata-Always15', 4, this.probeStatus(), this.showProbe);
205
+ this.probeService.getCharacteristic(this.platform.Characteristic.ConfiguredName)
206
+ .on('get', (callback) => {
207
+ const currentValue = this.probeStatus();
208
+ callback(null, currentValue);
209
+ });
210
+ this.ovenService.addLinkedService(this.probeService);
211
+ this.ovenOptions = this.createInputSourceService('Oven Options', 'NicoCata-Always4', 5, this.oventOptions(), this.ovenOnStatus());
212
+ this.ovenOptions.getCharacteristic(this.platform.Characteristic.ConfiguredName)
213
+ .on('get', (callback) => {
214
+ const currentValue = this.oventOptions();
215
+ callback(null, currentValue);
216
+ });
217
+ this.ovenService.addLinkedService(this.ovenOptions);
218
+ this.ovenStart = this.createInputSourceService('Oven Start Time', 'NicoCata-Always1', 6, this.courseStartString, this.showTime);
219
+ this.ovenStart.getCharacteristic(this.platform.Characteristic.ConfiguredName)
220
+ .on('get', (callback) => {
221
+ const currentValue = this.courseStartString;
222
+ callback(null, currentValue);
223
+ });
224
+ this.ovenService.addLinkedService(this.ovenStart);
225
+ this.ovenTimer = this.createInputSourceService('Oven Timer Status', 'NicoCata-Always2', 7, this.courseTimerString, this.showTimer);
226
+ this.ovenTimer.getCharacteristic(this.platform.Characteristic.ConfiguredName)
227
+ .on('get', (callback) => {
228
+ const currentValue = this.courseTimerString;
229
+ callback(null, currentValue);
230
+ });
231
+ this.ovenService.addLinkedService(this.ovenTimer);
232
+ this.ovenTime = this.createInputSourceService('Oven Cook Time Status', 'NicoCata-Always2T', 8, this.courseTimeString, this.showTime);
233
+ this.ovenTime.getCharacteristic(this.platform.Characteristic.ConfiguredName)
234
+ .on('get', (callback) => {
235
+ const currentValue = this.courseTimeString;
236
+ callback(null, currentValue);
237
+ });
238
+ this.ovenService.addLinkedService(this.ovenTime);
239
+ this.ovenEndTime = this.createInputSourceService('Oven End Time', 'NicoCata-Always3', 9, this.courseTimeEndString, this.showTime);
240
+ this.ovenEndTime.getCharacteristic(this.platform.Characteristic.ConfiguredName)
241
+ .on('get', (callback) => {
242
+ const currentValue = this.courseTimeEndString;
243
+ callback(null, currentValue);
244
+ });
245
+ this.ovenService.addLinkedService(this.ovenEndTime);
246
+ this.burner1 = this.createInputSourceService('Front Left Burner Status', 'NicoCataGaTa-Oven001', 10, this.burner1State(), this.showBurner1);
247
+ this.burner1.getCharacteristic(this.platform.Characteristic.ConfiguredName)
248
+ .on('get', (callback) => {
249
+ const currentValue = this.burner1State();
250
+ callback(null, currentValue);
251
+ });
252
+ this.ovenService.addLinkedService(this.burner1);
253
+ this.burner2 = this.createInputSourceService('Back Left Burner Status', 'NicoCataGaTa-Oven002', 11, this.burner2State(), this.showBurner2);
254
+ this.burner2.getCharacteristic(this.platform.Characteristic.ConfiguredName)
255
+ .on('get', (callback) => {
256
+ const currentValue = this.burner2State();
257
+ callback(null, currentValue);
258
+ });
259
+ this.ovenService.addLinkedService(this.burner2);
260
+ this.burner3 = this.createInputSourceService('Center Burner Status', 'NicoCataGaTa-Oven003', 12, this.burner3State(), this.showBurner3);
261
+ this.burner3.getCharacteristic(this.platform.Characteristic.ConfiguredName)
262
+ .on('get', (callback) => {
263
+ const currentValue = this.burner3State();
264
+ callback(null, currentValue);
265
+ });
266
+ this.ovenService.addLinkedService(this.burner3);
267
+ this.burner4 = this.createInputSourceService('Front Right Burner Status', 'NicoCataGaTa-Oven004', 13, this.burner4State(), this.showBurner4);
268
+ this.burner4.getCharacteristic(this.platform.Characteristic.ConfiguredName)
269
+ .on('get', (callback) => {
270
+ const currentValue = this.burner4State();
271
+ callback(null, currentValue);
272
+ });
273
+ this.ovenService.addLinkedService(this.burner4);
274
+ this.burner5 = this.createInputSourceService('Back Right Burner Status', 'NicoCataGaTa-Oven005', 14, this.burner5State(), this.showBurner5);
275
+ this.burner5.getCharacteristic(this.platform.Characteristic.ConfiguredName)
276
+ .on('get', (callback) => {
277
+ const currentValue = this.burner5State();
278
+ callback(null, currentValue);
279
+ });
280
+ this.ovenService.addLinkedService(this.burner5);
281
+ //////////Timers
282
+ this.ovenTimerService = this.accessory.getService('Oven Cook Time') ||
283
+ this.accessory.addService(this.platform.Service.Valve, 'Oven Cook Time', 'NicoCataGaTa-OvenT2');
284
+ this.ovenTimerService.setCharacteristic(Characteristic.Name, 'Oven Cook Time');
285
+ this.ovenTimerService.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
286
+ this.ovenTimerService.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Oven Cook Time');
287
+ this.ovenTimerService.setCharacteristic(Characteristic.ValveType, Characteristic.ValveType.IRRIGATION);
288
+ this.ovenTimerService.getCharacteristic(Characteristic.Active)
289
+ .on('get', (callback) => {
290
+ let currentValue = 0;
291
+ if (this.remainTime() !== 0) {
292
+ currentValue = 1;
293
+ }
294
+ callback(null, currentValue);
295
+ })
296
+ .on('set', (value, callback) => {
297
+ const enabled = normalizeBoolean(value);
298
+ if (!enabled) {
299
+ this.stopOven();
300
+ this.ovenTimerService.updateCharacteristic(Characteristic.Active, 0);
301
+ this.ovenTimerService.updateCharacteristic(Characteristic.RemainingDuration, 0);
302
+ this.ovenTimerService.updateCharacteristic(Characteristic.InUse, 0);
303
+ }
304
+ else {
305
+ this.sendOvenCommand();
306
+ }
307
+ callback(null);
308
+ });
309
+ this.ovenTimerService.setCharacteristic(Characteristic.InUse, this.remainTime() > 0 ? Characteristic.InUse.IN_USE : Characteristic.InUse.NOT_IN_USE);
310
+ this.ovenTimerService.getCharacteristic(Characteristic.RemainingDuration)
311
+ .setProps({
312
+ maxValue: TWELVE_HOURS_IN_SECONDS - 1,
313
+ })
314
+ .on('get', (callback) => {
315
+ const currentValue = this.remainTime();
316
+ callback(null, currentValue);
317
+ });
318
+ this.ovenTimerService.getCharacteristic(this.platform.Characteristic.SetDuration)
319
+ .setProps({
320
+ maxValue: TWELVE_HOURS_IN_SECONDS - 1,
321
+ })
322
+ .on('get', (callback) => {
323
+ const currentValue = this.oventTargetTime();
324
+ callback(null, currentValue);
325
+ })
326
+ .on('set', (value, callback) => {
327
+ const vNum = normalizeNumber(value);
328
+ if (vNum === null) {
329
+ this.logger.error('SetDuration is not a number');
330
+ callback();
331
+ return;
332
+ }
333
+ this.pauseUpdate = true;
334
+ this.logger.debug('Cooking Duration set to to: ' + this.secondsToTime(vNum));
335
+ this.ovenCommandList.ovenSetDuration = vNum;
336
+ callback(null);
337
+ });
338
+ this.ovenAlarmService = this.accessory.getService('Oven Timer') ||
339
+ this.accessory.addService(this.platform.Service.Valve, 'Oven Timer', 'NicoCataGaTa-OvenT32');
340
+ this.ovenAlarmService.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
341
+ this.ovenAlarmService.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Oven Timer');
342
+ this.ovenAlarmService.setCharacteristic(Characteristic.Name, 'Oven Timer');
343
+ this.ovenAlarmService.setCharacteristic(Characteristic.ValveType, Characteristic.ValveType.IRRIGATION);
344
+ this.ovenAlarmService.getCharacteristic(Characteristic.Active)
345
+ .on('get', (callback) => {
346
+ let currentValue = 0;
347
+ if (this.ovenTimerTime() !== 0) {
348
+ currentValue = 1;
349
+ }
350
+ callback(null, currentValue);
351
+ })
352
+ .on('set', (value, callback) => {
353
+ const enabled = normalizeBoolean(value);
354
+ if (!enabled) {
355
+ this.timerAlarmSec = 0;
356
+ this.sendTimerCommand(0);
357
+ this.ovenAlarmService.updateCharacteristic(Characteristic.Active, 0);
358
+ this.ovenAlarmService.updateCharacteristic(Characteristic.RemainingDuration, 0);
359
+ this.ovenAlarmService.updateCharacteristic(Characteristic.InUse, 0);
360
+ }
361
+ else {
362
+ this.sendTimerCommand(this.timerAlarmSec);
363
+ this.ovenAlarmService.updateCharacteristic(Characteristic.Active, 1);
364
+ this.ovenAlarmService.updateCharacteristic(Characteristic.RemainingDuration, this.timerAlarmSec);
365
+ this.ovenAlarmService.updateCharacteristic(Characteristic.InUse, 1);
366
+ }
367
+ callback(null);
368
+ });
369
+ this.ovenAlarmService.setCharacteristic(Characteristic.InUse, this.ovenTimerTime() > 0 ? Characteristic.InUse.IN_USE : Characteristic.InUse.NOT_IN_USE);
370
+ this.ovenAlarmService.getCharacteristic(Characteristic.RemainingDuration)
371
+ .setProps({
372
+ maxValue: TWELVE_HOURS_IN_SECONDS,
373
+ })
374
+ .on('get', (callback) => {
375
+ const currentValue = this.ovenTimerTime();
376
+ callback(null, currentValue);
377
+ });
378
+ this.ovenAlarmService.getCharacteristic(this.platform.Characteristic.SetDuration)
379
+ .setProps({
380
+ maxValue: TWELVE_HOURS_IN_SECONDS,
381
+ })
382
+ .on('get', (callback) => {
383
+ const currentValue = this.timerAlarmSec;
384
+ callback(null, currentValue);
385
+ })
386
+ .on('set', (value, callback) => {
387
+ let vNum = normalizeNumber(value);
388
+ if (vNum === null) {
389
+ this.logger.error('SetDuration is not a number');
390
+ callback();
391
+ return;
392
+ }
393
+ if (vNum >= TWELVE_HOURS_IN_SECONDS) {
394
+ vNum = TWELVE_HOURS_IN_SECONDS - 1;
395
+ }
396
+ this.timerAlarmSec = vNum;
397
+ callback(null);
398
+ });
399
+ ////////////Buttons
400
+ this.bakeSwitch = accessory.getService('Bake Mode') ||
401
+ accessory.addService(this.platform.Service.Switch, 'Bake Mode', 'CataNicoGaTa-80');
402
+ this.bakeSwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
403
+ this.bakeSwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Bake Mode');
404
+ this.bakeSwitch.getCharacteristic(this.platform.Characteristic.On)
405
+ .on('get', (callback) => {
406
+ this.logger.debug('Bake Switch Get state');
407
+ const currentValue = false;
408
+ callback(null, currentValue);
409
+ })
410
+ .on('set', (value, callback) => {
411
+ if (value) {
412
+ this.ovenCommandList.ovenMode = 'BAKE';
413
+ }
414
+ this.updateOvenModeSwitch();
415
+ callback(null);
416
+ });
417
+ this.convectionBakeSwitch = accessory.getService('Convection Bake Mode') ||
418
+ accessory.addService(this.platform.Service.Switch, 'Convection Bake Mode', 'CataNicoGaTa-Control1');
419
+ this.convectionBakeSwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
420
+ this.convectionBakeSwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Convection Bake Mode');
421
+ this.convectionBakeSwitch.getCharacteristic(this.platform.Characteristic.On)
422
+ .on('get', (callback) => {
423
+ const currentValue = false;
424
+ callback(null, currentValue);
425
+ })
426
+ .on('set', (value, callback) => {
427
+ const enabled = normalizeBoolean(value);
428
+ if (enabled) {
429
+ this.ovenCommandList.ovenMode = 'CONVECTION_BAKE';
430
+ }
431
+ this.updateOvenModeSwitch();
432
+ callback(null);
433
+ });
434
+ this.convectionRoastSwitch = accessory.getService('Convection Roast Mode') ||
435
+ accessory.addService(this.platform.Service.Switch, 'Convection Roast Mode', 'CataNicoGaTa-Control2');
436
+ this.convectionRoastSwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
437
+ this.convectionRoastSwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Convection Roast Mode');
438
+ this.convectionRoastSwitch.getCharacteristic(this.platform.Characteristic.On)
439
+ .on('get', (callback) => {
440
+ const currentValue = false;
441
+ callback(null, currentValue);
442
+ })
443
+ .on('set', (value, callback) => {
444
+ const enabled = normalizeBoolean(value);
445
+ if (enabled) {
446
+ this.ovenCommandList.ovenMode = 'CONVECTION_ROST';
447
+ }
448
+ this.updateOvenModeSwitch();
449
+ callback(null);
450
+ });
451
+ this.frozenMealSwitch = accessory.getService('Frozen Meal Mode') ||
452
+ accessory.addService(this.platform.Service.Switch, 'Frozen Meal Mode', 'CataNicoGaTa-Control3');
453
+ this.frozenMealSwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
454
+ this.frozenMealSwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Frozen Meal Mode');
455
+ this.frozenMealSwitch.getCharacteristic(this.platform.Characteristic.On)
456
+ .on('get', (callback) => {
457
+ const currentValue = false;
458
+ callback(null, currentValue);
459
+ })
460
+ .on('set', (value, callback) => {
461
+ const enabled = normalizeBoolean(value);
462
+ if (enabled) {
463
+ this.ovenCommandList.ovenMode = 'FROZEN_MEAL';
464
+ }
465
+ this.updateOvenModeSwitch();
466
+ callback(null);
467
+ });
468
+ this.airFrySwitch = accessory.getService('Air Fry Mode') ||
469
+ accessory.addService(this.platform.Service.Switch, 'Air Fry Mode', 'CataNicoGaTa-Control4');
470
+ this.airFrySwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
471
+ this.airFrySwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Air Fry Mode');
472
+ this.airFrySwitch.getCharacteristic(this.platform.Characteristic.On)
473
+ .on('get', (callback) => {
474
+ const currentValue = false;
475
+ callback(null, currentValue);
476
+ })
477
+ .on('set', (value, callback) => {
478
+ const enabled = normalizeBoolean(value);
479
+ if (enabled) {
480
+ this.ovenCommandList.ovenMode = 'AIR_FRY';
481
+ }
482
+ this.updateOvenModeSwitch();
483
+ callback(null);
484
+ });
485
+ this.airSousvideSwitch = accessory.getService('Air Sousvide Mode') ||
486
+ accessory.addService(this.platform.Service.Switch, 'Air Sousvide Mode', 'CataNicoGaTa-Control5');
487
+ this.airSousvideSwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
488
+ this.airSousvideSwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Air Sousvide Mode');
489
+ this.airSousvideSwitch.getCharacteristic(this.platform.Characteristic.On)
490
+ .on('get', (callback) => {
491
+ const currentValue = false;
492
+ callback(null, currentValue);
493
+ })
494
+ .on('set', (value, callback) => {
495
+ const enabled = normalizeBoolean(value);
496
+ if (enabled) {
497
+ this.ovenCommandList.ovenMode = 'AIR_SOUSVIDE';
498
+ }
499
+ this.updateOvenModeSwitch();
500
+ callback(null);
501
+ });
502
+ this.warmModeSwitch = accessory.getService('Proof-Warm Mode') ||
503
+ accessory.addService(this.platform.Service.Switch, 'Proof-Warm Mode', 'CataNicoGaTa-Control5W');
504
+ this.warmModeSwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
505
+ this.warmModeSwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Proof-Warm Mode');
506
+ this.warmModeSwitch.getCharacteristic(this.platform.Characteristic.On)
507
+ .on('get', (callback) => {
508
+ const currentValue = false;
509
+ callback(null, currentValue);
510
+ })
511
+ .on('set', (value, callback) => {
512
+ const enabled = normalizeBoolean(value);
513
+ if (enabled) {
514
+ this.ovenCommandList.ovenMode = 'WARM';
515
+ }
516
+ this.updateOvenModeSwitch();
517
+ callback(null);
518
+ });
519
+ this.cancelSwitch = accessory.getService('Stop Oven') ||
520
+ accessory.addService(this.platform.Service.Switch, 'Stop Oven', 'CataNicoGaTa-Control6');
521
+ this.cancelSwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
522
+ this.cancelSwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Stop Oven');
523
+ this.cancelSwitch.getCharacteristic(this.platform.Characteristic.On)
524
+ .on('get', (callback) => {
525
+ const currentValue = false;
526
+ callback(null, currentValue);
527
+ })
528
+ .on('set', (value, callback) => {
529
+ const enabled = normalizeBoolean(value);
530
+ if (enabled) {
531
+ this.stopOven();
532
+ }
533
+ setTimeout(() => {
534
+ this.cancelSwitch.updateCharacteristic(this.platform.Characteristic.On, false);
535
+ }, ONE_SECOND_MS);
536
+ this.updateOvenModeSwitch();
537
+ callback(null);
538
+ });
539
+ this.monitorOnlySwitch = accessory.getService('Monitor Only Mode') ||
540
+ accessory.addService(this.platform.Service.Switch, 'Monitor Only Mode', 'CataNicoGaTa-Control7');
541
+ this.monitorOnlySwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
542
+ this.monitorOnlySwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Monitor Only Mode');
543
+ this.monitorOnlySwitch.getCharacteristic(this.platform.Characteristic.On)
544
+ .on('get', (callback) => {
545
+ if (this.Status.data?.upperRemoteStart.includes('DIS')) {
546
+ this.monitorOnly = true;
547
+ }
548
+ const currentValue = this.monitorOnly;
549
+ callback(null, currentValue);
550
+ })
551
+ .on('set', (value, callback) => {
552
+ const b = normalizeBoolean(value);
553
+ this.homekitMonitorOnly = b;
554
+ this.monitorOnly = b;
555
+ callback(null);
556
+ });
557
+ this.startOvenSwitch = accessory.getService('Start Oven') ||
558
+ accessory.addService(this.platform.Service.Switch, 'Start Oven', 'CataNicoGaTa-Control8');
559
+ this.startOvenSwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
560
+ this.startOvenSwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Start Oven');
561
+ this.startOvenSwitch.getCharacteristic(this.platform.Characteristic.On)
562
+ .on('get', (callback) => {
563
+ const currentValue = false;
564
+ callback(null, currentValue);
565
+ })
566
+ .on('set', (value, callback) => {
567
+ const enabled = normalizeBoolean(value);
568
+ if (enabled) {
569
+ this.sendOvenCommand();
570
+ setTimeout(() => {
571
+ this.startOvenSwitch.updateCharacteristic(this.platform.Characteristic.On, false);
572
+ }, ONE_SECOND_MS);
573
+ }
574
+ callback(null);
575
+ });
576
+ if ('upperCookAndWarmStatus' in this.Status.data) {
577
+ this.keepWarmSwitch = accessory.getService('Keep Warm') ||
578
+ accessory.addService(this.platform.Service.Switch, 'Keep Warm', 'CataNicoGaTa-Control9');
579
+ this.keepWarmSwitch.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
580
+ this.keepWarmSwitch.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Keep Warm');
581
+ this.keepWarmSwitch.getCharacteristic(this.platform.Characteristic.On)
582
+ .on('get', (callback) => {
583
+ const currentValue = !this.Status.data?.upperCookAndWarmStatus?.includes('DIS');
584
+ callback(null, currentValue);
585
+ })
586
+ .on('set', (value, callback) => {
587
+ const enabled = normalizeBoolean(value);
588
+ if (enabled) {
589
+ this.ovenCommandList.ovenKeepWarm = 'ENABLE';
590
+ }
591
+ else {
592
+ this.ovenCommandList.ovenKeepWarm = 'DISABLE';
593
+ }
594
+ callback(null);
595
+ });
596
+ }
597
+ ////////Door sensor
598
+ this.ovenDoorOpened = this.accessory.getService('Oven Door') ||
599
+ this.accessory.addService(this.platform.Service.ContactSensor, 'Oven Door', 'NicoCataGaTa-OvenTCBCS');
600
+ this.ovenDoorOpened.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
601
+ this.ovenDoorOpened.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Oven Door');
602
+ this.ovenDoorOpened.setCharacteristic(this.platform.Characteristic.StatusActive, this.onStatus());
603
+ this.ovenDoorOpened.setCharacteristic(this.platform.Characteristic.ContactSensorState, this.Status.data?.upperDoorOpen.includes('DIS') ? 0 : 1);
604
+ ///Range Cooking
605
+ this.rangeOn = this.accessory.getService('Range is Cooking') ||
606
+ this.accessory.addService(this.platform.Service.MotionSensor, 'Range is Cooking', 'NicoCataGaTa-OvenTCBCSMotion');
607
+ this.rangeOn.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
608
+ this.rangeOn.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Range is Cooking');
609
+ this.rangeOn.setCharacteristic(this.platform.Characteristic.StatusActive, this.onStatus());
610
+ this.rangeOn.setCharacteristic(this.platform.Characteristic.MotionDetected, this.onStatus());
611
+ ////Remote Enabled
612
+ this.remoteEnabled = this.accessory.getService('Remote Control Enabled') ||
613
+ this.accessory.addService(this.platform.Service.ContactSensor, 'Remote Control Enabled', 'NicoCataGaTa-OvenTCRCS');
614
+ this.remoteEnabled.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
615
+ this.remoteEnabled.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Remote Control Enabled');
616
+ this.remoteEnabled.setCharacteristic(this.platform.Characteristic.StatusActive, this.onStatus());
617
+ this.remoteEnabled.setCharacteristic(this.platform.Characteristic.ContactSensorState, this.Status.data?.upperRemoteStart.includes('DIS') ? 0 : 1);
618
+ /////////Burners On
619
+ this.burnersOnNumber = this.accessory.getService('Number of Burners in Use') ||
620
+ this.accessory.addService(this.platform.Service.LightSensor, 'Number of Burners in Use', 'NicoCataGaTa-OvenTCB');
621
+ this.burnersOnNumber.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
622
+ this.burnersOnNumber.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Number of Burners in Use');
623
+ this.burnersOnNumber.setCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.Status.data?.burnerOnCounter < 1 ? 0.0001 : this.Status.data?.burnerOnCounter);
624
+ this.burnersOnNumber.setCharacteristic(this.platform.Characteristic.StatusActive, this.Status.data?.burnerOnCounter > 0 ? true : false);
625
+ ///////Oven Temperature Control
626
+ this.ovenTempControl = this.accessory.getService('Oven Temperature Control') ||
627
+ this.accessory.addService(this.platform.Service.Thermostat, 'Oven Temperature Control', 'NicoCataGaTa-OvenTC')
628
+ .setCharacteristic(this.platform.Characteristic.Name, 'Oven Temperature Control')
629
+ .setCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState, this.currentHeatingState())
630
+ .setCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits, 1);
631
+ this.ovenTempControl.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
632
+ this.ovenTempControl.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Oven Temperature Control');
633
+ this.ovenTempControl.getCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState)
634
+ .setProps({ validValues: [this.platform.Characteristic.TargetHeatingCoolingState.OFF, this.platform.Characteristic.TargetHeatingCoolingState.HEAT] })
635
+ .on('get', (callback) => {
636
+ const currentValue = this.targetHeatingState();
637
+ callback(null, currentValue);
638
+ })
639
+ .on('set', (value, callback) => {
640
+ const enabled = normalizeBoolean(value);
641
+ if (!enabled) {
642
+ this.stopOven();
643
+ }
644
+ else {
645
+ this.pauseUpdate = true;
646
+ }
647
+ callback(null);
648
+ });
649
+ this.ovenTempControl.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
650
+ .setProps({
651
+ minValue: 0,
652
+ maxValue: 218,
653
+ minStep: 0.5,
654
+ })
655
+ .on('get', (callback) => {
656
+ const currentValue = this.ovenCurrentTemperature();
657
+ callback(null, currentValue);
658
+ });
659
+ this.ovenTempControl.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
660
+ .on('get', (callback) => {
661
+ const currentValue = this.localHumidity;
662
+ callback(null, currentValue);
663
+ });
664
+ this.ovenTempControl.getCharacteristic(this.platform.Characteristic.TargetTemperature)
665
+ .setProps({
666
+ minValue: 38,
667
+ maxValue: 218,
668
+ minStep: 0.5,
669
+ })
670
+ .on('get', (callback) => {
671
+ const currentValue = this.ovenTargetTemperature();
672
+ // this.platform.log('Get Target Temp' + this.ovenTargetTemperature())
673
+ callback(null, currentValue);
674
+ })
675
+ .on('set', (value, callback) => {
676
+ const vNum = normalizeNumber(value);
677
+ if (vNum === null) {
678
+ this.logger.error('TargetTemperature is not a number');
679
+ callback();
680
+ return;
681
+ }
682
+ if (this.Status.data?.upperCurrentTemperatureUnit.includes('FAH')) {
683
+ this.ovenCommandList.ovenSetTemperature = this.tempCtoF(vNum);
684
+ }
685
+ else {
686
+ this.ovenCommandList.ovenSetTemperature = Math.round(vNum);
687
+ }
688
+ callback(null);
689
+ });
690
+ this.probeTempControl = this.accessory.getService('Probe Temperature Control') ||
691
+ this.accessory.addService(this.platform.Service.Thermostat, 'Probe Temperature Control', 'NicoCataGaTa-OvenTCP2')
692
+ .setCharacteristic(this.platform.Characteristic.Name, 'Probe Temperature Control')
693
+ .setCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState, this.probeCurrentState())
694
+ .setCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits, 1);
695
+ this.probeTempControl.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
696
+ this.probeTempControl.setCharacteristic(this.platform.Characteristic.ConfiguredName, 'Probe Temperature Control');
697
+ this.probeTempControl.getCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState)
698
+ .setProps({ validValues: [this.platform.Characteristic.TargetHeatingCoolingState.OFF, this.platform.Characteristic.TargetHeatingCoolingState.HEAT] })
699
+ .on('get', (callback) => {
700
+ const currentValue = this.probeTargetState();
701
+ callback(null, currentValue);
702
+ })
703
+ .on('set', (value, callback) => {
704
+ this.pauseUpdate = true;
705
+ callback(null);
706
+ });
707
+ this.probeTempControl.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
708
+ .setProps({
709
+ minValue: 0,
710
+ maxValue: 285,
711
+ minStep: 0.1,
712
+ })
713
+ .on('get', (callback) => {
714
+ const currentValue = this.probeCurrentTemperature();
715
+ callback(null, currentValue);
716
+ });
717
+ this.probeTempControl.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
718
+ .on('get', (callback) => {
719
+ const currentValue = this.localHumidity;
720
+ callback(null, currentValue);
721
+ });
722
+ this.probeTempControl.getCharacteristic(this.platform.Characteristic.TargetTemperature)
723
+ .setProps({
724
+ minValue: 38,
725
+ maxValue: 285,
726
+ minStep: 0.1,
727
+ })
728
+ .on('get', (callback) => {
729
+ const currentValue = this.probeTargetTemperature();
730
+ callback(null, currentValue);
731
+ })
732
+ .on('set', (value, callback) => {
733
+ const v = normalizeNumber(value);
734
+ if (v === null) {
735
+ this.logger.error('TargetTemperature is not a valid number');
736
+ callback(null);
737
+ return;
738
+ }
739
+ if (this.Status.data?.upperCurrentTemperatureUnit.includes('FAH')) {
740
+ this.ovenCommandList.probeTemperature = this.tempCtoF(v);
741
+ }
742
+ else {
743
+ this.ovenCommandList.probeTemperature = Math.round(v);
744
+ }
745
+ callback(null);
746
+ });
747
+ }
748
+ get Status() {
749
+ return new OvenStatus(this.accessory.context.device.snapshot?.ovenState, this.accessory.context.device.deviceModel);
750
+ }
751
+ get config() {
752
+ return Object.assign({}, {
753
+ oven_trigger: false,
754
+ }, super.config);
755
+ }
756
+ secondsToTime(seconds) {
757
+ const h = Math.floor(seconds / ONE_HOUR_IN_SECONDS);
758
+ const m = Math.floor(seconds % ONE_HOUR_IN_SECONDS / 60);
759
+ const s = Math.floor(seconds % 60);
760
+ return h + ':' + m + ':' + s + ' Hours';
761
+ }
762
+ async sendTimerCommand(time) {
763
+ if (!this.waitingForCommand) {
764
+ this.logger.debug('Alarm Set to: ' + this.secondsToTime(time));
765
+ const ctrlKey = 'SetTimer';
766
+ const device = this.accessory.context.device;
767
+ try {
768
+ await this.platform.ThinQ?.deviceControl(device.id, {
769
+ dataKey: null,
770
+ dataValue: null,
771
+ dataSetList: {
772
+ ovenState: {
773
+ 'cmdOptionContentsType': 'TIMER',
774
+ 'cmdOptionDataLength': 'TIMER',
775
+ 'lowerTimerHour': 128,
776
+ 'lowerTimerMinute': 128,
777
+ 'lowerTimerSecond': 128,
778
+ 'upperTimerHour': Math.floor(time / ONE_HOUR_IN_SECONDS),
779
+ 'upperTimerMinute': Math.floor(time % ONE_HOUR_IN_SECONDS / 60),
780
+ 'upperTimerSecond': Math.floor(time % 60),
781
+ },
782
+ },
783
+ dataGetList: null,
784
+ }, 'Set', ctrlKey);
785
+ }
786
+ catch (error) {
787
+ this.logger.error('Error sending timer command:', error);
788
+ }
789
+ this.waitingForCommand = true;
790
+ setTimeout(() => {
791
+ this.pauseUpdate = false;
792
+ this.firstPause = true;
793
+ }, TEN_SECONDS_MS);
794
+ }
795
+ setTimeout(() => {
796
+ this.waitingForCommand = false;
797
+ }, ONE_SECOND_MS);
798
+ }
799
+ async sendOvenCommand() {
800
+ if (!this.monitorOnly) {
801
+ if (!this.waitingForCommand) {
802
+ this.pauseUpdate = true;
803
+ this.ovenCommandList.tempUnits = this.Status.data?.upperCurrentTemperatureUnit;
804
+ if (this.ovenCommandList.ovenSetDuration === 0) {
805
+ this.ovenCommandList.ovenSetDuration = THIRTY_MINUTES_IN_SECONDS;
806
+ }
807
+ if (this.ovenCommandList.ovenMode === 'NONE') {
808
+ this.ovenCommandList.ovenMode = 'BAKE';
809
+ }
810
+ if (this.ovenCommandList.ovenMode.includes('CONVECTION_BAKE') ||
811
+ this.ovenCommandList.ovenMode.includes('CONVECTION_ROST') ||
812
+ this.ovenCommandList.ovenMode.includes('FROZEN_MEAL') ||
813
+ this.ovenCommandList.ovenMode.includes('AIR_FRY')) {
814
+ if (this.ovenCommandList.tempUnits.includes('FAH')) {
815
+ if (this.ovenCommandList.ovenSetTemperature < 300) {
816
+ this.ovenCommandList.ovenSetTemperature = 300;
817
+ }
818
+ if (this.ovenCommandList.ovenSetTemperature > 550) {
819
+ this.ovenCommandList.ovenSetTemperature = 550;
820
+ }
821
+ }
822
+ else {
823
+ if (this.ovenCommandList.ovenSetTemperature < 150) {
824
+ this.ovenCommandList.ovenSetTemperature = 150;
825
+ }
826
+ if (this.ovenCommandList.ovenSetTemperature > 285) {
827
+ this.ovenCommandList.ovenSetTemperature = 285;
828
+ }
829
+ }
830
+ }
831
+ else if (this.ovenCommandList.ovenMode.includes('BAKE')) {
832
+ if (this.ovenCommandList.tempUnits.includes('FAH')) {
833
+ if (this.ovenCommandList.ovenSetTemperature < 170) {
834
+ this.ovenCommandList.ovenSetTemperature = 170;
835
+ }
836
+ if (this.ovenCommandList.ovenSetTemperature > 550) {
837
+ this.ovenCommandList.ovenSetTemperature = 550;
838
+ }
839
+ }
840
+ else {
841
+ if (this.ovenCommandList.ovenSetTemperature < 80) {
842
+ this.ovenCommandList.ovenSetTemperature = 80;
843
+ }
844
+ if (this.ovenCommandList.ovenSetTemperature > 285) {
845
+ this.ovenCommandList.ovenSetTemperature = 285;
846
+ }
847
+ }
848
+ }
849
+ else if (this.ovenCommandList.ovenMode.includes('AIR_SOUSVIDE')) {
850
+ if (this.ovenCommandList.tempUnits.includes('FAH')) {
851
+ if (this.ovenCommandList.ovenSetTemperature < 100) {
852
+ this.ovenCommandList.ovenSetTemperature = 100;
853
+ }
854
+ if (this.ovenCommandList.ovenSetTemperature > 205) {
855
+ this.ovenCommandList.ovenSetTemperature = 205;
856
+ }
857
+ }
858
+ else {
859
+ if (this.ovenCommandList.ovenSetTemperature < 380) {
860
+ this.ovenCommandList.ovenSetTemperature = 38;
861
+ }
862
+ if (this.ovenCommandList.ovenSetTemperature > 96) {
863
+ this.ovenCommandList.ovenSetTemperature = 96;
864
+ }
865
+ }
866
+ }
867
+ else if (this.ovenCommandList.ovenMode.includes('WARM')) {
868
+ if (this.ovenCommandList.tempUnits.includes('FAH')) {
869
+ this.ovenCommandList = {
870
+ ovenMode: 'WARM',
871
+ ovenSetTemperature: 0,
872
+ tempUnits: 'FAHRENHEIT',
873
+ ovenSetDuration: 0,
874
+ probeTemperature: 0,
875
+ ovenKeepWarm: 'DISABLE',
876
+ };
877
+ }
878
+ else {
879
+ this.ovenCommandList = {
880
+ ovenMode: 'WARM',
881
+ ovenSetTemperature: 0,
882
+ tempUnits: 'CELSIUS',
883
+ ovenSetDuration: 0,
884
+ probeTemperature: 0,
885
+ ovenKeepWarm: 'DISABLE',
886
+ };
887
+ }
888
+ }
889
+ this.logger.debug('Sending the Folowing Commands: ' + JSON.stringify(this.ovenCommandList));
890
+ const ctrlKey = 'SetCookStart';
891
+ const device = this.accessory.context.device;
892
+ try {
893
+ await this.platform.ThinQ?.deviceControl(device.id, {
894
+ dataKey: null,
895
+ dataValue: null,
896
+ dataSetList: {
897
+ ovenState: {
898
+ 'cmdOptionContentsType': 'REMOTE_COOK_START',
899
+ 'cmdOptionDataLength': 'REMOTE_COOK_START',
900
+ 'cmdOptionSetCookAndWarm': this.ovenCommandList.ovenKeepWarm,
901
+ 'cmdOptionSetCookName': this.ovenCommandList.ovenMode,
902
+ 'cmdOptionSetMyRecipeCookNumber': 0,
903
+ 'cmdOptionSetSteamLevel': '',
904
+ 'cmdOptionSetSubCookNumber': 0,
905
+ 'cmdOptionSetTargetTemperatureUnit': this.ovenCommandList.tempUnits,
906
+ 'cmdOptionSetTargetTimeHour': Math.floor(this.ovenCommandList.ovenSetDuration / ONE_HOUR_IN_SECONDS),
907
+ 'cmdOptionSetTargetTimeMinute': Math.floor(this.ovenCommandList.ovenSetDuration % ONE_HOUR_IN_SECONDS / 60),
908
+ 'cmdOptionSetRapidPreheat': 'OFF',
909
+ 'setTargetProveTemperature': this.ovenCommandList.probeTemperature,
910
+ 'setTargetTemperature': this.ovenCommandList.ovenSetTemperature,
911
+ },
912
+ },
913
+ dataGetList: null,
914
+ }, 'Set', ctrlKey);
915
+ }
916
+ catch (error) {
917
+ this.logger.error('Error sending oven command:', error);
918
+ }
919
+ this.waitingForCommand = true;
920
+ setTimeout(() => {
921
+ this.pauseUpdate = false;
922
+ this.firstPause = true;
923
+ }, TEN_SECONDS_MS);
924
+ }
925
+ setTimeout(() => {
926
+ this.waitingForCommand = false;
927
+ }, ONE_SECOND_MS);
928
+ }
929
+ }
930
+ async stopOven() {
931
+ if (!this.monitorOnly) {
932
+ if (!this.waitingForCommand) {
933
+ this.pauseUpdate = true;
934
+ this.logger.debug('Stop Command Sent to Oven');
935
+ const ctrlKey = 'SetCookStop';
936
+ const device = this.accessory.context.device;
937
+ try {
938
+ await this.platform.ThinQ?.deviceControl(device.id, {
939
+ dataKey: null,
940
+ dataValue: null,
941
+ dataSetList: {
942
+ ovenState: {
943
+ 'cmdOptionCookStop': 'UPPER',
944
+ },
945
+ },
946
+ dataGetList: null,
947
+ }, 'Set', ctrlKey);
948
+ }
949
+ catch (error) {
950
+ this.logger.error('Error stopping oven:', error);
951
+ }
952
+ setTimeout(() => {
953
+ this.pauseUpdate = false;
954
+ this.firstPause = true;
955
+ }, TEN_SECONDS_MS);
956
+ this.waitingForCommand = true;
957
+ setTimeout(() => {
958
+ this.waitingForCommand = false;
959
+ }, ONE_SECOND_MS);
960
+ }
961
+ }
962
+ }
963
+ getMonitorState() {
964
+ if (this.Status.data?.upperRemoteStart.includes('DIS')) {
965
+ this.monitorOnly = true;
966
+ }
967
+ else {
968
+ this.monitorOnly = this.homekitMonitorOnly;
969
+ }
970
+ return this.monitorOnly;
971
+ }
972
+ setActive() {
973
+ this.logger.info('Oven Response 1', this.Status.data);
974
+ // this.platform.log('Oven Response 2', this.Status.deviceModel.DeviceModel.data.ControlWifi);
975
+ // this.platform.log('Oven Response 3', this.Status.deviceModel.DeviceModel.data.UpperManualCook);
976
+ //this.platform.log('Oven Response 4', this.Status.deviceModel.DeviceModel.data.Monitoring);
977
+ // this.platform.log('Dishwasher rinse', this.Status.data.rinseLevel);
978
+ // this.platform.log('Dishwasher rinse typeof', typeof this.Status.data.rinseLevel);
979
+ //this.updateRinseLevel();
980
+ // this.platform.log('Dishwasher rinse status', this.rinseStatus);
981
+ // this.serviceDishwasher.updateCharacteristic(this.platform.Characteristic.StatusFault, this.rinseStatus);
982
+ // this.platform.log('Dishwasher Response', this.Status);
983
+ // throw new this.platform.api.hap.HapStatusError(-70412 /* this.platform.api.hap.HAPStatus.NOT_ALLOWED_IN_CURRENT_STATE */);
984
+ }
985
+ ovenOnStatus() {
986
+ return !this.Status.data?.upperState.includes('INITIAL');
987
+ }
988
+ onStatus() {
989
+ return !this.Status.data?.upperState.includes('INITIAL') || this.Status.data?.burnerOnCounter > 0;
990
+ }
991
+ nameLengthCheck(newName) {
992
+ if (newName.length >= 64) {
993
+ newName = newName.slice(0, 60) + '...';
994
+ }
995
+ return newName;
996
+ }
997
+ remainTime() {
998
+ let remainingDuration = 0;
999
+ if (typeof this.Status.data?.upperRemainTimeHour !== 'undefined') {
1000
+ remainingDuration += this.Status.data?.upperRemainTimeHour * ONE_HOUR_IN_SECONDS;
1001
+ }
1002
+ if (typeof this.Status.data?.upperRemainTimeMinute !== 'undefined') {
1003
+ remainingDuration += this.Status.data?.upperRemainTimeMinute * 60;
1004
+ }
1005
+ if (typeof this.Status.data?.upperRemainTimeSecond !== 'undefined') {
1006
+ remainingDuration += this.Status.data?.upperRemainTimeSecond;
1007
+ }
1008
+ return remainingDuration;
1009
+ }
1010
+ ovenModeName() {
1011
+ this.inputNameMode = 'Oven Mode: ';
1012
+ switch (this.Status.data?.upperManualCookName) {
1013
+ case 'NONE':
1014
+ this.inputNameMode += 'None';
1015
+ break;
1016
+ case 'BAKE':
1017
+ this.inputNameMode += 'Bake';
1018
+ break;
1019
+ case 'ROAST':
1020
+ this.inputNameMode += 'Roast';
1021
+ break;
1022
+ case 'CONVECTION_BAKE':
1023
+ this.inputNameMode += 'Convection Bake';
1024
+ break;
1025
+ case 'CONVECTION_ROAST':
1026
+ this.inputNameMode += 'Convection Roast';
1027
+ break;
1028
+ case 'CRISP_CONVECTION':
1029
+ this.inputNameMode += 'Crisp Convection';
1030
+ break;
1031
+ case 'FAVORITE':
1032
+ this.inputNameMode += 'Favorite';
1033
+ break;
1034
+ case 'BROIL':
1035
+ this.inputNameMode += 'Broil';
1036
+ break;
1037
+ case 'WARM':
1038
+ this.inputNameMode += 'Warm';
1039
+ break;
1040
+ case 'PROOF':
1041
+ this.inputNameMode += 'Proof';
1042
+ break;
1043
+ case 'FROZEN_MEAL':
1044
+ this.inputNameMode += 'Frozen Meal';
1045
+ break;
1046
+ case 'SLOW_COOK':
1047
+ this.inputNameMode += 'Slow Cook';
1048
+ break;
1049
+ case 'PROBE_SET':
1050
+ this.inputNameMode += 'Probe Set';
1051
+ break;
1052
+ case 'EASY_CLEAN':
1053
+ this.inputNameMode += 'Easy Clean';
1054
+ break;
1055
+ case 'SPEED_BROIL':
1056
+ this.inputNameMode += 'Speed Broil';
1057
+ break;
1058
+ case 'SELF_CLEAN':
1059
+ this.inputNameMode += 'Self Clean';
1060
+ break;
1061
+ case 'SPEED_ROAST':
1062
+ this.inputNameMode += 'Speed Roast';
1063
+ break;
1064
+ case 'AIR_FRY':
1065
+ this.inputNameMode += 'Air Fry';
1066
+ break;
1067
+ case 'PIZZA':
1068
+ this.inputNameMode += 'Pizza';
1069
+ break;
1070
+ case 'AIR_SOUSVIDE':
1071
+ this.inputNameMode += 'Air Sousvide';
1072
+ break;
1073
+ default:
1074
+ // eslint-disable-next-line no-case-declarations
1075
+ let cookName = this.Status.data?.upperManualCookName;
1076
+ cookName = cookName.toLocaleLowerCase();
1077
+ // eslint-disable-next-line no-case-declarations
1078
+ const cookNameCap = cookName.charAt(0).toUpperCase()
1079
+ + cookName.slice(1);
1080
+ this.inputNameMode += cookNameCap;
1081
+ }
1082
+ if (!this.inputNameMode.includes('None')) {
1083
+ this.inputNameMode = this.OvenSubCookMenu(this.inputNameMode);
1084
+ }
1085
+ if ('upperCookAndWarmStatus' in this.Status.data) {
1086
+ if (!this.Status.data?.upperCookAndWarmStatus.includes('DIS')) {
1087
+ this.inputNameMode += ' (Keep Warm On)';
1088
+ }
1089
+ }
1090
+ return this.nameLengthCheck(this.inputNameMode);
1091
+ }
1092
+ ovenStatus() {
1093
+ this.inputNameStatus = 'Oven is ';
1094
+ switch (this.Status.data?.upperState) {
1095
+ case 'INITIAL':
1096
+ this.inputNameStatus += 'in Standby';
1097
+ if (this.Status.data?.upperRemoteStart.includes('DIS')) {
1098
+ this.inputNameStatus += ' (Remote Start Disabled)';
1099
+ }
1100
+ else if (this.homekitMonitorOnly) {
1101
+ this.inputNameStatus += ' (Homekit Monitor Only Mode)';
1102
+ }
1103
+ break;
1104
+ case 'PREHEATING':
1105
+ this.inputNameStatus += 'Preheating';
1106
+ break;
1107
+ case 'COOKING_IN_PROGRESS':
1108
+ this.inputNameStatus += 'Baking';
1109
+ break;
1110
+ case 'DONE':
1111
+ this.inputNameStatus += 'Done Baking';
1112
+ break;
1113
+ case 'COOLING':
1114
+ this.inputNameStatus += 'Cooling Down';
1115
+ break;
1116
+ case 'CLEANING':
1117
+ this.inputNameStatus += 'Cleaning Itself';
1118
+ break;
1119
+ case 'CLEANING_DONE':
1120
+ this.inputNameStatus += 'Done Cleaning Itself';
1121
+ break;
1122
+ default:
1123
+ // eslint-disable-next-line no-case-declarations
1124
+ let stateName = this.Status.data?.upperState;
1125
+ stateName = stateName.toLocaleLowerCase();
1126
+ // eslint-disable-next-line no-case-declarations
1127
+ const stateNameCap = stateName.charAt(0).toUpperCase()
1128
+ + stateName.slice(1);
1129
+ this.inputNameStatus += stateNameCap;
1130
+ }
1131
+ if ('commonControlLock' in this.Status.data) {
1132
+ if (!this.Status.data?.commonControlLock.includes('DIS')) {
1133
+ this.inputNameStatus += ' - Controls Locked';
1134
+ }
1135
+ }
1136
+ return this.nameLengthCheck(this.inputNameStatus);
1137
+ }
1138
+ ovenTemperature() {
1139
+ /////Current Temp
1140
+ let temperature = 'Oven Temperature Information';
1141
+ if (this.Status.data?.upperCurrentTemperatureValue !== 0) {
1142
+ temperature = 'Current Temp is ' + this.Status.data?.upperCurrentTemperatureValue + '°';
1143
+ }
1144
+ ////Set temperature
1145
+ if (this.Status.data?.upperTargetTemperatureValue !== 0) {
1146
+ temperature += ' With Set Temp ' + this.Status.data?.upperTargetTemperatureValue + '°';
1147
+ }
1148
+ return this.nameLengthCheck(temperature);
1149
+ }
1150
+ ovenCurrentTemperature() {
1151
+ /////Current Temp
1152
+ if (this.Status.data?.upperCurrentTemperatureValue !== 0) {
1153
+ if (this.Status.data?.upperCurrentTemperatureUnit.includes('FAH')) {
1154
+ return this.tempFtoC(this.Status.data?.upperCurrentTemperatureValue);
1155
+ }
1156
+ else {
1157
+ return 0.5 * Math.round(2 * this.Status.data?.upperCurrentTemperatureValue);
1158
+ }
1159
+ }
1160
+ else if (this.Status.data?.upperCurrentTemperatureValue === 0 && this.Status.data?.upperTargetTemperatureValue !== 0) {
1161
+ if (this.Status.data?.upperCurrentTemperatureUnit.includes('FAH')) {
1162
+ return this.tempFtoC(this.Status.data?.upperTargetTemperatureValue);
1163
+ }
1164
+ else {
1165
+ return 0.5 * Math.round(2 * this.Status.data?.upperTargetTemperatureValue);
1166
+ }
1167
+ }
1168
+ else {
1169
+ return this.localTemperature;
1170
+ }
1171
+ }
1172
+ ovenTargetTemperature() {
1173
+ ////Set temperature
1174
+ if (this.Status.data?.upperTargetTemperatureValue !== 0) {
1175
+ if (this.Status.data?.upperCurrentTemperatureUnit.includes('FAH')) {
1176
+ return this.tempFtoC(this.Status.data?.upperTargetTemperatureValue);
1177
+ }
1178
+ else {
1179
+ return 0.5 * Math.round(2 * this.Status.data?.upperTargetTemperatureValue);
1180
+ }
1181
+ }
1182
+ else {
1183
+ return 38;
1184
+ }
1185
+ }
1186
+ probeCurrentTemperature() {
1187
+ /////Current Temp
1188
+ if (this.Status.data?.upperCurrentProveTemperatureF !== 0 && typeof this.Status.data?.upperCurrentProveTemperatureF !== 'undefined') {
1189
+ return this.tempFtoC(this.Status.data?.upperCurrentProveTemperatureF);
1190
+ }
1191
+ else {
1192
+ return this.localTemperature;
1193
+ }
1194
+ }
1195
+ probeTargetTemperature() {
1196
+ ////Set temperature
1197
+ if (this.Status.data?.upperTargetProveTemperatureF !== 0) {
1198
+ return this.tempFtoC(this.Status.data?.upperTargetProveTemperatureF);
1199
+ }
1200
+ else {
1201
+ return 38;
1202
+ }
1203
+ }
1204
+ OvenSubCookMenu(name) {
1205
+ if (this.Status.data?.upperSubCookMenu !== 'NONE' && typeof this.Status.data?.upperSubCookMenu !== 'undefined') {
1206
+ let subCook = this.Status.data?.upperSubCookMenu;
1207
+ subCook = subCook.toLocaleLowerCase();
1208
+ const subCookCap = subCook.charAt(0).toUpperCase()
1209
+ + subCook.slice(1);
1210
+ return name + ' (' + subCookCap + ')';
1211
+ }
1212
+ return name;
1213
+ }
1214
+ oventTargetTime() {
1215
+ let setDuration = 0;
1216
+ if (typeof this.Status.data?.upperTargetTimeHour !== 'undefined') {
1217
+ setDuration += this.Status.data?.upperTargetTimeHour * ONE_HOUR_IN_SECONDS;
1218
+ }
1219
+ if (typeof this.Status.data?.upperTargetTimeMinute !== 'undefined') {
1220
+ setDuration += this.Status.data?.upperTargetTimeMinute * 60;
1221
+ }
1222
+ if (typeof this.Status.data?.upperTargetTimeSecond !== 'undefined') {
1223
+ setDuration += this.Status.data?.upperTargetTimeSecond;
1224
+ }
1225
+ return setDuration;
1226
+ }
1227
+ ovenTimerTime() {
1228
+ let remainTimer = 0;
1229
+ if (typeof this.Status.data?.upperTimerHour !== 'undefined') {
1230
+ remainTimer += this.Status.data?.upperTimerHour * ONE_HOUR_IN_SECONDS;
1231
+ }
1232
+ if (typeof this.Status.data?.upperTimerMinute !== 'undefined') {
1233
+ remainTimer += this.Status.data?.upperTimerMinute * 60;
1234
+ }
1235
+ if (typeof this.Status.data?.upperTimerSecond !== 'undefined') {
1236
+ remainTimer += this.Status.data?.upperTimerSecond;
1237
+ }
1238
+ return remainTimer;
1239
+ }
1240
+ tempCtoF(temp) {
1241
+ return Math.round(temp * 1.8 + 32);
1242
+ }
1243
+ tempFtoC(temp) {
1244
+ return 0.5 * Math.round(2 * (temp - 32) / 1.8);
1245
+ }
1246
+ //////////////////
1247
+ ovenCookingDuration() {
1248
+ /////Cycle duration
1249
+ const courseTime = new Date(0);
1250
+ courseTime.setSeconds(this.oventTargetTime());
1251
+ let courseTimeString = courseTime.toISOString().substr(11, 8);
1252
+ if (courseTimeString.startsWith('0')) {
1253
+ courseTimeString = courseTimeString.substring(1);
1254
+ }
1255
+ let hourMinutes = 'Minutes';
1256
+ if (this.oventTargetTime() > ONE_HOUR_IN_SECONDS) {
1257
+ hourMinutes = 'Hours';
1258
+ }
1259
+ if (this.oventTargetTime() === ONE_HOUR_IN_SECONDS) {
1260
+ hourMinutes = 'Hour';
1261
+ }
1262
+ return 'Duration: ' + courseTimeString + ' ' + hourMinutes;
1263
+ }
1264
+ ovenCookingTimer() {
1265
+ const courseTimer = new Date(0);
1266
+ courseTimer.setSeconds(this.ovenTimerTime());
1267
+ let courseTimerString = courseTimer.toISOString().substr(11, 8);
1268
+ if (courseTimerString.startsWith('0')) {
1269
+ courseTimerString = courseTimerString.substring(1);
1270
+ }
1271
+ let hourMinutes = 'Minutes';
1272
+ if (this.ovenTimerTime() > ONE_HOUR_IN_SECONDS) {
1273
+ hourMinutes = 'Hours';
1274
+ }
1275
+ if (this.ovenTimerTime() === ONE_HOUR_IN_SECONDS) {
1276
+ hourMinutes = 'Hour';
1277
+ }
1278
+ return 'Timer: ' + courseTimerString + ' ' + hourMinutes;
1279
+ }
1280
+ ovenCookingStartTime() {
1281
+ ////Starting time
1282
+ const courseStart = new Date();
1283
+ const newDate = courseStart.toLocaleString('en-US', {
1284
+ weekday: 'long',
1285
+ year: 'numeric',
1286
+ month: 'long',
1287
+ day: 'numeric',
1288
+ hour12: false,
1289
+ hour: 'numeric',
1290
+ minute: 'numeric',
1291
+ second: 'numeric',
1292
+ timeZoneName: 'short',
1293
+ });
1294
+ return 'Start: ' + newDate;
1295
+ }
1296
+ ovenCookingEndTime() {
1297
+ const courseCurrentTime = new Date();
1298
+ this.courseStartMS = courseCurrentTime.getTime();
1299
+ const dateEnd = new Date(this.oventTargetTime() * ONE_SECOND_MS + this.courseStartMS);
1300
+ const newEndDate = dateEnd.toLocaleString('en-US', {
1301
+ weekday: 'long',
1302
+ year: 'numeric',
1303
+ month: 'long',
1304
+ day: 'numeric',
1305
+ hour12: false,
1306
+ hour: 'numeric',
1307
+ minute: 'numeric',
1308
+ second: 'numeric',
1309
+ timeZoneName: 'short',
1310
+ });
1311
+ return 'End: ' + newEndDate;
1312
+ }
1313
+ oventOptions() {
1314
+ this.inputNameOptions = 'Settings: ';
1315
+ if (this.Status.data?.upperCurrentTemperatureUnit.includes('FAH')) {
1316
+ this.inputNameOptions += 'Temp in °F';
1317
+ }
1318
+ else {
1319
+ this.inputNameOptions += 'Temp in °C';
1320
+ }
1321
+ if (!this.Status.data?.upperSabbath.includes('DIS')) {
1322
+ this.inputNameOptions += ', Sabbath On';
1323
+ }
1324
+ if (this.Status.data?.settingConvAutoConversion?.includes('ENA')) {
1325
+ this.inputNameOptions += ', Auto Conversion';
1326
+ }
1327
+ if (this.Status.data?.settingPreheatAlarm?.includes('ON')) {
1328
+ this.inputNameOptions += ', Preheat Alarm°';
1329
+ }
1330
+ return this.nameLengthCheck(this.inputNameOptions);
1331
+ }
1332
+ ///////////
1333
+ probeStatus() {
1334
+ if (this.Status.data.upperCurrentProveTemperatureF !== 0 && typeof this.Status.data.upperCurrentProveTemperatureF !== 'undefined') {
1335
+ this.probeName = '';
1336
+ this.showProbe = true;
1337
+ if (this.Status.data.upperTargetProveTemperatureF !== 0 && typeof this.Status.data.upperTargetProveTemperatureF !== 'undefined') {
1338
+ const donePercent = Math.round(100 * this.Status.data.upperCurrentProveTemperatureF / this.Status.data.upperTargetProveTemperatureF);
1339
+ this.probeName += 'Food is ' + donePercent + '% Done, ';
1340
+ }
1341
+ if (this.Status.data.upperCurrentTemperatureUnit.includes('FAH')) {
1342
+ this.probeName += 'Current Probe Temp ' + this.Status.data.upperCurrentProveTemperatureF + '°';
1343
+ if (this.Status.data.upperTargetProveTemperatureF !== 0 && typeof this.Status.data.upperTargetProveTemperatureF !== 'undefined') {
1344
+ this.probeName += ' With Set Temp ' + this.Status.data.upperTargetProveTemperatureF + '°';
1345
+ }
1346
+ }
1347
+ else {
1348
+ this.probeName += 'Current Probe Temp ' + this.tempFtoC(this.Status.data.upperCurrentProveTemperatureF) + '°';
1349
+ if (this.Status.data.upperTargetProveTemperatureF !== 0 && typeof this.Status.data.upperTargetProveTemperatureF !== 'undefined') {
1350
+ this.probeName += ' With Set Temp ' + this.tempFtoC(this.Status.data.upperTargetProveTemperatureF) + '°';
1351
+ }
1352
+ }
1353
+ }
1354
+ else {
1355
+ this.probeName = 'Probe Settings Not Available ';
1356
+ this.showProbe = false;
1357
+ }
1358
+ return this.nameLengthCheck(this.probeName);
1359
+ }
1360
+ ///////////Temperature Control
1361
+ probeCurrentState() {
1362
+ /////Current Temp
1363
+ if (this.Status.data?.upperCurrentProveTemperatureF !== 0 && typeof this.Status.data?.upperCurrentProveTemperatureF !== 'undefined') {
1364
+ return 1;
1365
+ }
1366
+ else {
1367
+ return 0;
1368
+ }
1369
+ }
1370
+ probeTargetState() {
1371
+ ////Set temperature
1372
+ if (this.Status.data?.upperTargetProveTemperatureF !== 0) {
1373
+ return 1;
1374
+ }
1375
+ else {
1376
+ return 0;
1377
+ }
1378
+ }
1379
+ currentHeatingState() {
1380
+ if (this.Status.data?.upperCurrentTemperatureValue !== 0) {
1381
+ return 1;
1382
+ }
1383
+ else {
1384
+ return 0;
1385
+ }
1386
+ }
1387
+ targetHeatingState() {
1388
+ // if (this.Status.data?.upperState.includes('INITIAL') ||
1389
+ // this.Status.data?.upperState.includes('DONE') ||
1390
+ // this.Status.data?.upperState.includes('COOLING')) {
1391
+ if (this.Status.data?.upperTargetTemperatureValue === 0) {
1392
+ return 0;
1393
+ }
1394
+ else {
1395
+ return 1;
1396
+ }
1397
+ }
1398
+ createCook(key) {
1399
+ const { Service: { HeaterCooler }, Characteristic } = this.platform;
1400
+ const device = this.accessory.context.device;
1401
+ const service = this.accessory.getService(HeaterCooler) || this.accessory.addService(HeaterCooler, device.name);
1402
+ service.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
1403
+ .onGet(() => {
1404
+ const currentState = device.deviceModel.lookupMonitorValue('UpperOvenState', this.Status.getState(key));
1405
+ if (currentState === null) {
1406
+ this.logger.error('Current Oven State is null');
1407
+ return Characteristic.CurrentHeaterCoolerState.INACTIVE;
1408
+ }
1409
+ if (currentState === OvenState.COOLING) {
1410
+ return Characteristic.CurrentHeaterCoolerState.COOLING;
1411
+ }
1412
+ else if ([OvenState.PREHEATING, OvenState.COOKING_IN_PROGRESS].includes(currentState)) {
1413
+ return Characteristic.CurrentHeaterCoolerState.HEATING;
1414
+ }
1415
+ else {
1416
+ return Characteristic.CurrentHeaterCoolerState.IDLE;
1417
+ }
1418
+ });
1419
+ service.getCharacteristic(Characteristic.TargetHeaterCoolerState)
1420
+ .setProps({
1421
+ validValues: [Characteristic.TargetHeaterCoolerState.HEAT],
1422
+ perms: ["ev" /* Perms.NOTIFY */, "pr" /* Perms.PAIRED_READ */],
1423
+ });
1424
+ }
1425
+ burner1State() {
1426
+ if (this.Status.data?.cooktop1CooktopState !== 'INIT' && typeof this.Status.data?.cooktop1CooktopState !== 'undefined') {
1427
+ let burnerOperationTime = 0;
1428
+ if (typeof this.Status.data?.cooktop1OperationTimeHour !== 'undefined') {
1429
+ burnerOperationTime += this.Status.data?.cooktop1OperationTimeHour * ONE_HOUR_IN_SECONDS;
1430
+ }
1431
+ if (typeof this.Status.data?.cooktop1OperationTimeMinute !== 'undefined') {
1432
+ burnerOperationTime += this.Status.data?.cooktop1OperationTimeMinute * 60;
1433
+ }
1434
+ if (typeof this.Status.data?.cooktop1OperationTimeSecond !== 'undefined') {
1435
+ burnerOperationTime += this.Status.data?.cooktop1OperationTimeSecond;
1436
+ }
1437
+ if (burnerOperationTime !== 0) {
1438
+ this.inputNameBurner1 = 'Front Left Burner is On. Cooking for ' + this.getOperationTime(burnerOperationTime);
1439
+ }
1440
+ else {
1441
+ this.inputNameBurner1 = 'Front Left Burner is On';
1442
+ }
1443
+ this.showBurner1 = true;
1444
+ }
1445
+ else {
1446
+ this.inputNameBurner1 = 'Front Left Burner Not in Use';
1447
+ this.showBurner1 = false;
1448
+ }
1449
+ return this.nameLengthCheck(this.inputNameBurner1);
1450
+ }
1451
+ burner2State() {
1452
+ if (this.Status.data?.cooktop2CooktopState !== 'INIT' && typeof this.Status.data?.cooktop2CooktopState !== 'undefined') {
1453
+ let burnerOperationTime = 0;
1454
+ if (typeof this.Status.data?.cooktop2OperationTimeHour !== 'undefined') {
1455
+ burnerOperationTime += this.Status.data?.cooktop2OperationTimeHour * ONE_HOUR_IN_SECONDS;
1456
+ }
1457
+ if (typeof this.Status.data?.cooktop1OperationTimeMinute !== 'undefined') {
1458
+ burnerOperationTime += this.Status.data?.cooktop2OperationTimeMinute * 60;
1459
+ }
1460
+ if (typeof this.Status.data?.cooktop1OperationTimeSecond !== 'undefined') {
1461
+ burnerOperationTime += this.Status.data?.cooktop2OperationTimeSecond;
1462
+ }
1463
+ if (burnerOperationTime !== 0) {
1464
+ this.inputNameBurner2 = 'Back Left Burner is On. Cooking for ' + this.getOperationTime(burnerOperationTime);
1465
+ }
1466
+ else {
1467
+ this.inputNameBurner2 = 'Back Left Burner is On';
1468
+ }
1469
+ this.showBurner2 = true;
1470
+ }
1471
+ else {
1472
+ this.inputNameBurner2 = 'Back Left Burner Not in Use';
1473
+ this.showBurner2 = false;
1474
+ }
1475
+ return this.nameLengthCheck(this.inputNameBurner2);
1476
+ }
1477
+ burner3State() {
1478
+ if (this.Status.data?.cooktop3CooktopState !== 'INIT' && typeof this.Status.data?.cooktop3CooktopState !== 'undefined') {
1479
+ let burnerOperationTime = 0;
1480
+ if (typeof this.Status.data?.cooktop3OperationTimeHour !== 'undefined') {
1481
+ burnerOperationTime += this.Status.data?.cooktop3OperationTimeHour * ONE_HOUR_IN_SECONDS;
1482
+ }
1483
+ if (typeof this.Status.data?.cooktop3OperationTimeMinute !== 'undefined') {
1484
+ burnerOperationTime += this.Status.data?.cooktop3OperationTimeMinute * 60;
1485
+ }
1486
+ if (typeof this.Status.data?.cooktop3OperationTimeSecond !== 'undefined') {
1487
+ burnerOperationTime += this.Status.data?.cooktop3OperationTimeSecond;
1488
+ }
1489
+ if (burnerOperationTime !== 0) {
1490
+ this.inputNameBurner3 = 'Center Burner is On. Cooking for ' + this.getOperationTime(burnerOperationTime);
1491
+ }
1492
+ else {
1493
+ this.inputNameBurner3 = 'Center Burner is On';
1494
+ }
1495
+ this.showBurner3 = true;
1496
+ }
1497
+ else {
1498
+ this.inputNameBurner3 = 'Center Burner Not in Use';
1499
+ this.showBurner3 = false;
1500
+ }
1501
+ return this.nameLengthCheck(this.inputNameBurner3);
1502
+ }
1503
+ burner4State() {
1504
+ if (this.Status.data?.cooktop4CooktopState !== 'INIT' && typeof this.Status.data?.cooktop4CooktopState !== 'undefined') {
1505
+ let burnerOperationTime = 0;
1506
+ if (typeof this.Status.data?.cooktop4OperationTimeHour !== 'undefined') {
1507
+ burnerOperationTime += this.Status.data?.cooktop4OperationTimeHour * ONE_HOUR_IN_SECONDS;
1508
+ }
1509
+ if (typeof this.Status.data?.cooktop4OperationTimeMinute !== 'undefined') {
1510
+ burnerOperationTime += this.Status.data?.cooktop4OperationTimeMinute * 60;
1511
+ }
1512
+ if (typeof this.Status.data?.cooktop4OperationTimeSecond !== 'undefined') {
1513
+ burnerOperationTime += this.Status.data?.cooktop4OperationTimeSecond;
1514
+ }
1515
+ if (burnerOperationTime !== 0) {
1516
+ this.inputNameBurner4 = 'Front Right Burner is On. Cooking for ' + this.getOperationTime(burnerOperationTime);
1517
+ }
1518
+ else {
1519
+ this.inputNameBurner4 = 'Front Right Burner is On';
1520
+ }
1521
+ this.showBurner4 = true;
1522
+ }
1523
+ else {
1524
+ this.inputNameBurner4 = 'Front Right Burner Not in Use';
1525
+ this.showBurner4 = false;
1526
+ }
1527
+ return this.nameLengthCheck(this.inputNameBurner4);
1528
+ }
1529
+ burner5State() {
1530
+ if (this.Status.data?.cooktop5CooktopState !== 'INIT' && typeof this.Status.data?.cooktop5CooktopState !== 'undefined') {
1531
+ let burnerOperationTime = 0;
1532
+ if (typeof this.Status.data?.cooktop5OperationTimeHour !== 'undefined') {
1533
+ burnerOperationTime += this.Status.data?.cooktop5OperationTimeHour * ONE_HOUR_IN_SECONDS;
1534
+ }
1535
+ if (typeof this.Status.data?.cooktop5OperationTimeMinute !== 'undefined') {
1536
+ burnerOperationTime += this.Status.data?.cooktop5OperationTimeMinute * 60;
1537
+ }
1538
+ if (typeof this.Status.data?.cooktop5OperationTimeSecond !== 'undefined') {
1539
+ burnerOperationTime += this.Status.data?.cooktop5OperationTimeSecond;
1540
+ }
1541
+ if (burnerOperationTime !== 0) {
1542
+ this.inputNameBurner5 = 'Back Right Burner is On. Cooking for ' + this.getOperationTime(burnerOperationTime);
1543
+ }
1544
+ else {
1545
+ this.inputNameBurner5 = 'Back Right Burner is On';
1546
+ }
1547
+ this.showBurner5 = true;
1548
+ }
1549
+ else {
1550
+ this.inputNameBurner5 = 'Back Right Burner Not in Use';
1551
+ this.showBurner5 = false;
1552
+ }
1553
+ return this.nameLengthCheck(this.inputNameBurner5);
1554
+ }
1555
+ updateOvenModeSwitch() {
1556
+ this.pauseUpdate = true;
1557
+ this.updateOvenModeSwitchNoPause();
1558
+ }
1559
+ updateOvenModeSwitchNoPause() {
1560
+ this.bakeSwitch.updateCharacteristic(this.platform.Characteristic.On, this.ovenCommandList.ovenMode === 'BAKE' ? true : false);
1561
+ this.convectionBakeSwitch.updateCharacteristic(this.platform.Characteristic.On, this.ovenCommandList.ovenMode === 'CONVECTION_BAKE' ? true : false);
1562
+ this.convectionRoastSwitch.updateCharacteristic(this.platform.Characteristic.On, this.ovenCommandList.ovenMode === 'CONVECTION_ROST' ? true : false);
1563
+ this.frozenMealSwitch.updateCharacteristic(this.platform.Characteristic.On, this.ovenCommandList.ovenMode === 'FROZEN_MEAL' ? true : false);
1564
+ this.airFrySwitch.updateCharacteristic(this.platform.Characteristic.On, this.ovenCommandList.ovenMode === 'AIR_FRY' ? true : false);
1565
+ this.airSousvideSwitch.updateCharacteristic(this.platform.Characteristic.On, this.ovenCommandList.ovenMode === 'AIR_SOUSVIDE' ? true : false);
1566
+ this.warmModeSwitch.updateCharacteristic(this.platform.Characteristic.On, this.ovenCommandList.ovenMode === 'WARM' ? true : false);
1567
+ }
1568
+ getOperationTime(timeInSeconds) {
1569
+ const newTime = new Date(0);
1570
+ newTime.setSeconds(timeInSeconds);
1571
+ let newTimeString = newTime.toTimeString();
1572
+ if (newTimeString.startsWith('0')) {
1573
+ newTimeString = newTimeString.substring(1);
1574
+ }
1575
+ let hourMinutes = 'Minutes';
1576
+ if (timeInSeconds > ONE_HOUR_IN_SECONDS) {
1577
+ hourMinutes = 'Hours';
1578
+ }
1579
+ if (timeInSeconds === ONE_HOUR_IN_SECONDS) {
1580
+ hourMinutes = 'Hour';
1581
+ }
1582
+ return newTimeString + ' ' + hourMinutes;
1583
+ }
1584
+ ovenServiceActive() {
1585
+ if (!this.Status.data?.upperState.includes('INITIAL') || this.Status.data?.burnerOnCounter !== 0) {
1586
+ return 1;
1587
+ }
1588
+ else {
1589
+ return 0;
1590
+ }
1591
+ }
1592
+ updateAccessoryCharacteristic(device) {
1593
+ super.updateAccessoryCharacteristic(device);
1594
+ const { Characteristic } = this.platform;
1595
+ // this.platform.log('Update Accessorry received');
1596
+ if (!this.pauseUpdate) {
1597
+ if (this.ovenService.getCharacteristic(this.platform.Characteristic.Active).value !== this.ovenServiceActive()) {
1598
+ this.ovenService.updateCharacteristic(this.platform.Characteristic.Active, this.ovenServiceActive());
1599
+ }
1600
+ if (this.ovenOnStatus()) {
1601
+ this.ovenCommandList = {
1602
+ ovenMode: 'NONE',
1603
+ ovenSetTemperature: 350,
1604
+ tempUnits: 'FAHRENHEIT',
1605
+ ovenSetDuration: THIRTY_MINUTES_IN_SECONDS,
1606
+ probeTemperature: 0,
1607
+ ovenKeepWarm: 'DISABLE',
1608
+ };
1609
+ if (this.bakeSwitch.getCharacteristic(this.platform.Characteristic.On).value === true ||
1610
+ this.convectionBakeSwitch.getCharacteristic(this.platform.Characteristic.On).value === true ||
1611
+ this.convectionRoastSwitch.getCharacteristic(this.platform.Characteristic.On).value === true ||
1612
+ this.frozenMealSwitch.getCharacteristic(this.platform.Characteristic.On).value === true ||
1613
+ this.airFrySwitch.getCharacteristic(this.platform.Characteristic.On).value === true ||
1614
+ this.airSousvideSwitch.getCharacteristic(this.platform.Characteristic.On).value === true ||
1615
+ this.warmModeSwitch.getCharacteristic(this.platform.Characteristic.On).value === true) {
1616
+ this.updateOvenModeSwitch();
1617
+ }
1618
+ }
1619
+ else {
1620
+ this.ovenCommandList = {
1621
+ ovenMode: this.Status.data?.upperManualCookName,
1622
+ ovenSetTemperature: this.Status.data?.upperTargetTemperatureValue,
1623
+ tempUnits: this.Status.data?.upperCurrentTemperatureUnit,
1624
+ ovenSetDuration: this.oventTargetTime(),
1625
+ probeTemperature: this.Status.data?.upperTargetProveTemperatureF,
1626
+ ovenKeepWarm: (this.Status.data?.upperCookAndWarmStatus?.includes('DIS')) ? 'DISABLE' : 'ENABLE',
1627
+ };
1628
+ this.updateOvenModeSwitchNoPause();
1629
+ }
1630
+ ///// how to handle the time Here
1631
+ if (!this.Status.data?.upperManualCookName.includes('NONE')) {
1632
+ if (this.firstStart) {
1633
+ this.courseStartString = this.ovenCookingStartTime();
1634
+ }
1635
+ this.showTime = true;
1636
+ }
1637
+ else {
1638
+ this.firstStart = true;
1639
+ this.showTime = false;
1640
+ this.courseStartString = 'Oven Start Time Not Set';
1641
+ }
1642
+ if (this.oventTargetTime() !== 0) {
1643
+ if (this.oventTargetTime() !== this.firstDuration) {
1644
+ this.firstDuration = this.oventTargetTime();
1645
+ this.courseTimeString = this.ovenCookingDuration();
1646
+ this.courseTimeEndString = this.ovenCookingEndTime();
1647
+ }
1648
+ this.showTime = true;
1649
+ }
1650
+ else {
1651
+ this.firstDuration = 0;
1652
+ this.courseTimeString = 'Oven Cook Time Not Set';
1653
+ this.courseTimeEndString = 'Oven End Time Not Set';
1654
+ }
1655
+ if (this.ovenTimerTime() !== 0) {
1656
+ if (this.ovenTimerTime() !== this.firstDuration) {
1657
+ this.firstTimer = this.ovenTimerTime();
1658
+ this.courseTimerString = this.ovenCookingTimer();
1659
+ }
1660
+ this.showTimer = true;
1661
+ }
1662
+ else {
1663
+ this.firstTimer = 0;
1664
+ this.showTimer = false;
1665
+ this.courseTimerString = 'Oven Timer Not Set';
1666
+ }
1667
+ ///////////////////
1668
+ if (this.ovenState.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.ovenStatus()) {
1669
+ this.ovenState.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.ovenStatus());
1670
+ }
1671
+ if (this.ovenMode.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.ovenModeName()) {
1672
+ this.ovenMode.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.ovenModeName());
1673
+ }
1674
+ if (this.probeService.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.probeStatus()) {
1675
+ this.probeService.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.probeStatus());
1676
+ }
1677
+ if (this.ovenTemp.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.ovenTemperature()) {
1678
+ this.ovenTemp.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.ovenTemperature());
1679
+ }
1680
+ if (this.ovenStart.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.nameLengthCheck(this.courseStartString)) {
1681
+ this.ovenStart.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.nameLengthCheck(this.courseStartString));
1682
+ }
1683
+ if (this.ovenTimer.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.nameLengthCheck(this.courseTimerString)) {
1684
+ this.ovenTimer.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.nameLengthCheck(this.courseTimerString));
1685
+ }
1686
+ if (this.ovenTime.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.nameLengthCheck(this.courseTimeString)) {
1687
+ this.ovenTime.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.nameLengthCheck(this.courseTimeString));
1688
+ }
1689
+ if (this.ovenEndTime.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.nameLengthCheck(this.courseTimeEndString)) {
1690
+ this.ovenEndTime.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.nameLengthCheck(this.courseTimeEndString));
1691
+ }
1692
+ if (this.ovenOptions.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.oventOptions()) {
1693
+ this.ovenOptions.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.oventOptions());
1694
+ }
1695
+ if (this.burner1.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.burner1State()) {
1696
+ this.burner1.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.burner1State());
1697
+ }
1698
+ if (this.burner2.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.burner2State()) {
1699
+ this.burner2.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.burner2State());
1700
+ }
1701
+ if (this.burner3.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.burner3State()) {
1702
+ this.burner3.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.burner3State());
1703
+ }
1704
+ if (this.burner4.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.burner4State()) {
1705
+ this.burner4.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.burner4State());
1706
+ }
1707
+ if (this.burner5.getCharacteristic(this.platform.Characteristic.ConfiguredName).value !== this.burner5State()) {
1708
+ this.burner5.updateCharacteristic(this.platform.Characteristic.ConfiguredName, this.burner5State());
1709
+ }
1710
+ /////////////Show State
1711
+ const visibilityState = this.platform.Characteristic.TargetVisibilityState;
1712
+ const currentState = this.platform.Characteristic.CurrentVisibilityState;
1713
+ const updateVisibility = (service, condition) => {
1714
+ service.updateCharacteristic(visibilityState, condition ? visibilityState.SHOWN : visibilityState.HIDDEN);
1715
+ service.updateCharacteristic(currentState, condition ? currentState.SHOWN : currentState.HIDDEN);
1716
+ };
1717
+ updateVisibility(this.ovenMode, this.ovenOnStatus());
1718
+ updateVisibility(this.ovenTemp, this.ovenOnStatus());
1719
+ updateVisibility(this.probeService, this.showProbe);
1720
+ updateVisibility(this.ovenOptions, this.ovenOnStatus());
1721
+ updateVisibility(this.ovenStart, this.showTime);
1722
+ updateVisibility(this.ovenTime, this.showTime);
1723
+ updateVisibility(this.ovenEndTime, this.showTime);
1724
+ updateVisibility(this.ovenTimer, this.showTimer);
1725
+ updateVisibility(this.burner1, this.showBurner1);
1726
+ updateVisibility(this.burner2, this.showBurner2);
1727
+ updateVisibility(this.burner3, this.showBurner3);
1728
+ updateVisibility(this.burner4, this.showBurner4);
1729
+ updateVisibility(this.burner5, this.showBurner5);
1730
+ /////////Temperature Monitor
1731
+ if (this.ovenTempControl.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits).value !==
1732
+ this.Status.data?.upperCurrentTemperatureUnit.includes('FAH') ? 1 : 0) {
1733
+ this.ovenTempControl.updateCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits, this.Status.data?.upperCurrentTemperatureUnit.includes('FAH') ? 1 : 0);
1734
+ this.probeTempControl.updateCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits, this.Status.data?.upperCurrentTemperatureUnit.includes('FAH') ? 1 : 0);
1735
+ }
1736
+ if (this.ovenTempControl.getCharacteristic(this.platform.Characteristic.CurrentTemperature).value !== this.ovenCurrentTemperature()) {
1737
+ this.ovenTempControl.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.ovenCurrentTemperature());
1738
+ }
1739
+ if (this.Status.data?.upperTargetTemperatureValue !== 0) {
1740
+ if (this.ovenTempControl.getCharacteristic(this.platform.Characteristic.TargetTemperature).value !== this.ovenTargetTemperature()) {
1741
+ this.ovenTempControl.updateCharacteristic(this.platform.Characteristic.TargetTemperature, this.ovenTargetTemperature());
1742
+ }
1743
+ }
1744
+ if (this.ovenTempControl.getCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState).value !== this.targetHeatingState()) {
1745
+ this.ovenTempControl.updateCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState, this.targetHeatingState());
1746
+ }
1747
+ if (this.ovenTempControl.getCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState).value !== this.currentHeatingState()) {
1748
+ this.ovenTempControl.updateCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState, this.currentHeatingState());
1749
+ }
1750
+ if (this.ovenTempControl.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).value !== this.localHumidity) {
1751
+ this.probeTempControl.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.localHumidity);
1752
+ this.ovenTempControl.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.localHumidity);
1753
+ }
1754
+ if (this.Status.data?.upperCurrentProveTemperatureF !== 0 && typeof this.Status.data?.upperCurrentProveTemperatureF !== 'undefined') {
1755
+ if (this.probeTempControl.getCharacteristic(this.platform.Characteristic.CurrentTemperature).value !== this.probeCurrentTemperature()) {
1756
+ this.probeTempControl.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.probeCurrentTemperature());
1757
+ }
1758
+ }
1759
+ if (this.Status.data?.upperTargetProveTemperatureF !== 0) {
1760
+ if (this.probeTempControl.getCharacteristic(this.platform.Characteristic.TargetTemperature).value !== this.probeTargetTemperature()) {
1761
+ this.probeTempControl.updateCharacteristic(this.platform.Characteristic.TargetTemperature, this.probeTargetTemperature());
1762
+ }
1763
+ }
1764
+ if (this.probeTempControl.getCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState).value !== this.probeTargetState()) {
1765
+ this.probeTempControl.updateCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState, this.probeTargetState());
1766
+ }
1767
+ if (this.probeTempControl.getCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState).value !== this.probeCurrentState()) {
1768
+ this.probeTempControl.updateCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState, this.probeCurrentState());
1769
+ }
1770
+ ///////Timer Monitor
1771
+ this.ovenTimerService.updateCharacteristic(this.platform.Characteristic.Active, this.remainTime() > 0 ? 1 : 0);
1772
+ if (this.oventTargetTime() === 0) {
1773
+ this.ovenTimerService.updateCharacteristic(this.platform.Characteristic.InUse, Characteristic.InUse.NOT_IN_USE);
1774
+ }
1775
+ else if (this.ovenOnStatus() && this.oventTargetTime() !== 0) {
1776
+ this.ovenTimerService.updateCharacteristic(this.platform.Characteristic.InUse, Characteristic.InUse.IN_USE);
1777
+ }
1778
+ if (this.ovenTimerService.getCharacteristic(this.platform.Characteristic.RemainingDuration).value !== this.remainTime()) {
1779
+ this.ovenTimerService.updateCharacteristic(this.platform.Characteristic.RemainingDuration, this.ovenCurrentTemperature());
1780
+ }
1781
+ if (this.ovenTimerService.getCharacteristic(this.platform.Characteristic.SetDuration).value !== this.oventTargetTime()) {
1782
+ this.ovenTimerService.updateCharacteristic(this.platform.Characteristic.SetDuration, this.oventTargetTime());
1783
+ }
1784
+ ///Monitor Switch Status
1785
+ if (this.Status.data?.upperRemoteStart.includes('DIS')) {
1786
+ this.monitorOnly = true;
1787
+ }
1788
+ if (this.monitorOnlySwitch.getCharacteristic(this.platform.Characteristic.On).value !== this.monitorOnly) {
1789
+ this.monitorOnlySwitch.updateCharacteristic(this.platform.Characteristic.On, this.monitorOnly);
1790
+ }
1791
+ ////////Door Status
1792
+ this.ovenDoorOpened.updateCharacteristic(this.platform.Characteristic.StatusActive, this.onStatus());
1793
+ this.ovenDoorOpened.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.Status.data?.upperDoorOpen.includes('DIS') ? 0 : 1);
1794
+ ///Range Status
1795
+ if (this.rangeOn.getCharacteristic(this.platform.Characteristic.StatusActive).value !== this.onStatus()) {
1796
+ this.rangeOn.updateCharacteristic(this.platform.Characteristic.StatusActive, this.onStatus());
1797
+ this.rangeOn.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.onStatus());
1798
+ }
1799
+ ////Remote Control Status
1800
+ this.remoteEnabled.updateCharacteristic(this.platform.Characteristic.StatusActive, this.onStatus());
1801
+ this.remoteEnabled.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.Status.data?.upperRemoteStart.includes('DIS') ? 0 : 1);
1802
+ /////Burners on
1803
+ this.burnersOnNumber.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.Status.data?.burnerOnCounter < 1 ? 0.0001 : this.Status.data?.burnerOnCounter);
1804
+ this.burnersOnNumber.updateCharacteristic(this.platform.Characteristic.StatusActive, this.Status.data?.burnerOnCounter > 0 ? true : false);
1805
+ //////Alarm Timer
1806
+ this.ovenAlarmService.updateCharacteristic(Characteristic.Active, this.ovenTimerTime() > 0 ? 1 : 0);
1807
+ this.ovenAlarmService.updateCharacteristic(Characteristic.RemainingDuration, this.ovenTimerTime());
1808
+ this.ovenAlarmService.updateCharacteristic(Characteristic.InUse, this.ovenTimerTime() > 0 ? 1 : 0);
1809
+ if ('upperCookAndWarmStatus' in this.Status.data) {
1810
+ ////Switch State
1811
+ this.keepWarmSwitch?.updateCharacteristic(this.platform.Characteristic.On, !this.Status.data?.upperCookAndWarmStatus.includes('DIS'));
1812
+ //////////Warm Status
1813
+ if (!this.Status.data?.upperCookAndWarmStatus.includes('DIS')) {
1814
+ this.ovenCommandList.ovenKeepWarm = 'ENABLE';
1815
+ }
1816
+ else {
1817
+ this.ovenCommandList.ovenKeepWarm = 'DISABLE';
1818
+ }
1819
+ }
1820
+ }
1821
+ else {
1822
+ if (this.firstPause) {
1823
+ this.firstPause = false;
1824
+ setTimeout(() => {
1825
+ this.pauseUpdate = false;
1826
+ this.firstPause = true;
1827
+ }, TWO_MINUTES_MS);
1828
+ }
1829
+ }
1830
+ }
1831
+ update(snapshot) {
1832
+ super.update(snapshot);
1833
+ const oven = snapshot.oven;
1834
+ if (!oven) {
1835
+ return;
1836
+ }
1837
+ }
1838
+ }
1839
+ export class OvenStatus {
1840
+ data;
1841
+ deviceModel;
1842
+ constructor(data, deviceModel) {
1843
+ this.data = data;
1844
+ this.deviceModel = deviceModel;
1845
+ }
1846
+ getState(key) {
1847
+ return this.data[key + 'State'];
1848
+ }
1849
+ }
1850
+ //# sourceMappingURL=Oven.js.map