Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updatw 27.01.25 #365

Merged
merged 7 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ With the ioBroker Matter Adapter, it is possible to map the following use cases:
-->

## Changelog

### __WORK IN PROGRESS__
* (@Apollon77) Fixed Thermostat limit initialization and Mode error
* (@Apollon77) Fixed Matter Event handling when mapped to an ioBroker state (e.g.GenericSwitch)
* (@Apollon77) Fixed Device type detection by really preferring the preferred type

### 0.4.9 (2025-01-26)
* (@Apollon77) Enhanced error and invalid devices display for UI
* (@Apollon77) Fixed Button Press Controller support
Expand Down
39 changes: 20 additions & 19 deletions src-admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
},
"dependencies": {
"@foxriver76/iob-component-lib": "^0.2.0",
"@iobroker/adapter-react-v5": "^7.4.18",
"@iobroker/dm-gui-components": "^7.4.18",
"@iobroker/adapter-react-v5": "^7.4.19",
"@iobroker/dm-gui-components": "^7.4.19",
"@iobroker/type-detector": "^4.1.1",
"@types/react-dom": "^18.3.5",
"@types/uuid": "^10.0.0",
Expand Down Expand Up @@ -51,4 +51,4 @@
}
]
]
}
}
2 changes: 1 addition & 1 deletion src-admin/src/Tabs/Bridges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
<div style={styles.deviceType}>{`${I18n.t('Device type')}: ${I18n.t(device.type)}`}</div>
</div>
<div style={{ flex: 1 }} />
{this.props.nodeStates?.[bridge.uuid] ? (
{this.props.nodeStates?.[bridge.uuid] && bridge.enabled ? (
<Tooltip
key="debug"
title={hasError ? I18n.t('Show error') : I18n.t('Show additional information')}
Expand Down
7 changes: 7 additions & 0 deletions src/lib/devices/Thermostat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ export class Thermostat extends GenericDevice {
return this.#modeState.value;
}

updateMode(mode: ThermostatMode): Promise<void> {
if (!this.#modeState) {
throw new Error('Mode state not found');
}
return this.#modeState.updateValue(mode);
}

hasMode(): boolean {
return !!this.#modeState;
}
Expand Down
12 changes: 9 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export class MatterAdapter extends utils.Adapter {
readonly #bridges = new Map<string, { bridge?: BridgedDevice; error?: string }>();
#controller?: MatterController;
#sendControllerUpdateTimeout?: NodeJS.Timeout;
#detector: ChannelDetector;
#_guiSubscribes: { clientId: string; ts: number }[] | null = null;
readonly #matterEnvironment: Environment;
#stateTimeout?: NodeJS.Timeout;
Expand Down Expand Up @@ -130,7 +129,6 @@ export class MatterAdapter extends utils.Adapter {
this.#deviceManagement = new MatterAdapterDeviceManagement(this);
this.#matterEnvironment = Environment.default;

this.#detector = new ChannelDetector();
this.t = (word: string, ..._args: (string | number | boolean | null)[]): string => word;
this.getText = (_word: string, ..._args: (string | number | boolean | null)[]): ioBroker.Translated =>
({}) as ioBroker.Translated;
Expand Down Expand Up @@ -813,8 +811,16 @@ export class MatterAdapter extends utils.Adapter {
_usedIdsOptional: usedIds,
ignoreIndicators,
excludedTypes: [Types.info],
allowedTypes: preferredType ? [preferredType as Types] : undefined,
//ignoreCache: true
};
const controls = this.#detector.detect(options);

const detector = new ChannelDetector();
let controls = detector.detect(options);
if (!controls?.length) {
delete options.allowedTypes;
controls = detector.detect(options);
}
if (controls?.length) {
let controlsToCheck = controls.filter((control: PatternControl) =>
control.states.some(({ id: foundId }) => foundId === id),
Expand Down
2 changes: 1 addition & 1 deletion src/matter/BridgedDevicesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class BridgedDevices extends BaseServerNode {
productId,
serialNumber: uniqueId,
uniqueId: md5(uniqueId),
hardwareVersion: versions.versionNum,
hardwareVersion: 1,
hardwareVersionString: versions.versionStr,
softwareVersion: versions.versionNum,
softwareVersionString: versions.versionStr,
Expand Down
2 changes: 1 addition & 1 deletion src/matter/DeviceNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Device extends BaseServerNode {
productId,
serialNumber: uniqueId,
uniqueId: md5(uniqueId),
hardwareVersion: versions.versionNum,
hardwareVersion: 1,
hardwareVersionString: versions.versionStr,
softwareVersion: versions.versionNum,
softwareVersionString: versions.versionStr,
Expand Down
2 changes: 1 addition & 1 deletion src/matter/to-iobroker/GenericDeviceToIoBroker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export abstract class GenericDeviceToIoBroker {
eventId = cluster.events[eventName].id;
}

if (stateData.id !== undefined) {
if (stateData.id === undefined) {
stateData.id = `${this.baseId}.`;
}
const pathId = eventPathToString({ endpointId, clusterId, eventName });
Expand Down
20 changes: 12 additions & 8 deletions src/matter/to-matter/ThermostatToMatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class ThermostatToMatter extends GenericDeviceToMatter {
adapter: ioBrokerDevice.adapter,
},
thermostat: {
// Values are potentially corrected later again
// Values are corrected later again with real values
systemMode: hasHeating ? MatterThermostat.SystemMode.Heat : MatterThermostat.SystemMode.Cool,
controlSequenceOfOperation:
hasHeating && hasCooling
Expand All @@ -124,10 +124,10 @@ export class ThermostatToMatter extends GenericDeviceToMatter {
? MatterThermostat.ControlSequenceOfOperation.CoolingOnly
: MatterThermostat.ControlSequenceOfOperation.HeatingOnly,
minSetpointDeadBand: clusterModes.includes(MatterThermostat.Feature.AutoMode) ? 0 : undefined,
absMinHeatSetpointLimit: hasHeating ? this.convertTemperatureValue(7) : undefined,
absMaxHeatSetpointLimit: hasHeating ? this.convertTemperatureValue(30) : undefined,
absMinCoolSetpointLimit: hasCooling ? this.convertTemperatureValue(16) : undefined,
absMaxCoolSetpointLimit: hasCooling ? this.convertTemperatureValue(32) : undefined,
absMinHeatSetpointLimit: hasHeating ? this.convertTemperatureValue(0) : undefined,
absMaxHeatSetpointLimit: hasHeating ? this.convertTemperatureValue(50) : undefined,
absMinCoolSetpointLimit: hasCooling ? this.convertTemperatureValue(0) : undefined,
absMaxCoolSetpointLimit: hasCooling ? this.convertTemperatureValue(50) : undefined,
},
},
);
Expand Down Expand Up @@ -242,8 +242,10 @@ export class ThermostatToMatter extends GenericDeviceToMatter {
const minMax = this.#ioBrokerDevice.getSetpointMinMax() ?? { min: 7, max: 30 };
await this.#matterEndpointThermostat.setStateOf(IoThermostatServer, {
// should be HeatingThermostatServer
// @ts-expect-error Workaround a .js instancing/typing error
occupiedHeatingSetpoint: this.convertTemperatureValue(setpointTemperature),
// @ts-expect-error Workaround a matter.js instancing/typing error
occupiedHeatingSetpoint: this.convertTemperatureValue(
this.#ioBrokerDevice.cropValue(setpointTemperature, minMax.min, minMax.max, true),
),
absMinHeatSetpointLimit: this.convertTemperatureValue(minMax.min),
absMaxHeatSetpointLimit: this.convertTemperatureValue(minMax.max),
});
Expand All @@ -252,7 +254,9 @@ export class ThermostatToMatter extends GenericDeviceToMatter {
const minMax = this.#ioBrokerDevice.getSetpointMinMax() ?? { min: 16, max: 32 };
await this.#matterEndpointThermostat.setStateOf(IoThermostatServer, {
// @ts-expect-error Workaround a matter.js instancing/typing error
occupiedCoolingSetpoint: this.convertTemperatureValue(setpointTemperature),
occupiedCoolingSetpoint: this.convertTemperatureValue(
this.#ioBrokerDevice.cropValue(setpointTemperature, minMax.min, minMax.max, true),
),
absMinCoolSetpointLimit: this.convertTemperatureValue(minMax.min),
absMaxCoolSetpointLimit: this.convertTemperatureValue(minMax.max),
});
Expand Down
Loading