mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
[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:
+1
-4
@@ -6,7 +6,7 @@ import { DeviceFunctions } from "../DeviceFunctions";
|
|||||||
export class CustomThermostatServer extends ThermostatServer {
|
export class CustomThermostatServer extends ThermostatServer {
|
||||||
static readonly DEFAULTS_COMMON = {
|
static readonly DEFAULTS_COMMON = {
|
||||||
systemMode: 0,
|
systemMode: 0,
|
||||||
localTemperature: 0,
|
localTemperature: 0,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
static readonly DEFAULTS_COOL = {
|
static readonly DEFAULTS_COOL = {
|
||||||
@@ -27,9 +27,6 @@ export class CustomThermostatServer extends ThermostatServer {
|
|||||||
minSetpointDeadBand: 0,
|
minSetpointDeadBand: 0,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
static readonly DEFAULTS = {
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
static selectFeatures(values: any): Thermostat.Feature[] {
|
static selectFeatures(values: any): Thermostat.Feature[] {
|
||||||
const feats: Thermostat.Feature[] = [];
|
const feats: Thermostat.Feature[] = [];
|
||||||
let controlSeq = -1;
|
let controlSeq = -1;
|
||||||
|
|||||||
+19
-3
@@ -18,9 +18,25 @@ export class ThermostatDeviceType extends BaseDeviceType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override defaultClusterValues(userValues: Record<string, any>) {
|
override defaultClusterValues(userValues: Record<string, any>) {
|
||||||
const defaults: Record<string, any> = {
|
const thermostat = userValues.thermostat ?? {};
|
||||||
thermostat: CustomThermostatServer.DEFAULTS,
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user