Skip to content

Commit

Permalink
Prefer the Preferred type
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Jan 27, 2025
1 parent 41b6340 commit 4c15121
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ With the ioBroker Matter Adapter, it is possible to map the following use cases:
### __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
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

0 comments on commit 4c15121

Please sign in to comment.