[matter] Prevent Thermostat bridge failures (#21064)

Matter.js 0.17 implemented strict data validate for thermostats that we
could violate, preventing them from being added to the bridge.

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
This commit is contained in:
Dan Cunningham
2026-06-26 22:53:09 +02:00
committed by GitHub
parent a94c69fd36
commit 82f0c988e6
2 changed files with 20 additions and 7 deletions
@@ -27,9 +27,6 @@ export class CustomThermostatServer extends ThermostatServer {
minSetpointDeadBand: 0,
} as const;
static readonly DEFAULTS = {
} as const;
static selectFeatures(values: any): Thermostat.Feature[] {
const feats: Thermostat.Feature[] = [];
let controlSeq = -1;
@@ -18,9 +18,25 @@ export class ThermostatDeviceType extends BaseDeviceType {
}
override defaultClusterValues(userValues: Record<string, any>) {
const defaults: Record<string, any> = {
thermostat: CustomThermostatServer.DEFAULTS,
const thermostat = userValues.thermostat ?? {};
const hasHeating = thermostat.occupiedHeatingSetpoint !== undefined;
const hasCooling = thermostat.occupiedCoolingSetpoint !== undefined;
const thermostatDefaults: Record<string, any> = {
...CustomThermostatServer.DEFAULTS_COMMON,
};
if (hasHeating) {
Object.assign(thermostatDefaults, CustomThermostatServer.DEFAULTS_HEAT);
}
if (hasCooling) {
Object.assign(thermostatDefaults, CustomThermostatServer.DEFAULTS_COOL);
}
if (hasHeating && hasCooling) {
Object.assign(thermostatDefaults, CustomThermostatServer.DEFAULTS_AUTO);
}
return {
thermostat: thermostatDefaults,
};
return defaults;
}
}