@matter/node 0.16.0-alpha.0-20251027-17770fb28 → 0.16.0-alpha.0-20251030-e9ca79f93

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 (120) hide show
  1. package/dist/cjs/behavior/Behavior.d.ts +1 -0
  2. package/dist/cjs/behavior/Behavior.d.ts.map +1 -1
  3. package/dist/cjs/behavior/Behavior.js +5 -0
  4. package/dist/cjs/behavior/Behavior.js.map +1 -1
  5. package/dist/cjs/behavior/internal/BehaviorBacking.js +1 -1
  6. package/dist/cjs/behavior/internal/BehaviorBacking.js.map +1 -1
  7. package/dist/cjs/behavior/state/managed/Datasource.d.ts +4 -5
  8. package/dist/cjs/behavior/state/managed/Datasource.d.ts.map +1 -1
  9. package/dist/cjs/behavior/state/managed/Datasource.js +6 -2
  10. package/dist/cjs/behavior/state/managed/Datasource.js.map +1 -1
  11. package/dist/cjs/behavior/state/managed/ManagedReference.d.ts +3 -2
  12. package/dist/cjs/behavior/state/managed/ManagedReference.d.ts.map +1 -1
  13. package/dist/cjs/behavior/state/managed/ManagedReference.js +65 -20
  14. package/dist/cjs/behavior/state/managed/ManagedReference.js.map +1 -1
  15. package/dist/cjs/behavior/state/managed/values/ListManager.js +2 -1
  16. package/dist/cjs/behavior/state/managed/values/ListManager.js.map +1 -1
  17. package/dist/cjs/behavior/state/managed/values/StructManager.js +9 -1
  18. package/dist/cjs/behavior/state/managed/values/StructManager.js.map +1 -1
  19. package/dist/cjs/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
  20. package/dist/cjs/behaviors/access-control/AccessControlServer.js +3 -3
  21. package/dist/cjs/behaviors/access-control/AccessControlServer.js.map +1 -1
  22. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  23. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +3 -9
  24. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  25. package/dist/cjs/behaviors/service-area/ServiceAreaServer.js +2 -2
  26. package/dist/cjs/behaviors/service-area/ServiceAreaServer.js.map +1 -1
  27. package/dist/cjs/behaviors/thermostat/AtomicWriteHandler.d.ts +58 -0
  28. package/dist/cjs/behaviors/thermostat/AtomicWriteHandler.d.ts.map +1 -0
  29. package/dist/cjs/behaviors/thermostat/AtomicWriteHandler.js +306 -0
  30. package/dist/cjs/behaviors/thermostat/AtomicWriteHandler.js.map +6 -0
  31. package/dist/cjs/behaviors/thermostat/AtomicWriteState.d.ts +33 -0
  32. package/dist/cjs/behaviors/thermostat/AtomicWriteState.d.ts.map +1 -0
  33. package/dist/cjs/behaviors/thermostat/AtomicWriteState.js +86 -0
  34. package/dist/cjs/behaviors/thermostat/AtomicWriteState.js.map +6 -0
  35. package/dist/cjs/behaviors/thermostat/ThermostatBehavior.d.ts +12 -0
  36. package/dist/cjs/behaviors/thermostat/ThermostatBehavior.d.ts.map +1 -1
  37. package/dist/cjs/behaviors/thermostat/ThermostatInterface.d.ts +1 -0
  38. package/dist/cjs/behaviors/thermostat/ThermostatInterface.d.ts.map +1 -1
  39. package/dist/cjs/behaviors/thermostat/ThermostatServer.d.ts +894 -3
  40. package/dist/cjs/behaviors/thermostat/ThermostatServer.d.ts.map +1 -1
  41. package/dist/cjs/behaviors/thermostat/ThermostatServer.js +1216 -1
  42. package/dist/cjs/behaviors/thermostat/ThermostatServer.js.map +2 -2
  43. package/dist/cjs/devices/water-heater.d.ts +24 -0
  44. package/dist/cjs/devices/water-heater.d.ts.map +1 -1
  45. package/dist/cjs/endpoint/Endpoint.d.ts +36 -2
  46. package/dist/cjs/endpoint/Endpoint.d.ts.map +1 -1
  47. package/dist/cjs/endpoint/Endpoint.js +17 -14
  48. package/dist/cjs/endpoint/Endpoint.js.map +1 -1
  49. package/dist/cjs/endpoint/properties/EndpointContainer.d.ts +1 -0
  50. package/dist/cjs/endpoint/properties/EndpointContainer.d.ts.map +1 -1
  51. package/dist/cjs/endpoint/properties/EndpointContainer.js +3 -0
  52. package/dist/cjs/endpoint/properties/EndpointContainer.js.map +1 -1
  53. package/dist/esm/behavior/Behavior.d.ts +1 -0
  54. package/dist/esm/behavior/Behavior.d.ts.map +1 -1
  55. package/dist/esm/behavior/Behavior.js +5 -0
  56. package/dist/esm/behavior/Behavior.js.map +1 -1
  57. package/dist/esm/behavior/internal/BehaviorBacking.js +2 -2
  58. package/dist/esm/behavior/internal/BehaviorBacking.js.map +1 -1
  59. package/dist/esm/behavior/state/managed/Datasource.d.ts +4 -5
  60. package/dist/esm/behavior/state/managed/Datasource.d.ts.map +1 -1
  61. package/dist/esm/behavior/state/managed/Datasource.js +7 -3
  62. package/dist/esm/behavior/state/managed/Datasource.js.map +1 -1
  63. package/dist/esm/behavior/state/managed/ManagedReference.d.ts +3 -2
  64. package/dist/esm/behavior/state/managed/ManagedReference.d.ts.map +1 -1
  65. package/dist/esm/behavior/state/managed/ManagedReference.js +66 -21
  66. package/dist/esm/behavior/state/managed/ManagedReference.js.map +1 -1
  67. package/dist/esm/behavior/state/managed/values/ListManager.js +2 -1
  68. package/dist/esm/behavior/state/managed/values/ListManager.js.map +1 -1
  69. package/dist/esm/behavior/state/managed/values/StructManager.js +9 -1
  70. package/dist/esm/behavior/state/managed/values/StructManager.js.map +1 -1
  71. package/dist/esm/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
  72. package/dist/esm/behaviors/access-control/AccessControlServer.js +3 -3
  73. package/dist/esm/behaviors/access-control/AccessControlServer.js.map +1 -1
  74. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  75. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +3 -9
  76. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  77. package/dist/esm/behaviors/service-area/ServiceAreaServer.js +2 -2
  78. package/dist/esm/behaviors/service-area/ServiceAreaServer.js.map +1 -1
  79. package/dist/esm/behaviors/thermostat/AtomicWriteHandler.d.ts +58 -0
  80. package/dist/esm/behaviors/thermostat/AtomicWriteHandler.d.ts.map +1 -0
  81. package/dist/esm/behaviors/thermostat/AtomicWriteHandler.js +293 -0
  82. package/dist/esm/behaviors/thermostat/AtomicWriteHandler.js.map +6 -0
  83. package/dist/esm/behaviors/thermostat/AtomicWriteState.d.ts +33 -0
  84. package/dist/esm/behaviors/thermostat/AtomicWriteState.d.ts.map +1 -0
  85. package/dist/esm/behaviors/thermostat/AtomicWriteState.js +66 -0
  86. package/dist/esm/behaviors/thermostat/AtomicWriteState.js.map +6 -0
  87. package/dist/esm/behaviors/thermostat/ThermostatBehavior.d.ts +12 -0
  88. package/dist/esm/behaviors/thermostat/ThermostatBehavior.d.ts.map +1 -1
  89. package/dist/esm/behaviors/thermostat/ThermostatInterface.d.ts +1 -0
  90. package/dist/esm/behaviors/thermostat/ThermostatInterface.d.ts.map +1 -1
  91. package/dist/esm/behaviors/thermostat/ThermostatServer.d.ts +894 -3
  92. package/dist/esm/behaviors/thermostat/ThermostatServer.d.ts.map +1 -1
  93. package/dist/esm/behaviors/thermostat/ThermostatServer.js +1225 -1
  94. package/dist/esm/behaviors/thermostat/ThermostatServer.js.map +2 -2
  95. package/dist/esm/devices/water-heater.d.ts +24 -0
  96. package/dist/esm/devices/water-heater.d.ts.map +1 -1
  97. package/dist/esm/endpoint/Endpoint.d.ts +36 -2
  98. package/dist/esm/endpoint/Endpoint.d.ts.map +1 -1
  99. package/dist/esm/endpoint/Endpoint.js +17 -14
  100. package/dist/esm/endpoint/Endpoint.js.map +1 -1
  101. package/dist/esm/endpoint/properties/EndpointContainer.d.ts +1 -0
  102. package/dist/esm/endpoint/properties/EndpointContainer.d.ts.map +1 -1
  103. package/dist/esm/endpoint/properties/EndpointContainer.js +3 -0
  104. package/dist/esm/endpoint/properties/EndpointContainer.js.map +1 -1
  105. package/package.json +7 -7
  106. package/src/behavior/Behavior.ts +10 -0
  107. package/src/behavior/internal/BehaviorBacking.ts +2 -2
  108. package/src/behavior/state/managed/Datasource.ts +14 -7
  109. package/src/behavior/state/managed/ManagedReference.ts +67 -19
  110. package/src/behavior/state/managed/values/ListManager.ts +1 -0
  111. package/src/behavior/state/managed/values/StructManager.ts +13 -3
  112. package/src/behaviors/access-control/AccessControlServer.ts +3 -7
  113. package/src/behaviors/general-diagnostics/GeneralDiagnosticsServer.ts +5 -9
  114. package/src/behaviors/service-area/ServiceAreaServer.ts +2 -2
  115. package/src/behaviors/thermostat/AtomicWriteHandler.ts +412 -0
  116. package/src/behaviors/thermostat/AtomicWriteState.ts +91 -0
  117. package/src/behaviors/thermostat/ThermostatInterface.ts +2 -0
  118. package/src/behaviors/thermostat/ThermostatServer.ts +1487 -3
  119. package/src/endpoint/Endpoint.ts +61 -5
  120. package/src/endpoint/properties/EndpointContainer.ts +4 -0
@@ -3,10 +3,1234 @@
3
3
  * Copyright 2022-2025 Matter.js Authors
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { OccupancySensingServer } from "#behaviors/occupancy-sensing";
7
+ import { TemperatureMeasurementServer } from "#behaviors/temperature-measurement";
8
+ import { Thermostat } from "#clusters/thermostat";
9
+ import {
10
+ Bytes,
11
+ cropValueRange,
12
+ deepCopy,
13
+ Entropy,
14
+ ImplementationError,
15
+ InternalError,
16
+ Logger,
17
+ Observable
18
+ } from "#general";
19
+ import { FieldElement } from "#model";
20
+ import { hasLocalActor, Val } from "#protocol";
21
+ import { ClusterType, StatusResponse } from "#types";
22
+ import { AtomicWriteHandler } from "./AtomicWriteHandler.js";
6
23
  import { ThermostatBehavior } from "./ThermostatBehavior.js";
7
- class ThermostatServer extends ThermostatBehavior {
24
+ const logger = Logger.get("ThermostatServer");
25
+ const ThermostatBehaviorLogicBase = ThermostatBehavior.with(
26
+ Thermostat.Feature.Heating,
27
+ Thermostat.Feature.Cooling,
28
+ Thermostat.Feature.Occupancy,
29
+ Thermostat.Feature.AutoMode,
30
+ Thermostat.Feature.Presets
31
+ );
32
+ const schema = ThermostatBehaviorLogicBase.schema.extend({
33
+ children: [
34
+ FieldElement({
35
+ name: "PersistedPresets",
36
+ type: "list",
37
+ conformance: "[PRES]",
38
+ quality: "N",
39
+ children: [FieldElement({ name: "entry", type: "PresetStruct" })]
40
+ })
41
+ ]
42
+ });
43
+ class ThermostatBaseServer extends ThermostatBehaviorLogicBase {
44
+ static schema = schema;
45
+ async initialize() {
46
+ if (this.features.scheduleConfiguration) {
47
+ throw new ImplementationError("ScheduleConfiguration features is deprecated and not allowed to be enabled");
48
+ }
49
+ if (this.features.setback) {
50
+ throw new ImplementationError("Setback feature is deprecated and not allowed to be enabled");
51
+ }
52
+ if (this.features.matterScheduleConfiguration) {
53
+ logger.warn("MatterScheduleConfiguration feature is not yet implemented. Please do not activate it");
54
+ }
55
+ const options = this.endpoint.behaviors.optionsFor(ThermostatBaseServer);
56
+ if (this.features.presets && this.state.persistedPresets === void 0) {
57
+ this.state.persistedPresets = options?.presets ?? [];
58
+ }
59
+ if (this.state.minSetpointDeadBand > 127) {
60
+ this.state.minSetpointDeadBand = 20;
61
+ }
62
+ if (this.state.minSetpointDeadBand < 0 || this.state.minSetpointDeadBand > 127) {
63
+ throw new ImplementationError("minSetpointDeadBand is out of valid range 0..127");
64
+ }
65
+ this.#setupValidations();
66
+ this.#setupTemperatureMeasurementIntegration();
67
+ this.#setupOccupancyIntegration();
68
+ this.#setupModeHandling();
69
+ this.#setupThermostatLogic();
70
+ this.#setupPresets();
71
+ this.internal.minSetpointDeadBand = this.state.minSetpointDeadBand;
72
+ this.internal.controlSequenceOfOperation = this.state.controlSequenceOfOperation;
73
+ }
74
+ /**
75
+ * The default implementation of the SetpointRaiseLower command. It handles all validation and setpoint adjustments
76
+ * required by the Matter specification. This method only changes the Occupied setpoints.
77
+ */
78
+ setpointRaiseLower({ mode, amount }) {
79
+ if (mode === Thermostat.SetpointRaiseLowerMode.Heat && !this.features.heating) {
80
+ throw new StatusResponse.InvalidCommandError(
81
+ "Heating feature is not supported but Heat mode was requested"
82
+ );
83
+ }
84
+ if (mode === Thermostat.SetpointRaiseLowerMode.Cool && !this.features.cooling) {
85
+ throw new StatusResponse.InvalidCommandError(
86
+ "Cooling feature is not supported but Cool mode was requested"
87
+ );
88
+ }
89
+ amount *= 10;
90
+ if (mode === Thermostat.SetpointRaiseLowerMode.Both) {
91
+ if (this.features.heating && this.features.cooling) {
92
+ let desiredCoolingSetpoint = this.state.occupiedCoolingSetpoint + amount;
93
+ const coolLimit = desiredCoolingSetpoint - this.#clampSetpointToLimits("Cool", desiredCoolingSetpoint);
94
+ let desiredHeatingSetpoint = this.state.occupiedHeatingSetpoint + amount;
95
+ const heatLimit = desiredHeatingSetpoint - this.#clampSetpointToLimits("Heat", desiredHeatingSetpoint);
96
+ if (coolLimit !== 0 || heatLimit !== 0) {
97
+ if (Math.abs(coolLimit) <= Math.abs(heatLimit)) {
98
+ desiredHeatingSetpoint = desiredHeatingSetpoint - heatLimit;
99
+ desiredCoolingSetpoint = desiredCoolingSetpoint - heatLimit;
100
+ } else {
101
+ desiredHeatingSetpoint = desiredHeatingSetpoint - coolLimit;
102
+ desiredCoolingSetpoint = desiredCoolingSetpoint - coolLimit;
103
+ }
104
+ }
105
+ this.state.occupiedCoolingSetpoint = desiredCoolingSetpoint;
106
+ this.state.occupiedHeatingSetpoint = desiredHeatingSetpoint;
107
+ } else if (this.features.cooling) {
108
+ this.state.occupiedCoolingSetpoint = this.#clampSetpointToLimits(
109
+ "Cool",
110
+ this.state.occupiedCoolingSetpoint + amount
111
+ );
112
+ } else {
113
+ this.state.occupiedHeatingSetpoint = this.#clampSetpointToLimits(
114
+ "Heat",
115
+ this.state.occupiedHeatingSetpoint + amount
116
+ );
117
+ }
118
+ return;
119
+ }
120
+ if (mode === Thermostat.SetpointRaiseLowerMode.Cool) {
121
+ const desiredCoolingSetpoint = this.#clampSetpointToLimits(
122
+ "Cool",
123
+ this.state.occupiedCoolingSetpoint + amount
124
+ );
125
+ if (this.features.autoMode) {
126
+ let heatingSetpoint = this.state.occupiedHeatingSetpoint;
127
+ if (desiredCoolingSetpoint - heatingSetpoint < this.setpointDeadBand) {
128
+ heatingSetpoint = desiredCoolingSetpoint - this.setpointDeadBand;
129
+ if (heatingSetpoint === this.#clampSetpointToLimits("Heat", heatingSetpoint)) {
130
+ this.state.occupiedHeatingSetpoint = heatingSetpoint;
131
+ } else {
132
+ throw new StatusResponse.InvalidCommandError(
133
+ "Could Not adjust heating setpoint to maintain dead band!"
134
+ );
135
+ }
136
+ }
137
+ }
138
+ this.state.occupiedCoolingSetpoint = desiredCoolingSetpoint;
139
+ return;
140
+ }
141
+ if (mode === Thermostat.SetpointRaiseLowerMode.Heat) {
142
+ const desiredHeatingSetpoint = this.#clampSetpointToLimits(
143
+ "Heat",
144
+ this.state.occupiedHeatingSetpoint + amount
145
+ );
146
+ if (this.features.autoMode) {
147
+ let coolingSetpoint = this.state.occupiedCoolingSetpoint;
148
+ if (coolingSetpoint - desiredHeatingSetpoint < this.setpointDeadBand) {
149
+ coolingSetpoint = desiredHeatingSetpoint + this.setpointDeadBand;
150
+ if (coolingSetpoint === this.#clampSetpointToLimits("Cool", coolingSetpoint)) {
151
+ this.state.occupiedCoolingSetpoint = coolingSetpoint;
152
+ } else {
153
+ throw new StatusResponse.InvalidCommandError(
154
+ "Could Not adjust cooling setpoint to maintain dead band!"
155
+ );
156
+ }
157
+ }
158
+ }
159
+ this.state.occupiedHeatingSetpoint = desiredHeatingSetpoint;
160
+ return;
161
+ }
162
+ throw new StatusResponse.InvalidCommandError(`Unsupported SetpointRaiseLowerMode ${mode}`);
163
+ }
164
+ /**
165
+ * Performs basic validation and sets the active preset handle when valid.
166
+ * This fulfills the basic requirements of the SetActivePresetRequest matter command. Use this method if you need
167
+ * to override setActivePresetRequest to ensure compliance.
168
+ */
169
+ handleSetActivePresetRequest({ presetHandle }) {
170
+ let preset = void 0;
171
+ if (presetHandle !== null) {
172
+ preset = this.state.persistedPresets?.find(
173
+ (p) => p.presetHandle !== null && Bytes.areEqual(p.presetHandle, presetHandle)
174
+ );
175
+ if (preset === void 0) {
176
+ throw new StatusResponse.InvalidCommandError("Requested PresetHandle not found");
177
+ }
178
+ }
179
+ logger.info(`Setting active preset handle to`, presetHandle);
180
+ this.state.activePresetHandle = presetHandle;
181
+ return preset;
182
+ }
183
+ /**
184
+ * This default implementation of the SetActivePresetRequest command handler sets the active preset and
185
+ * (additionally to specification requirements!) adjusts the occupied setpoints to the preset values if defined.
186
+ *
187
+ * If you do not want this behavior, you can override this method but should call handleSetActivePresetRequest to
188
+ * ensure compliance with the specification.
189
+ */
190
+ setActivePresetRequest({ presetHandle }) {
191
+ const preset = this.handleSetActivePresetRequest({ presetHandle });
192
+ if (preset !== void 0) {
193
+ const { heatingSetpoint, coolingSetpoint } = preset;
194
+ if (this.features.heating && heatingSetpoint !== null && heatingSetpoint !== void 0) {
195
+ this.state.occupiedHeatingSetpoint = this.#clampSetpointToLimits("Heat", heatingSetpoint);
196
+ }
197
+ if (this.features.cooling && coolingSetpoint !== null && coolingSetpoint !== void 0) {
198
+ this.state.occupiedCoolingSetpoint = this.#clampSetpointToLimits("Cool", coolingSetpoint);
199
+ }
200
+ }
201
+ }
202
+ /** Determines if the given context is from a command */
203
+ #isCommandContext(context) {
204
+ return "command" in context && context.command;
205
+ }
206
+ /**
207
+ * Whether the thermostat is currently considered occupied
208
+ * Uses the occupancy state if the feature is supported, otherwise always true
209
+ */
210
+ get occupied() {
211
+ return this.features.occupancy ? this.state.occupancy?.occupied ?? true : true;
212
+ }
213
+ /** The current heating setpoint depending on occupancy */
214
+ get heatingSetpoint() {
215
+ if (this.occupied) {
216
+ return this.state.occupiedHeatingSetpoint;
217
+ }
218
+ return this.state.unoccupiedHeatingSetpoint;
219
+ }
220
+ /** The current cooling setpoint depending on occupancy */
221
+ get coolingSetpoint() {
222
+ if (this.occupied) {
223
+ return this.state.occupiedCoolingSetpoint;
224
+ }
225
+ return this.state.unoccupiedCoolingSetpoint;
226
+ }
227
+ /** Setup basic Thermostat state and logic */
228
+ #setupThermostatLogic() {
229
+ if (this.state.temperatureSetpointHold !== void 0) {
230
+ if (this.state.temperatureSetpointHoldDuration === void 0) {
231
+ this.state.temperatureSetpointHoldDuration = null;
232
+ }
233
+ if (this.state.setpointHoldExpiryTimestamp === void 0) {
234
+ } else {
235
+ logger.warn(
236
+ "Handling for setpointHoldExpiryTimestamp is not yet implemented. To use this attribute you need to install the needed logic yourself"
237
+ );
238
+ }
239
+ }
240
+ }
241
+ // TODO Add when we adjusted the epoch-s handling to be correct
242
+ /*#handleTemperatureSetpointHoldChange(newValue: Thermostat.TemperatureSetpointHold) {
243
+ if (newValue === Thermostat.TemperatureSetpointHold.SetpointHoldOn) {
244
+ if (
245
+ this.state.temperatureSetpointHoldDuration !== null &&
246
+ this.state.temperatureSetpointHoldDuration! > 0
247
+ ) {
248
+ // TODO: convert to use of Seconds and such and real UTC time
249
+ // Also requires adjustment in encoding/decoding of the attribute
250
+ const nowUtc = Time.nowMs - 946_684_800_000; // Still not really UTC, but ok for now
251
+ this.state.setpointHoldExpiryTimestamp = Math.floor(
252
+ nowUtc / 1000 + this.state.temperatureSetpointHoldDuration! * 60,
253
+ );
254
+ }
255
+ } else {
256
+ this.state.setpointHoldExpiryTimestamp = null;
257
+ }
258
+ }*/
259
+ /** Whether heating is allowed in the current ControlSequenceOfOperation and features */
260
+ get heatingAllowed() {
261
+ return this.features.heating && ![
262
+ Thermostat.ControlSequenceOfOperation.CoolingOnly,
263
+ Thermostat.ControlSequenceOfOperation.CoolingAndHeatingWithReheat
264
+ ].includes(this.internal.controlSequenceOfOperation);
265
+ }
266
+ /** Whether cooling is allowed in the current ControlSequenceOfOperation and features */
267
+ get coolingAllowed() {
268
+ return this.features.cooling && ![
269
+ Thermostat.ControlSequenceOfOperation.HeatingOnly,
270
+ Thermostat.ControlSequenceOfOperation.HeatingWithReheat
271
+ ].includes(this.internal.controlSequenceOfOperation);
272
+ }
273
+ /**
274
+ * Adjust the running mode of the thermostat based on the new system mode when the thermostatRunningMode is supported
275
+ */
276
+ adjustRunningMode(newState) {
277
+ if (this.state.thermostatRunningMode === void 0) {
278
+ return;
279
+ }
280
+ switch (newState) {
281
+ case Thermostat.ThermostatRunningMode.Heat:
282
+ if (!this.heatingAllowed) {
283
+ throw new ImplementationError("Heating is not allowed in the current ControlSequenceOfOperation");
284
+ }
285
+ break;
286
+ case Thermostat.ThermostatRunningMode.Cool:
287
+ if (!this.coolingAllowed) {
288
+ throw new ImplementationError("Cooling is not allowed in the current ControlSequenceOfOperation");
289
+ }
290
+ break;
291
+ }
292
+ this.state.thermostatRunningMode = newState;
293
+ }
294
+ /**
295
+ * Setup integration with TemperatureMeasurement cluster or external temperature state and intialize internal
296
+ * localTemperature state.
297
+ */
298
+ #setupTemperatureMeasurementIntegration() {
299
+ const preferRemoteTemperature = !!this.state.remoteSensing?.localTemperature;
300
+ if (this.features.localTemperatureNotExposed) {
301
+ if (preferRemoteTemperature) {
302
+ throw new ImplementationError(
303
+ "RemoteSensing cannot be set to LocalTemperature when LocalTemperatureNotExposed feature is enabled"
304
+ );
305
+ }
306
+ logger.debug("LocalTemperatureNotExposed feature is enabled, ignoring local temperature measurement");
307
+ this.state.localTemperature = null;
308
+ }
309
+ let localTemperature = null;
310
+ if (!preferRemoteTemperature && this.agent.has(TemperatureMeasurementServer)) {
311
+ logger.debug(
312
+ "Using existing TemperatureMeasurement cluster on same endpoint for local temperature measurement"
313
+ );
314
+ if (this.state.externalMeasuredIndoorTemperature !== void 0) {
315
+ logger.warn(
316
+ "Both local TemperatureMeasurement cluster and externalMeasuredIndoorTemperature state are set, using local cluster"
317
+ );
318
+ }
319
+ this.reactTo(
320
+ this.agent.get(TemperatureMeasurementServer).events.measuredValue$Changed,
321
+ this.#handleMeasuredTemperatureChange
322
+ );
323
+ localTemperature = this.endpoint.stateOf(TemperatureMeasurementServer).measuredValue;
324
+ } else {
325
+ if (this.state.externalMeasuredIndoorTemperature === void 0) {
326
+ logger.warn(
327
+ "No local TemperatureMeasurement cluster available and externalMeasuredIndoorTemperature state not set. Setting localTemperature to null"
328
+ );
329
+ } else {
330
+ logger.info("Using measured temperature via externalMeasuredIndoorTemperature state");
331
+ localTemperature = this.state.externalMeasuredIndoorTemperature ?? null;
332
+ }
333
+ this.reactTo(this.events.externalMeasuredIndoorTemperature$Changed, this.#handleMeasuredTemperatureChange);
334
+ }
335
+ this.#handleMeasuredTemperatureChange(localTemperature);
336
+ }
337
+ /**
338
+ * Handles changes to the measured temperature, applies calibration and update internal and official state.
339
+ */
340
+ #handleMeasuredTemperatureChange(temperature) {
341
+ if (temperature !== null && this.state.localTemperatureCalibration !== void 0) {
342
+ temperature += this.state.localTemperatureCalibration * 10;
343
+ }
344
+ if (!this.features.localTemperatureNotExposed) {
345
+ this.state.localTemperature = temperature;
346
+ }
347
+ const oldTemperature = this.internal.localTemperature;
348
+ if (temperature !== null && oldTemperature !== temperature) {
349
+ this.internal.localTemperature = temperature;
350
+ this.events.calibratedTemperature$Changed.emit(temperature, oldTemperature, this.context);
351
+ }
352
+ }
353
+ /**
354
+ * Setup integration with OccupancySensing cluster or external occupancy state and initialize internal occupancy
355
+ * state.
356
+ */
357
+ #setupOccupancyIntegration() {
358
+ if (!this.features.occupancy) {
359
+ return;
360
+ }
361
+ let currentOccupancy;
362
+ const preferRemoteOccupancy = !!this.state.remoteSensing?.occupancy;
363
+ if (!preferRemoteOccupancy && this.agent.has(OccupancySensingServer)) {
364
+ logger.debug("Using existing OccupancySensing cluster on same endpoint for local occupancy sensing");
365
+ if (this.state.externallyMeasuredOccupancy !== void 0) {
366
+ logger.warn(
367
+ "Both local OccupancySensing cluster and externallyMeasuredOccupancy state are set, using local cluster"
368
+ );
369
+ }
370
+ this.reactTo(this.agent.get(OccupancySensingServer).events.occupancy$Changed, this.#handleOccupancyChange);
371
+ currentOccupancy = !!this.endpoint.stateOf(OccupancySensingServer).occupancy.occupied;
372
+ } else {
373
+ if (this.state.externallyMeasuredOccupancy === void 0) {
374
+ currentOccupancy = true;
375
+ logger.warn(
376
+ "No local OccupancySensing cluster available and externallyMeasuredOccupancy state not set"
377
+ );
378
+ } else {
379
+ logger.info("Using occupancy via externallyMeasuredOccupancy state");
380
+ currentOccupancy = this.state.externallyMeasuredOccupancy;
381
+ }
382
+ this.reactTo(this.events.externallyMeasuredOccupancy$Changed, this.#handleExternalOccupancyChange);
383
+ }
384
+ this.#handleExternalOccupancyChange(currentOccupancy);
385
+ }
386
+ #handleExternalOccupancyChange(newValue) {
387
+ this.state.occupancy = { occupied: newValue };
388
+ }
389
+ #handleOccupancyChange(newValue) {
390
+ this.state.occupancy = newValue;
391
+ }
392
+ /** Setup all validations for the Thermostat behavior */
393
+ #setupValidations() {
394
+ this.#assertUserSetpointLimits("HeatSetpointLimit");
395
+ this.#assertUserSetpointLimits("CoolSetpointLimit");
396
+ this.#clampSetpointToLimits("Heat", this.state.occupiedHeatingSetpoint);
397
+ this.#clampSetpointToLimits("Heat", this.state.unoccupiedHeatingSetpoint);
398
+ this.#clampSetpointToLimits("Cool", this.state.occupiedCoolingSetpoint);
399
+ this.#clampSetpointToLimits("Cool", this.state.unoccupiedCoolingSetpoint);
400
+ this.maybeReactTo(this.events.absMinHeatSetpointLimit$Changing, this.#assertAbsMinHeatSetpointLimitChanging);
401
+ this.maybeReactTo(this.events.minHeatSetpointLimit$Changing, this.#assertMinHeatSetpointLimitChanging);
402
+ this.maybeReactTo(this.events.maxHeatSetpointLimit$Changing, this.#assertMaxHeatSetpointLimitChanging);
403
+ this.maybeReactTo(this.events.absMaxHeatSetpointLimit$Changing, this.#assertAbsMaxHeatSetpointLimitChanging);
404
+ this.maybeReactTo(this.events.absMinCoolSetpointLimit$Changing, this.#assertAbsMinCoolSetpointLimitChanging);
405
+ this.maybeReactTo(this.events.minCoolSetpointLimit$Changing, this.#assertMinCoolSetpointLimitChanging);
406
+ this.maybeReactTo(this.events.maxCoolSetpointLimit$Changing, this.#assertMaxCoolSetpointLimitChanging);
407
+ this.maybeReactTo(this.events.absMaxCoolSetpointLimit$Changing, this.#assertAbsMaxCoolSetpointLimitChanging);
408
+ this.maybeReactTo(this.events.occupiedHeatingSetpoint$Changing, this.#assertOccupiedHeatingSetpointChanging);
409
+ this.maybeReactTo(
410
+ this.events.unoccupiedHeatingSetpoint$Changing,
411
+ this.#assertUnoccupiedHeatingSetpointChanging
412
+ );
413
+ this.maybeReactTo(this.events.occupiedCoolingSetpoint$Changing, this.#assertOccupiedCoolingSetpointChanging);
414
+ this.maybeReactTo(
415
+ this.events.unoccupiedCoolingSetpoint$Changing,
416
+ this.#assertUnoccupiedCoolingSetpointChanging
417
+ );
418
+ this.maybeReactTo(this.events.remoteSensing$Changing, this.#assertRemoteSensingChanging);
419
+ this.maybeReactTo(this.events.minSetpointDeadBand$Changing, this.#ensureMinSetpointDeadBandNotWritable);
420
+ this.reactTo(
421
+ this.events.controlSequenceOfOperation$Changing,
422
+ this.#ensureControlSequenceOfOperationNotWritable
423
+ );
424
+ this.reactTo(this.events.systemMode$Changing, this.#assertSystemModeChanging);
425
+ this.maybeReactTo(this.events.thermostatRunningMode$Changing, this.#assertThermostatRunningModeChanging);
426
+ }
427
+ #assertThermostatRunningModeChanging(newRunningMode) {
428
+ const forbiddenRunningModes = new Array();
429
+ switch (this.internal.controlSequenceOfOperation) {
430
+ case Thermostat.ControlSequenceOfOperation.CoolingOnly:
431
+ case Thermostat.ControlSequenceOfOperation.CoolingAndHeatingWithReheat:
432
+ forbiddenRunningModes.push(Thermostat.ThermostatRunningMode.Heat);
433
+ break;
434
+ case Thermostat.ControlSequenceOfOperation.HeatingOnly:
435
+ case Thermostat.ControlSequenceOfOperation.HeatingWithReheat:
436
+ forbiddenRunningModes.push(Thermostat.ThermostatRunningMode.Cool);
437
+ break;
438
+ }
439
+ if (forbiddenRunningModes.includes(newRunningMode)) {
440
+ throw new StatusResponse.ConstraintErrorError(
441
+ `ThermostatRunningMode ${Thermostat.ThermostatRunningMode[newRunningMode]} is not allowed with ControlSequenceOfOperation ${Thermostat.ControlSequenceOfOperation[this.internal.controlSequenceOfOperation]}`
442
+ );
443
+ }
444
+ }
445
+ #assertSystemModeChanging(newMode) {
446
+ const forbiddenModes = new Array();
447
+ switch (this.internal.controlSequenceOfOperation) {
448
+ case Thermostat.ControlSequenceOfOperation.CoolingOnly:
449
+ case Thermostat.ControlSequenceOfOperation.CoolingAndHeatingWithReheat:
450
+ forbiddenModes.push(Thermostat.SystemMode.Heat, Thermostat.SystemMode.EmergencyHeat);
451
+ break;
452
+ case Thermostat.ControlSequenceOfOperation.HeatingOnly:
453
+ case Thermostat.ControlSequenceOfOperation.HeatingWithReheat:
454
+ forbiddenModes.push(Thermostat.SystemMode.Cool, Thermostat.SystemMode.Precooling);
455
+ break;
456
+ }
457
+ if (forbiddenModes.includes(newMode)) {
458
+ throw new StatusResponse.ConstraintErrorError(
459
+ `SystemMode ${Thermostat.SystemMode[newMode]} is not allowed with ControlSequenceOfOperation ${Thermostat.ControlSequenceOfOperation[this.internal.controlSequenceOfOperation]}`
460
+ );
461
+ }
462
+ }
463
+ /** Attribute is not writable, revert any changes */
464
+ #ensureControlSequenceOfOperationNotWritable() {
465
+ this.state.controlSequenceOfOperation = this.internal.controlSequenceOfOperation;
466
+ }
467
+ /** Attribute is not writable, revert any changes, but also ensure proper errors when write try was invalid */
468
+ #ensureMinSetpointDeadBandNotWritable(value) {
469
+ if (value < 0 || value > 127) {
470
+ throw new StatusResponse.ConstraintErrorError("MinSetpointDeadBand is out of valid range 0..127");
471
+ }
472
+ this.state.minSetpointDeadBand = this.internal.minSetpointDeadBand;
473
+ }
474
+ #assertRemoteSensingChanging(remoteSensing) {
475
+ if (this.features.localTemperatureNotExposed && remoteSensing.localTemperature) {
476
+ throw new StatusResponse.ConstraintErrorError(
477
+ "LocalTemperature is not exposed, so RemoteSensing cannot be set to LocalTemperature"
478
+ );
479
+ }
480
+ }
481
+ #assertUnoccupiedCoolingSetpointChanging(setpoint, _old, context) {
482
+ this.#assertSetpointWithinLimits("Cool", "Unoccupied", setpoint);
483
+ this.#assertSetpointDeadband("Cooling", setpoint);
484
+ if (!this.#isCommandContext(context)) {
485
+ this.#ensureSetpointDeadband("Cooling", "unoccupied", setpoint);
486
+ if (this.features.presets && this.state.activePresetHandle !== null && !this.occupied) {
487
+ this.agent.asLocalActor(() => {
488
+ this.state.activePresetHandle = null;
489
+ });
490
+ }
491
+ }
492
+ }
493
+ #assertUnoccupiedHeatingSetpointChanging(setpoint, _old, context) {
494
+ this.#assertSetpointWithinLimits("Heat", "Unoccupied", setpoint);
495
+ this.#assertSetpointDeadband("Heating", setpoint);
496
+ if (!this.#isCommandContext(context)) {
497
+ this.#ensureSetpointDeadband("Heating", "unoccupied", setpoint);
498
+ if (this.features.presets && this.state.activePresetHandle !== null && !this.occupied) {
499
+ this.agent.asLocalActor(() => {
500
+ this.state.activePresetHandle = null;
501
+ });
502
+ }
503
+ }
504
+ }
505
+ #assertAbsMaxCoolSetpointLimitChanging(absMax) {
506
+ this.#assertUserSetpointLimits("CoolSetpointLimit", { absMax });
507
+ }
508
+ #assertMaxCoolSetpointLimitChanging(max) {
509
+ this.#assertUserSetpointLimits("CoolSetpointLimit", { max });
510
+ if (this.features.autoMode) {
511
+ if (max < this.heatSetpointMaximum + this.setpointDeadBand) {
512
+ throw new StatusResponse.ConstraintErrorError(
513
+ `maxCoolSetpointLimit (${max}) must be greater than or equal to maxHeatSetpointLimit (${this.heatSetpointMaximum}) plus minSetpointDeadBand (${this.setpointDeadBand})`
514
+ );
515
+ }
516
+ }
517
+ }
518
+ #assertMinCoolSetpointLimitChanging(min) {
519
+ this.#assertUserSetpointLimits("CoolSetpointLimit", { min });
520
+ if (this.features.autoMode) {
521
+ if (min < this.heatSetpointMinimum + this.setpointDeadBand) {
522
+ throw new StatusResponse.ConstraintErrorError(
523
+ `minCoolSetpointLimit (${min}) must be greater than or equal to minHeatSetpointLimit (${this.heatSetpointMinimum}) plus minSetpointDeadBand (${this.setpointDeadBand})`
524
+ );
525
+ }
526
+ }
527
+ }
528
+ #assertAbsMinCoolSetpointLimitChanging(absMin) {
529
+ this.#assertUserSetpointLimits("CoolSetpointLimit", { absMin });
530
+ }
531
+ #assertAbsMaxHeatSetpointLimitChanging(absMax) {
532
+ this.#assertUserSetpointLimits("HeatSetpointLimit", { absMax });
533
+ }
534
+ #assertMaxHeatSetpointLimitChanging(max) {
535
+ this.#assertUserSetpointLimits("HeatSetpointLimit", { max });
536
+ if (this.features.autoMode) {
537
+ if (max > this.coolSetpointMaximum - this.setpointDeadBand) {
538
+ throw new StatusResponse.ConstraintErrorError(
539
+ `maxHeatSetpointLimit (${max}) must be less than or equal to maxCoolSetpointLimit (${this.coolSetpointMaximum}) minus minSetpointDeadBand (${this.setpointDeadBand})`
540
+ );
541
+ }
542
+ }
543
+ }
544
+ #assertMinHeatSetpointLimitChanging(min) {
545
+ this.#assertUserSetpointLimits("HeatSetpointLimit", { min });
546
+ if (this.features.autoMode) {
547
+ if (min > this.coolSetpointMinimum - this.setpointDeadBand) {
548
+ throw new StatusResponse.ConstraintErrorError(
549
+ `minHeatSetpointLimit (${min}) must be less than or equal to minCoolSetpointLimit (${this.state.minCoolSetpointLimit}) minus minSetpointDeadBand (${this.setpointDeadBand})`
550
+ );
551
+ }
552
+ }
553
+ }
554
+ #assertAbsMinHeatSetpointLimitChanging(absMin) {
555
+ this.#assertUserSetpointLimits("HeatSetpointLimit", { absMin });
556
+ }
557
+ #assertOccupiedCoolingSetpointChanging(setpoint, _old, context) {
558
+ this.#assertSetpointWithinLimits("Cool", "Occupied", setpoint);
559
+ this.#assertSetpointDeadband("Cooling", setpoint);
560
+ if (!this.#isCommandContext(context)) {
561
+ this.#ensureSetpointDeadband("Cooling", "occupied", setpoint);
562
+ if (this.features.presets && this.state.activePresetHandle !== null && this.occupied) {
563
+ this.agent.asLocalActor(() => {
564
+ this.state.activePresetHandle = null;
565
+ });
566
+ }
567
+ }
568
+ }
569
+ #assertOccupiedHeatingSetpointChanging(setpoint, _old, context) {
570
+ this.#assertSetpointWithinLimits("Heat", "Occupied", setpoint);
571
+ this.#assertSetpointDeadband("Heating", setpoint);
572
+ if (!this.#isCommandContext(context)) {
573
+ this.#ensureSetpointDeadband("Heating", "occupied", setpoint);
574
+ if (this.features.presets && this.state.activePresetHandle !== null && this.occupied) {
575
+ this.agent.asLocalActor(() => {
576
+ this.state.activePresetHandle = null;
577
+ });
578
+ }
579
+ }
580
+ }
581
+ /**
582
+ * The current mode the thermostat is considered to be in based on local temperature and setpoints
583
+ */
584
+ get temperatureConsideration() {
585
+ const localTemp = this.internal.localTemperature;
586
+ if (localTemp === null) {
587
+ return void 0;
588
+ }
589
+ const minSetPointDeadband = this.setpointDeadBand;
590
+ const heatingSetpoint = this.heatingSetpoint;
591
+ const coolingSetpoint = this.coolingSetpoint;
592
+ switch (this.state.systemMode) {
593
+ case Thermostat.SystemMode.Heat:
594
+ if (localTemp < heatingSetpoint) {
595
+ return "belowTarget";
596
+ }
597
+ if (localTemp > coolingSetpoint) {
598
+ return "onTarget";
599
+ }
600
+ break;
601
+ case Thermostat.SystemMode.Cool:
602
+ if (localTemp < heatingSetpoint) {
603
+ return "onTarget";
604
+ }
605
+ if (localTemp > coolingSetpoint) {
606
+ return "aboveTarget";
607
+ }
608
+ break;
609
+ case Thermostat.SystemMode.Auto:
610
+ if (localTemp < heatingSetpoint - minSetPointDeadband) {
611
+ return "belowTarget";
612
+ }
613
+ if (localTemp > coolingSetpoint + minSetPointDeadband) {
614
+ return "aboveTarget";
615
+ }
616
+ break;
617
+ }
618
+ return "onTarget";
619
+ }
620
+ get #heatDefaults() {
621
+ return {
622
+ absMin: 700,
623
+ absMax: 3e3
624
+ };
625
+ }
626
+ get #coolDefaults() {
627
+ return {
628
+ absMin: 1600,
629
+ absMax: 3200
630
+ };
631
+ }
632
+ /**
633
+ * Used to validate generically that user configurable limits must be within device limits follow:
634
+ * * AbsMinHeatSetpointLimit <= MinHeatSetpointLimit <= MaxHeatSetpointLimit <= AbsMaxHeatSetpointLimit
635
+ * * AbsMinCoolSetpointLimit <= MinCoolSetpointLimit <= MaxCoolSetpointLimit <= AbsMaxCoolSetpointLimit
636
+ * Values not provided are taken from the state
637
+ */
638
+ #assertUserSetpointLimits(scope, details = {}) {
639
+ const defaults = scope === "HeatSetpointLimit" ? this.#heatDefaults : this.#coolDefaults;
640
+ const {
641
+ absMin = this.state[`absMin${scope}`] ?? defaults.absMin,
642
+ min = this.state[`min${scope}`] ?? defaults.absMin,
643
+ max = this.state[`max${scope}`] ?? defaults.absMax,
644
+ absMax = this.state[`absMax${scope}`] ?? defaults.absMax
645
+ } = details;
646
+ logger.debug(
647
+ `Validating user setpoint limits for ${scope}: absMin=${absMin}, min=${min}, max=${max}, absMax=${absMax}`
648
+ );
649
+ if (absMin > min) {
650
+ throw new StatusResponse.ConstraintErrorError(
651
+ `absMin${scope} (${absMin}) must be less than or equal to min${scope} (${min})`
652
+ );
653
+ }
654
+ if (min > max) {
655
+ throw new StatusResponse.ConstraintErrorError(
656
+ `min${scope} (${min}) must be less than or equal to max${scope} (${max})`
657
+ );
658
+ }
659
+ if (max > absMax) {
660
+ throw new StatusResponse.ConstraintErrorError(
661
+ `max${scope} (${max}) must be less than or equal to absMax${scope} (${absMax})`
662
+ );
663
+ }
664
+ }
665
+ get heatSetpointMinimum() {
666
+ const absMin = this.state.absMinHeatSetpointLimit ?? this.#heatDefaults.absMin;
667
+ const min = this.state.minHeatSetpointLimit ?? this.#heatDefaults.absMin;
668
+ return Math.max(min, absMin);
669
+ }
670
+ get heatSetpointMaximum() {
671
+ const absMax = this.state.absMaxHeatSetpointLimit ?? this.#heatDefaults.absMax;
672
+ const max = this.state.maxHeatSetpointLimit ?? this.#heatDefaults.absMax;
673
+ return Math.min(max, absMax);
674
+ }
675
+ get coolSetpointMinimum() {
676
+ const absMin = this.state.absMinCoolSetpointLimit ?? this.#coolDefaults.absMin;
677
+ const min = this.state.minCoolSetpointLimit ?? this.#coolDefaults.absMin;
678
+ return Math.max(min, absMin);
679
+ }
680
+ get coolSetpointMaximum() {
681
+ const absMax = this.state.absMaxCoolSetpointLimit ?? this.#coolDefaults.absMax;
682
+ const max = this.state.maxCoolSetpointLimit ?? this.#coolDefaults.absMax;
683
+ return Math.min(max, absMax);
684
+ }
685
+ get setpointDeadBand() {
686
+ return this.features.autoMode ? this.internal.minSetpointDeadBand * 10 : 0;
687
+ }
688
+ #clampSetpointToLimits(scope, setpoint) {
689
+ const limitMin = scope === "Heat" ? this.heatSetpointMinimum : this.coolSetpointMinimum;
690
+ const limitMax = scope === "Heat" ? this.heatSetpointMaximum : this.coolSetpointMaximum;
691
+ const result = cropValueRange(setpoint, limitMin, limitMax);
692
+ if (result !== setpoint) {
693
+ logger.debug(
694
+ `${scope} setpoint (${setpoint}) is out of limits [${limitMin}, ${limitMax}], clamping to ${result}`
695
+ );
696
+ }
697
+ return result;
698
+ }
699
+ /**
700
+ * Used to validate that Setpoints must be within user configurable limits
701
+ */
702
+ #assertSetpointWithinLimits(scope, type, setpoint) {
703
+ const limitMin = scope === "Heat" ? this.heatSetpointMinimum : this.coolSetpointMinimum;
704
+ const limitMax = scope === "Heat" ? this.heatSetpointMaximum : this.coolSetpointMaximum;
705
+ if (limitMin !== void 0 && setpoint < limitMin) {
706
+ throw new StatusResponse.ConstraintErrorError(
707
+ `${scope}${type}Setpoint (${setpoint}) must be greater than or equal to min${scope}SetpointLimit (${limitMin})`
708
+ );
709
+ }
710
+ if (limitMax !== void 0 && setpoint > limitMax) {
711
+ throw new StatusResponse.ConstraintErrorError(
712
+ `${scope}${type}Setpoint (${setpoint}) must be less than or equal to max${scope}SetpointLimit (${limitMax})`
713
+ );
714
+ }
715
+ }
716
+ /**
717
+ * Attempts to ensure that a change to the heating/cooling setpoint maintains the deadband with the cooling/heating
718
+ * setpoint by adjusting the cooling setpoint
719
+ */
720
+ #ensureSetpointDeadband(scope, type, value) {
721
+ if (!this.features.autoMode) {
722
+ return;
723
+ }
724
+ const otherType = scope === "Heating" ? "Cooling" : "Heating";
725
+ const deadband = this.setpointDeadBand;
726
+ const otherSetpoint = otherType === "Heating" ? this.heatingSetpoint : this.coolingSetpoint;
727
+ const otherLimit = otherType === "Heating" ? this.heatSetpointMinimum : this.coolSetpointMaximum;
728
+ if (otherType === "Cooling") {
729
+ const minValidSetpoint = value + deadband;
730
+ logger.debug(
731
+ `Ensuring deadband for ${type}${otherType}Setpoint, min valid setpoint is ${minValidSetpoint}`
732
+ );
733
+ if (otherSetpoint >= minValidSetpoint) {
734
+ return;
735
+ }
736
+ if (minValidSetpoint > otherLimit) {
737
+ throw new StatusResponse.ConstraintErrorError(
738
+ `Cannot adjust cooling setpoint to maintain deadband, would exceed max cooling setpoint (${otherLimit})`
739
+ );
740
+ }
741
+ logger.debug(`Adjusting ${type}${otherType}Setpoint to ${minValidSetpoint} to maintain deadband`);
742
+ this.state[`${type}${otherType}Setpoint`] = minValidSetpoint;
743
+ } else {
744
+ const maxValidSetpoint = value - deadband;
745
+ logger.debug(
746
+ `Ensuring deadband for ${type}${otherType}Setpoint, max valid setpoint is ${maxValidSetpoint}`
747
+ );
748
+ if (otherSetpoint <= maxValidSetpoint) {
749
+ return;
750
+ }
751
+ if (maxValidSetpoint < otherLimit) {
752
+ throw new StatusResponse.ConstraintErrorError(
753
+ `Cannot adjust heating setpoint to maintain deadband, would exceed min heating setpoint (${otherLimit})`
754
+ );
755
+ }
756
+ logger.debug(`Adjusting ${type}${otherType}Setpoint to ${maxValidSetpoint} to maintain deadband`);
757
+ this.state[`${type}${otherType}Setpoint`] = maxValidSetpoint;
758
+ }
759
+ }
760
+ /**
761
+ * Checks to see if it's possible to adjust the heating/cooling setpoint to preserve a given deadband if the
762
+ * cooling/heating setpoint is changed
763
+ */
764
+ #assertSetpointDeadband(type, value) {
765
+ if (!this.features.autoMode) {
766
+ return;
767
+ }
768
+ const deadband = this.setpointDeadBand;
769
+ const otherValue = type === "Heating" ? this.coolSetpointMaximum : this.heatSetpointMinimum;
770
+ if (type === "Heating" && value + deadband > otherValue) {
771
+ throw new StatusResponse.ConstraintErrorError(
772
+ `HeatingSetpoint (${value}) plus deadband (${deadband}) exceeds CoolingSetpoint (${otherValue})`
773
+ );
774
+ } else if (type === "Cooling" && value - deadband < otherValue) {
775
+ throw new StatusResponse.ConstraintErrorError(
776
+ `CoolingSetpoint (${value}) minus deadband (${deadband}) is less than HeatingSetpoint (${otherValue})`
777
+ );
778
+ }
779
+ }
780
+ #setupModeHandling() {
781
+ this.reactTo(this.events.systemMode$Changed, this.#handleSystemModeChange);
782
+ this.maybeReactTo(this.events.thermostatRunningMode$Changed, this.#handleThermostatRunningModeChange);
783
+ if (this.state.useAutomaticModeManagement && this.state.thermostatRunningMode !== void 0) {
784
+ this.reactTo(this.events.calibratedTemperature$Changed, this.#handleTemperatureChangeForMode);
785
+ this.#handleTemperatureChangeForMode(this.internal.localTemperature);
786
+ }
787
+ }
788
+ #handleSystemModeChange(newMode) {
789
+ if (this.state.thermostatRunningMode !== void 0 && newMode !== Thermostat.SystemMode.Auto) {
790
+ if (newMode === Thermostat.SystemMode.Off) {
791
+ this.state.thermostatRunningMode = Thermostat.ThermostatRunningMode.Off;
792
+ } else if (newMode === Thermostat.SystemMode.Heat) {
793
+ this.state.thermostatRunningMode = Thermostat.ThermostatRunningMode.Heat;
794
+ } else if (newMode === Thermostat.SystemMode.Cool) {
795
+ this.state.thermostatRunningMode = Thermostat.ThermostatRunningMode.Cool;
796
+ }
797
+ }
798
+ }
799
+ #handleThermostatRunningModeChange(newRunningMode) {
800
+ if (this.state.piCoolingDemand !== void 0) {
801
+ if (newRunningMode === Thermostat.ThermostatRunningMode.Off || newRunningMode === Thermostat.ThermostatRunningMode.Heat) {
802
+ this.state.piCoolingDemand = 0;
803
+ }
804
+ }
805
+ if (this.state.piHeatingDemand !== void 0) {
806
+ if (newRunningMode === Thermostat.ThermostatRunningMode.Off || newRunningMode === Thermostat.ThermostatRunningMode.Cool) {
807
+ this.state.piHeatingDemand = 0;
808
+ }
809
+ }
810
+ }
811
+ /**
812
+ * Handles temperature changes to automatically adjust the system mode based on the current temperature
813
+ * consideration. This logic is disabled by default and will be enabled by setting useAutomaticModeManagement to
814
+ * true.
815
+ */
816
+ #handleTemperatureChangeForMode(temperature) {
817
+ if (temperature == null) {
818
+ return;
819
+ }
820
+ const consideration = this.temperatureConsideration;
821
+ switch (this.state.systemMode) {
822
+ case Thermostat.SystemMode.Heat:
823
+ switch (consideration) {
824
+ case "belowTarget":
825
+ this.adjustRunningMode(Thermostat.ThermostatRunningMode.Heat);
826
+ break;
827
+ default:
828
+ this.adjustRunningMode(Thermostat.ThermostatRunningMode.Off);
829
+ break;
830
+ }
831
+ break;
832
+ case Thermostat.SystemMode.Cool:
833
+ switch (consideration) {
834
+ case "aboveTarget":
835
+ this.adjustRunningMode(Thermostat.ThermostatRunningMode.Cool);
836
+ break;
837
+ default:
838
+ this.adjustRunningMode(Thermostat.ThermostatRunningMode.Off);
839
+ break;
840
+ }
841
+ break;
842
+ case Thermostat.SystemMode.Auto:
843
+ switch (consideration) {
844
+ case "belowTarget":
845
+ this.adjustRunningMode(Thermostat.ThermostatRunningMode.Heat);
846
+ break;
847
+ case "aboveTarget":
848
+ this.adjustRunningMode(Thermostat.ThermostatRunningMode.Cool);
849
+ break;
850
+ default:
851
+ this.adjustRunningMode(Thermostat.ThermostatRunningMode.Off);
852
+ break;
853
+ }
854
+ break;
855
+ }
856
+ }
857
+ #setupPresets() {
858
+ if (!this.features.presets) {
859
+ return;
860
+ }
861
+ this.reactTo(this.events.presets$AtomicChanging, this.#handlePresetsChanging);
862
+ this.reactTo(this.events.presets$AtomicChanged, this.#handlePresetsChanged);
863
+ this.reactTo(this.events.persistedPresets$Changing, this.#handlePresetsChanging);
864
+ this.reactTo(this.events.persistedPresets$Changed, this.#handlePersistedPresetsChanged);
865
+ this.reactTo(this.events.updatePresets, this.#updatePresets, { lock: true });
866
+ }
867
+ /** Handles changes to the Presets attribute and ensures persistedPresets are updated accordingly */
868
+ #updatePresets(newPresets) {
869
+ this.state.persistedPresets = newPresets;
870
+ }
871
+ /**
872
+ * Handles "In-flight" validation of newly written Presets via atomic-write and does the required validations.
873
+ */
874
+ #handlePresetsChanging(newPresets, oldPresets) {
875
+ if (newPresets.length > this.state.numberOfPresets) {
876
+ throw new StatusResponse.ResourceExhaustedError(
877
+ `Number of presets (${newPresets.length}) exceeds NumberOfPresets (${this.state.numberOfPresets})`
878
+ );
879
+ }
880
+ const oldPresetsMap = /* @__PURE__ */ new Map();
881
+ if (oldPresets !== void 0) {
882
+ for (const preset of oldPresets) {
883
+ if (preset.presetHandle !== null) {
884
+ const presetHex = Bytes.toHex(preset.presetHandle);
885
+ oldPresetsMap.set(presetHex, preset);
886
+ }
887
+ }
888
+ }
889
+ const persistedPresetsMap = /* @__PURE__ */ new Map();
890
+ if (this.state.persistedPresets !== void 0) {
891
+ for (const preset of this.state.persistedPresets) {
892
+ if (preset.presetHandle === null) {
893
+ throw new InternalError("Persisted preset is missing presetHandle, this should not happen");
894
+ }
895
+ const presetHex = Bytes.toHex(preset.presetHandle);
896
+ persistedPresetsMap.set(presetHex, preset);
897
+ }
898
+ }
899
+ const presetTypeMap = /* @__PURE__ */ new Map();
900
+ for (const type of this.state.presetTypes) {
901
+ presetTypeMap.set(type.presetScenario, type);
902
+ }
903
+ const presetScenarioNames = /* @__PURE__ */ new Map();
904
+ const presetScenarioCounts = /* @__PURE__ */ new Map();
905
+ const newPresetsSet = /* @__PURE__ */ new Set();
906
+ const newBuildInPresets = /* @__PURE__ */ new Set();
907
+ for (const preset of newPresets) {
908
+ if (preset.presetHandle !== null) {
909
+ const presetHex = Bytes.toHex(preset.presetHandle);
910
+ if (newPresetsSet.has(presetHex)) {
911
+ throw new StatusResponse.ConstraintErrorError(`Duplicate presetHandle ${presetHex} in new Presets`);
912
+ }
913
+ if (this.state.persistedPresets !== void 0) {
914
+ const persistedPreset = persistedPresetsMap.get(presetHex);
915
+ if (persistedPreset === void 0) {
916
+ throw new StatusResponse.NotFoundError(
917
+ `Preset with presetHandle ${presetHex} does not exist in old Presets, cannot add new Presets with non-null presetHandle`
918
+ );
919
+ }
920
+ if (preset.builtIn !== null && persistedPreset.builtIn !== preset.builtIn) {
921
+ throw new StatusResponse.ConstraintErrorError(
922
+ `Cannot change built-in status of preset with presetHandle ${presetHex}`
923
+ );
924
+ }
925
+ }
926
+ newPresetsSet.add(presetHex);
927
+ } else if (preset.builtIn) {
928
+ throw new StatusResponse.ConstraintErrorError(`Can not add a new built-in preset`);
929
+ }
930
+ const presetType = presetTypeMap.get(preset.presetScenario);
931
+ if (presetType === void 0) {
932
+ throw new StatusResponse.ConstraintErrorError(
933
+ `No PresetType defined for scenario ${Thermostat.PresetScenario[preset.presetScenario]}`
934
+ );
935
+ }
936
+ if (preset.name !== void 0) {
937
+ const scenarioNames = presetScenarioNames.get(preset.presetScenario) ?? [];
938
+ if (scenarioNames.includes(preset.name)) {
939
+ throw new StatusResponse.ConstraintErrorError(
940
+ `Duplicate preset name "${preset.name}" for scenario ${Thermostat.PresetScenario[preset.presetScenario]}`
941
+ );
942
+ }
943
+ if (!presetType.presetTypeFeatures.supportsNames) {
944
+ throw new StatusResponse.ConstraintErrorError(
945
+ `Preset names are not supported for scenario ${Thermostat.PresetScenario[preset.presetScenario]}`
946
+ );
947
+ }
948
+ scenarioNames.push(preset.name);
949
+ presetScenarioNames.set(preset.presetScenario, scenarioNames);
950
+ }
951
+ const count = presetScenarioCounts.get(preset.presetScenario) ?? 0;
952
+ if (count === presetType.numberOfPresets) {
953
+ throw new StatusResponse.ResourceExhaustedError(
954
+ `Number of presets (${count}) for scenario ${Thermostat.PresetScenario[preset.presetScenario]} exceeds allowed number (${presetType.numberOfPresets})`
955
+ );
956
+ }
957
+ presetScenarioCounts.set(preset.presetScenario, count + 1);
958
+ if (this.features.cooling) {
959
+ if (preset.coolingSetpoint === void 0) {
960
+ throw new StatusResponse.ConstraintErrorError(
961
+ `Preset for scenario ${Thermostat.PresetScenario[preset.presetScenario]} is missing required coolingSetpoint`
962
+ );
963
+ }
964
+ if (preset.coolingSetpoint < this.coolSetpointMinimum || preset.coolingSetpoint > this.coolSetpointMaximum) {
965
+ throw new StatusResponse.ConstraintErrorError(
966
+ `Preset coolingSetpoint (${preset.coolingSetpoint}) for scenario ${Thermostat.PresetScenario[preset.presetScenario]} is out of bounds [${this.coolSetpointMinimum}, ${this.coolSetpointMaximum}]`
967
+ );
968
+ }
969
+ }
970
+ if (this.features.heating) {
971
+ if (preset.heatingSetpoint === void 0) {
972
+ throw new StatusResponse.ConstraintErrorError(
973
+ `Preset for scenario ${Thermostat.PresetScenario[preset.presetScenario]} is missing required heatingSetpoint`
974
+ );
975
+ }
976
+ if (preset.heatingSetpoint < this.heatSetpointMinimum || preset.heatingSetpoint > this.heatSetpointMaximum) {
977
+ throw new StatusResponse.ConstraintErrorError(
978
+ `Preset heatingSetpoint (${preset.heatingSetpoint}) for scenario ${Thermostat.PresetScenario[preset.presetScenario]} is out of bounds [${this.heatSetpointMinimum}, ${this.heatSetpointMaximum}]`
979
+ );
980
+ }
981
+ }
982
+ if (preset.builtIn && preset.presetHandle !== null) {
983
+ newBuildInPresets.add(Bytes.toHex(preset.presetHandle));
984
+ }
985
+ }
986
+ }
987
+ /**
988
+ * Handles additional validation of preset changes when all chunks were written in an atomic write operation.
989
+ */
990
+ #handlePresetsChanged(newPresets, oldPresets) {
991
+ this.#handlePersistedPresetsChanged(newPresets, oldPresets);
992
+ const oldPresetsMap = /* @__PURE__ */ new Map();
993
+ const oldBuildInPresets = /* @__PURE__ */ new Set();
994
+ if (oldPresets !== void 0) {
995
+ for (const preset of oldPresets) {
996
+ if (preset.presetHandle === null) {
997
+ throw new InternalError("Old preset is missing presetHandle, this must not happen");
998
+ }
999
+ const presetHex = Bytes.toHex(preset.presetHandle);
1000
+ oldPresetsMap.set(presetHex, preset);
1001
+ if (preset.builtIn) {
1002
+ oldBuildInPresets.add(presetHex);
1003
+ }
1004
+ }
1005
+ }
1006
+ for (const preset of newPresets) {
1007
+ if (preset.presetHandle === null) {
1008
+ if (preset.builtIn) {
1009
+ throw new StatusResponse.ConstraintErrorError(
1010
+ `Preset for scenario ${Thermostat.PresetScenario[preset.presetScenario]} is built-in and must have a non-null presetHandle`
1011
+ );
1012
+ }
1013
+ }
1014
+ }
1015
+ }
1016
+ /**
1017
+ * Handles additional validation and required value adjustments of persistedPresets changes when all chunks were
1018
+ * written in an atomic write.
1019
+ */
1020
+ #handlePersistedPresetsChanged(newPresets, oldPresets) {
1021
+ if (oldPresets === void 0) {
1022
+ logger.debug(
1023
+ "Old presets is undefined, skipping some checks. This should only happen on setup of the behavior."
1024
+ );
1025
+ }
1026
+ const entropy = this.endpoint.env.get(Entropy);
1027
+ let changed = false;
1028
+ const newPresetHandles = /* @__PURE__ */ new Set();
1029
+ for (const preset of newPresets) {
1030
+ if (preset.presetHandle === null) {
1031
+ logger.error("Preset is missing presetHandle, generating a new one");
1032
+ preset.presetHandle = entropy.randomBytes(16);
1033
+ changed = true;
1034
+ }
1035
+ newPresetHandles.add(Bytes.toHex(preset.presetHandle));
1036
+ if (oldPresets === void 0) {
1037
+ if (preset.builtIn === null) {
1038
+ preset.builtIn = false;
1039
+ changed = true;
1040
+ }
1041
+ } else {
1042
+ if (preset.builtIn === null) {
1043
+ const oldPreset = oldPresets.find(
1044
+ (p) => p.presetHandle && preset.presetHandle && Bytes.areEqual(p.presetHandle, preset.presetHandle)
1045
+ );
1046
+ if (oldPreset !== void 0) {
1047
+ preset.builtIn = oldPreset.builtIn;
1048
+ } else {
1049
+ preset.builtIn = false;
1050
+ }
1051
+ changed = true;
1052
+ }
1053
+ }
1054
+ }
1055
+ const newBuildInPresets = /* @__PURE__ */ new Set();
1056
+ for (const preset of newPresets) {
1057
+ if (preset.builtIn) {
1058
+ newBuildInPresets.add(Bytes.toHex(preset.presetHandle));
1059
+ }
1060
+ }
1061
+ const oldBuildInPresets = /* @__PURE__ */ new Set();
1062
+ if (oldPresets !== void 0) {
1063
+ for (const preset of oldPresets) {
1064
+ if (preset.builtIn) {
1065
+ oldBuildInPresets.add(Bytes.toHex(preset.presetHandle));
1066
+ }
1067
+ }
1068
+ }
1069
+ for (const oldBuiltInPreset of oldBuildInPresets) {
1070
+ if (!newBuildInPresets.has(oldBuiltInPreset)) {
1071
+ throw new StatusResponse.ConstraintErrorError(
1072
+ `Cannot remove built-in preset with presetHandle ${oldBuiltInPreset}`
1073
+ );
1074
+ }
1075
+ }
1076
+ if (this.state.activePresetHandle !== null && !newPresetHandles.has(Bytes.toHex(this.state.activePresetHandle))) {
1077
+ throw new StatusResponse.InvalidInStateError(`ActivePresetHandle references non-existing presetHandle`);
1078
+ }
1079
+ if (changed) {
1080
+ logger.error("PresetHandles or BuiltIn flags were updated, updating persistedPresets");
1081
+ this.state.persistedPresets = deepCopy(newPresets);
1082
+ }
1083
+ }
1084
+ async [Symbol.asyncDispose]() {
1085
+ this.endpoint.env.close(AtomicWriteHandler);
1086
+ }
1087
+ /** Implementation of the atomic request handling */
1088
+ async atomicRequest(request) {
1089
+ const atomicWriteHandler = this.endpoint.env.get(AtomicWriteHandler);
1090
+ const { requestType } = request;
1091
+ switch (requestType) {
1092
+ case Thermostat.RequestType.BeginWrite:
1093
+ return atomicWriteHandler.beginWrite(request, this.context, this.endpoint, this.type);
1094
+ case Thermostat.RequestType.CommitWrite:
1095
+ return await atomicWriteHandler.commitWrite(
1096
+ request,
1097
+ this.context,
1098
+ this.endpoint,
1099
+ this.type,
1100
+ this.state
1101
+ );
1102
+ case Thermostat.RequestType.RollbackWrite:
1103
+ return atomicWriteHandler.rollbackWrite(request, this.context, this.endpoint, this.type);
1104
+ }
1105
+ }
1106
+ }
1107
+ ((ThermostatBaseServer2) => {
1108
+ class State extends ThermostatBehaviorLogicBase.State {
1109
+ /**
1110
+ * Otherwise measured temperature in Matter format as uint16 with a factor of 100. A calibration offset is applied
1111
+ * additionally from localTemperatureCalibration if set.
1112
+ * Use this if you have an external temperature sensor that should be used for thermostat control instead of a
1113
+ * local temperature measurement cluster.
1114
+ */
1115
+ externalMeasuredIndoorTemperature;
1116
+ /**
1117
+ * Otherwise measured occupancy as boolean.
1118
+ * Use this if you have an external occupancy sensor that should be used for thermostat control instead of a
1119
+ * internal occupancy sensing cluster.
1120
+ */
1121
+ externallyMeasuredOccupancy;
1122
+ /**
1123
+ * Use to enable the automatic mode management, implemented by this standard implementation. This is beyond
1124
+ * Matter specification! It reacts to temperature changes to adjust system running mode automatically. It also
1125
+ * requires the Auto feature to be enabled and the ThermostatRunningMode attribute to be present.
1126
+ */
1127
+ useAutomaticModeManagement = false;
1128
+ /**
1129
+ * Persisted presets stored in the device, needed because the original "presets" is a virtual property
1130
+ */
1131
+ persistedPresets;
1132
+ /**
1133
+ * Implementation of the needed Preset attribute logic for Atomic Write handling.
1134
+ */
1135
+ [Val.properties](endpoint, session) {
1136
+ const properties = {};
1137
+ if (endpoint.behaviors.optionsFor(ThermostatBaseServer2)?.presets !== void 0 || endpoint.behaviors.defaultsFor(ThermostatBaseServer2)?.presets !== void 0) {
1138
+ Object.defineProperty(properties, "presets", {
1139
+ /**
1140
+ * Getter will return a pending atomic write state when there is one, otherwise the stored value or
1141
+ * the default value.
1142
+ */
1143
+ get() {
1144
+ const pendingValue = endpoint.env.get(AtomicWriteHandler).pendingValueForAttributeAndPeer(
1145
+ session,
1146
+ endpoint,
1147
+ ThermostatBaseServer2,
1148
+ Thermostat.Complete.attributes.presets.id
1149
+ );
1150
+ if (pendingValue !== void 0) {
1151
+ return pendingValue;
1152
+ }
1153
+ let value = endpoint.stateOf(ThermostatBaseServer2.id).persistedPresets;
1154
+ if (value === void 0) {
1155
+ value = endpoint.behaviors.optionsFor(ThermostatBaseServer2)?.presets;
1156
+ }
1157
+ return value ?? [];
1158
+ },
1159
+ /**
1160
+ * Setter will either emit an update event directly when in local actor context or command context,
1161
+ * otherwise it will go through the AtomicWriteHandler to ensure proper atomic write handling.
1162
+ */
1163
+ set(value) {
1164
+ if (hasLocalActor(session) || "command" in session && session.command) {
1165
+ endpoint.eventsOf(ThermostatBaseServer2.id).updatePresets.emit(value);
1166
+ } else {
1167
+ endpoint.env.get(AtomicWriteHandler).writeAttribute(
1168
+ session,
1169
+ endpoint,
1170
+ ThermostatBaseServer2,
1171
+ Thermostat.Complete.attributes.presets.id,
1172
+ value
1173
+ );
1174
+ }
1175
+ }
1176
+ });
1177
+ }
1178
+ return properties;
1179
+ }
1180
+ }
1181
+ ThermostatBaseServer2.State = State;
1182
+ class Events extends ThermostatBehaviorLogicBase.Events {
1183
+ externalMeasuredIndoorTemperature$Changed = Observable();
1184
+ externallyMeasuredOccupancy$Changed = Observable();
1185
+ persistedPresets$Changed = Observable();
1186
+ persistedPresets$Changing = Observable();
1187
+ /**
1188
+ * Custom event emitted when the calibrated temperature changes.
1189
+ */
1190
+ calibratedTemperature$Changed = Observable();
1191
+ /**
1192
+ * Custom event emitted when the Presets attribute is "virtually" changing as part of an atomic write operation.
1193
+ * Info: The events is currently needed to be a pure Observable to get errors thrown in the event handler be
1194
+ * reported back to the emitter.
1195
+ */
1196
+ presets$AtomicChanging = Observable();
1197
+ /**
1198
+ * Custom event emitted when the Presets attribute has "virtually" changed as part of an atomic write operation.
1199
+ * Info: The events is currently needed to be a pure Observable to get errors thrown in the event handler be
1200
+ * reported back to the emitter.
1201
+ */
1202
+ presets$AtomicChanged = Observable();
1203
+ /**
1204
+ * Custom event emitted to inform the behavior implementation of an update of the PersistedPresets attribute.
1205
+ */
1206
+ updatePresets = Observable();
1207
+ }
1208
+ ThermostatBaseServer2.Events = Events;
1209
+ class Internal {
1210
+ /**
1211
+ * Local temperature in Matter format as uint16 with a factor of 100. It is the same value as the one reported
1212
+ * in the localTemperature Attribute, but also present when the LocalTemperatureNotExposed feature is enabled.
1213
+ * Means all logic and calculations are always done with this value.
1214
+ * The value will be updated on initialization and when the localTemperature Attribute changes.
1215
+ */
1216
+ localTemperature = null;
1217
+ /**
1218
+ * Storing fixed value internally to ensure it can not be modified.
1219
+ * This value will be initialized when the behavior is initialized and is static afterward.
1220
+ */
1221
+ minSetpointDeadBand = 0;
1222
+ /**
1223
+ * Storing fixed value internally to ensure it can not be modified.
1224
+ * This value will be initialized when the behavior is initialized and is static afterward.
1225
+ */
1226
+ controlSequenceOfOperation;
1227
+ }
1228
+ ThermostatBaseServer2.Internal = Internal;
1229
+ })(ThermostatBaseServer || (ThermostatBaseServer = {}));
1230
+ class ThermostatServer extends ThermostatBaseServer.for(ClusterType(Thermostat.Base)) {
8
1231
  }
9
1232
  export {
1233
+ ThermostatBaseServer,
10
1234
  ThermostatServer
11
1235
  };
12
1236
  //# sourceMappingURL=ThermostatServer.js.map