Skip to content

Commit

Permalink
Update 28.01.25
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Jan 28, 2025
1 parent ad595fd commit 21906d0
Show file tree
Hide file tree
Showing 20 changed files with 197 additions and 40 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ With the ioBroker Matter Adapter, it is possible to map the following use cases:
-->

## Changelog

### __WORK IN PROGRESS__
* (@Apollon77) Fixed caching issues in device type detection
* (@Apollon77) Added Debug info icon for Devices and Bridges

### 0.4.10 (2025-01-27)
* (@Apollon77) Fixed Thermostat limit initialization and Mode error
* (@Apollon77) Fixed Matter Event handling when mapped to an ioBroker state (e.g.GenericSwitch)
Expand Down
68 changes: 50 additions & 18 deletions src-admin/src/Tabs/Bridges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { v4 as uuidv4 } from 'uuid';

import {
Add,
Article,
AutoMode,
Close,
Delete,
Expand Down Expand Up @@ -1251,25 +1252,56 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
</div>
<div style={{ flex: 1 }} />
{this.props.nodeStates?.[bridge.uuid] && bridge.enabled ? (
<Tooltip
key="debug"
title={hasError ? I18n.t('Show error') : I18n.t('Show additional information')}
slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
>
<IconButton
style={{
height: 40,
color: hasError
? '#FF0000'
: this.props.themeType === 'dark'
? '#FFFFFF'
: '#00000080',
}}
onClick={e => this.requestAdditionalInformation(e, bridge.uuid, device.uuid)}
<>
<Tooltip
key="infos"
title={hasError ? I18n.t('Show error') : I18n.t('Show additional information')}
slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
>
{hasError ? <Warning /> : <Info />}
</IconButton>
</Tooltip>
<IconButton
style={{
height: 40,
color: hasError
? '#FF0000'
: this.props.themeType === 'dark'
? '#FFFFFF'
: '#00000080',
}}
onClick={e =>
this.requestAdditionalInformation(
'deviceExtendedInfo',
e,
bridge.uuid,
device.uuid,
)
}
>
{hasError ? <Warning /> : <Info />}
</IconButton>
</Tooltip>
<Tooltip
key="debug"
title={I18n.t('Show debug information')}
slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
>
<IconButton
style={{
height: 40,
color: this.props.themeType === 'dark' ? '#FFFFFF' : '#00000080',
}}
onClick={e =>
this.requestAdditionalInformation(
'deviceDebugInfo',
e,
bridge.uuid,
device.uuid,
)
}
>
<Article />
</IconButton>
</Tooltip>
</>
) : null}
</div>
</TableCell>
Expand Down
56 changes: 41 additions & 15 deletions src-admin/src/Tabs/BridgesAndDevices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Utils,
} from '@iobroker/adapter-react-v5';
import {
Article,
Close,
ContentCopy,
Delete,
Expand Down Expand Up @@ -262,11 +263,16 @@ class BridgesAndDevices<TProps extends BridgesAndDevicesProps, TState extends Br
return <QuestionMark style={{ color }} />;
}

requestAdditionalInformation(e: React.MouseEvent, uuid: string, bridgedDeviceUuid?: string): void {
requestAdditionalInformation(
message: 'deviceExtendedInfo' | 'deviceDebugInfo',
e: React.MouseEvent,
uuid: string,
bridgedDeviceUuid?: string,
): void {
e.stopPropagation();

this.props.socket
.sendTo(`matter.${this.props.instance}`, 'deviceExtendedInfo', { uuid, bridgedDeviceUuid })
.sendTo(`matter.${this.props.instance}`, message, { uuid, bridgedDeviceUuid })
.then(
({
result: { schema, options },
Expand All @@ -283,7 +289,7 @@ class BridgesAndDevices<TProps extends BridgesAndDevicesProps, TState extends Br
});
},
)
.catch(e => this.props.showToast(`Cannot reset: ${e}`));
.catch(e => this.props.showToast(`Cannot request additional information for "${message}": ${e}`));
}

renderMessageDialog(): React.JSX.Element | null {
Expand Down Expand Up @@ -315,16 +321,17 @@ class BridgesAndDevices<TProps extends BridgesAndDevicesProps, TState extends Br

renderStatus(
deviceOrBridge: DeviceDescription | BridgeDescription,
): [React.JSX.Element | null, React.JSX.Element | null, React.JSX.Element | null] {
): [React.JSX.Element | null, React.JSX.Element | null, React.JSX.Element | null, React.JSX.Element | null] {
if (!this.props.nodeStates[deviceOrBridge.uuid] || !deviceOrBridge.enabled) {
return [null, null, null];
return [null, null, null, null];
}

const result: [React.JSX.Element | null, React.JSX.Element | null, React.JSX.Element | null] = [
null,
null,
null,
];
const result: [
React.JSX.Element | null,
React.JSX.Element | null,
React.JSX.Element | null,
React.JSX.Element | null,
] = [null, null, null, null];

const qrCode = this.props.nodeStates[deviceOrBridge.uuid].status ? (
<Tooltip
Expand Down Expand Up @@ -354,9 +361,10 @@ class BridgesAndDevices<TProps extends BridgesAndDevicesProps, TState extends Br
}

const hasError = !!this.props.nodeStates[deviceOrBridge.uuid].error;
const extendedInfo = (

result[2] = (
<Tooltip
key="debug"
key="infos"
title={hasError ? I18n.t('Show error') : I18n.t('Show additional information')}
slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
>
Expand All @@ -375,15 +383,33 @@ class BridgesAndDevices<TProps extends BridgesAndDevicesProps, TState extends Br
}}
onClick={e => {
e.stopPropagation();
this.requestAdditionalInformation(e, deviceOrBridge.uuid);
this.requestAdditionalInformation('deviceExtendedInfo', e, deviceOrBridge.uuid);
}}
>
{hasError ? <Warning /> : <Info />}
</IconButton>
</Tooltip>
);

result[2] = extendedInfo;
result[3] = (
<Tooltip
key="debug"
title={I18n.t('Show debug information')}
slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
>
<IconButton
style={{
height: 40,
color: this.isDevice ? (this.props.themeType === 'dark' ? '#FFFFFF' : '#00000080') : '#FFFFFF',
}}
onClick={e => {
e.stopPropagation();
this.requestAdditionalInformation('deviceDebugInfo', e, deviceOrBridge.uuid);
}}
>
<Article />
</IconButton>
</Tooltip>
);

if (
this.props.nodeStates[deviceOrBridge.uuid].status &&
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Alle Geräte im Raum auswählen/abwählen",
"Show QR Code for commissioning": "QR-Code zur Inbetriebnahme anzeigen",
"Show additional information": "Weitere Informationen anzeigen",
"Show debug information": "Debug-Informationen anzeigen",
"Show error": "Fehler anzeigen",
"Show readme page": "Readme-Seite anzeigen",
"Show unsupported devices": "Nicht unterstützte Geräte anzeigen",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Select/Unselect all devices in room",
"Show QR Code for commissioning": "Show QR Code for commissioning",
"Show additional information": "Show additional information",
"Show debug information": "Show debug information",
"Show error": "Show error",
"Show readme page": "Show readme page",
"Show unsupported devices": "Show unsupported devices",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Seleccionar/deseleccionar todos los dispositivos en la habitación",
"Show QR Code for commissioning": "Mostrar código QR para puesta en servicio",
"Show additional information": "Mostrar información adicional",
"Show debug information": "Mostrar información de depuración",
"Show error": "Mostrar error",
"Show readme page": "Mostrar página readme",
"Show unsupported devices": "Mostrar dispositivos no compatibles",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Sélectionner/Désélectionner tous les appareils de la pièce",
"Show QR Code for commissioning": "Afficher le code QR pour la mise en service",
"Show additional information": "Afficher des informations supplémentaires",
"Show debug information": "Afficher les informations de débogage",
"Show error": "Afficher l'erreur",
"Show readme page": "Afficher la page readme",
"Show unsupported devices": "Afficher les appareils non pris en charge",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Seleziona/Deseleziona tutti i dispositivi nella stanza",
"Show QR Code for commissioning": "Mostra il codice QR per la messa in servizio",
"Show additional information": "Mostra informazioni aggiuntive",
"Show debug information": "Mostra informazioni di debug",
"Show error": "Mostra errore",
"Show readme page": "Mostra la pagina Leggimi",
"Show unsupported devices": "Mostra i dispositivi non supportati",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Selecteer/deselecteer alle apparaten in de kamer",
"Show QR Code for commissioning": "QR-code weergeven voor inbedrijfstelling",
"Show additional information": "Toon aanvullende informatie",
"Show debug information": "Debug-informatie weergeven",
"Show error": "Fout weergeven",
"Show readme page": "Leesmij-pagina weergeven",
"Show unsupported devices": "Toon niet-ondersteunde apparaten",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Zaznacz/odznacz wszystkie urządzenia w pokoju",
"Show QR Code for commissioning": "Pokaż kod QR do uruchomienia",
"Show additional information": "Pokaż dodatkowe informacje",
"Show debug information": "Pokaż informacje debugowania",
"Show error": "Pokaż błąd",
"Show readme page": "Pokaż stronę readme",
"Show unsupported devices": "Pokaż nieobsługiwane urządzenia",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Selecionar/desmarcar todos os dispositivos na sala",
"Show QR Code for commissioning": "Mostrar código QR para comissionamento",
"Show additional information": "Mostrar informações adicionais",
"Show debug information": "Mostrar informações de depuração",
"Show error": "Mostrar erro",
"Show readme page": "Mostrar página leia-me",
"Show unsupported devices": "Mostrar dispositivos não suportados",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Выбрать/отменить выбор всех устройств в комнате",
"Show QR Code for commissioning": "Показать QR-код для ввода в эксплуатацию",
"Show additional information": "Показать дополнительную информацию",
"Show debug information": "Показать отладочную информацию",
"Show error": "Показать ошибку",
"Show readme page": "Показать страницу readme",
"Show unsupported devices": "Показать неподдерживаемые устройства",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "Виберіть/Скасуйте вибір усіх пристроїв у кімнаті",
"Show QR Code for commissioning": "Показати QR-код для введення в експлуатацію",
"Show additional information": "Показати додаткову інформацію",
"Show debug information": "",
"Show error": "Показати помилку",
"Show readme page": "Показати сторінку readme",
"Show unsupported devices": "Показати непідтримувані пристрої",
Expand Down
1 change: 1 addition & 0 deletions src-admin/src/i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"Select/Unselect all devices in room": "选择/取消选择房间中的所有设备",
"Show QR Code for commissioning": "显示二维码进行调试",
"Show additional information": "显示更多信息",
"Show debug information": "显示调试信息",
"Show error": "显示错误",
"Show readme page": "显示自述文件页面",
"Show unsupported devices": "显示不支持的设备",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/devices/GenericDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ export abstract class GenericDevice extends EventEmitter {
} else if (valueType === ValueType.Enum) {
return 'select';
} else if (valueType === ValueType.String && property === PropertyType.Rgb) {
//return 'color'; // Add again once works in DM
return 'color'; // Add again once works in DM
}
return 'input';
}
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ export class MatterAdapter extends utils.Adapter {
let controls = detector.detect(options);
if (!controls?.length) {
delete options.allowedTypes;
const detector = new ChannelDetector();
controls = detector.detect(options);
}
if (controls?.length) {
Expand Down
53 changes: 53 additions & 0 deletions src/matter/BaseServerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { PowerSource } from '@matter/main/clusters';
import type { GenericDevice } from '../lib/devices/GenericDevice';
import { PropertyType } from '../lib/devices/DeviceStateObject';
import { BatteryPowerSourceServer } from './behaviors/PowerSourceServer';
import type { JsonFormSchema } from '@iobroker/dm-utils';

export enum NodeStates {
Creating = 'creating',
Expand Down Expand Up @@ -160,6 +161,31 @@ export abstract class BaseServerNode implements GeneralNode {
},
};
}
case 'deviceDebugInfo': {
const { data, schema } = this.getDeviceDebugInfo(message);
return {
result: {
schema,
options: {
data,
maxWidth: 'md',
minWidth: 610,
title: `${this.type === 'bridges' && !('bridgedDeviceUuid' in message) ? 'Bridge' : 'Device'} Debug information`,
buttons: [
{
type: 'copyToClipboard',
label: this.adapter.getText('Copy to clipboard'),
copyToClipboardAttr: 'debugInfos',
},
{
type: 'close',
label: this.adapter.getText('Close'),
},
],
},
},
};
}
}

return { error: `Unknown command "${command}"` };
Expand Down Expand Up @@ -190,6 +216,33 @@ export abstract class BaseServerNode implements GeneralNode {

abstract getDeviceDetails(message: ioBroker.MessagePayload): StructuredJsonFormData;

getDeviceDebugInfo(_message: ioBroker.MessagePayload): { schema: JsonFormSchema; data: any } {
return {
schema: {
type: 'panel',
items: {
_instructions: {
type: 'staticText',
text: this.adapter.getText(
'In case of issues with this node please copy and post these details together with Debug logs to the issue.',
),
},
debugInfos: {
type: 'text',
label: this.adapter.getText('Debug Infos'),
minRows: 30,
sm: 12,
readOnly: true,
copyToClipboard: true,
trim: false,
noClearButton: true,
},
},
},
data: null,
};
}

/**
* Initializes the reachable state handler for a device and map it to the Basic Information Cluster of the Matter +
* device.
Expand Down
Loading

0 comments on commit 21906d0

Please sign in to comment.