From 82f0c988e6bfe86bf395c9860d03106446f484fe Mon Sep 17 00:00:00 2001 From: Dan Cunningham Date: Fri, 26 Jun 2026 13:53:09 -0700 Subject: [PATCH] [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 --- .../behaviors/CustomThermostatServer.ts | 5 +---- .../bridge/devices/ThermostatDeviceType.ts | 22 ++++++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/bundles/org.openhab.binding.matter/matter-server/src/bridge/behaviors/CustomThermostatServer.ts b/bundles/org.openhab.binding.matter/matter-server/src/bridge/behaviors/CustomThermostatServer.ts index c16120c7a2..cc7f682955 100644 --- a/bundles/org.openhab.binding.matter/matter-server/src/bridge/behaviors/CustomThermostatServer.ts +++ b/bundles/org.openhab.binding.matter/matter-server/src/bridge/behaviors/CustomThermostatServer.ts @@ -6,7 +6,7 @@ import { DeviceFunctions } from "../DeviceFunctions"; export class CustomThermostatServer extends ThermostatServer { static readonly DEFAULTS_COMMON = { systemMode: 0, - localTemperature: 0, + localTemperature: 0, } as const; static readonly DEFAULTS_COOL = { @@ -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; diff --git a/bundles/org.openhab.binding.matter/matter-server/src/bridge/devices/ThermostatDeviceType.ts b/bundles/org.openhab.binding.matter/matter-server/src/bridge/devices/ThermostatDeviceType.ts index c7d80169cd..93d5811498 100644 --- a/bundles/org.openhab.binding.matter/matter-server/src/bridge/devices/ThermostatDeviceType.ts +++ b/bundles/org.openhab.binding.matter/matter-server/src/bridge/devices/ThermostatDeviceType.ts @@ -18,9 +18,25 @@ export class ThermostatDeviceType extends BaseDeviceType { } override defaultClusterValues(userValues: Record) { - const defaults: Record = { - thermostat: CustomThermostatServer.DEFAULTS, + const thermostat = userValues.thermostat ?? {}; + const hasHeating = thermostat.occupiedHeatingSetpoint !== undefined; + const hasCooling = thermostat.occupiedCoolingSetpoint !== undefined; + + const thermostatDefaults: Record = { + ...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; } }