Skip to content

Commit

Permalink
Uifixes201224 (#242)
Browse files Browse the repository at this point in the history
* Add safeguard to not re-set timer when devices are offline

* Adjust logging

* Adjust logging

* Adjust UI logic

* package-lock

* changelog
  • Loading branch information
Apollon77 authored Dec 20, 2024
1 parent 84cd121 commit d37dcd8
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 24 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ TBD
-->

## Changelog

### __WORK IN PROGRESS__
* (@Apollon77) Fixes bridge/device icon display in UI
* (@Apollon77) Prevents displaying warning dialogs when nothing is wrong
* (@Apollon77) Adjusts some logs

### 0.3.0 (2024-12-20)
* BREAKING: Please re-enter your ioBroker Pro Cloud Password!
* (@Apollon77) Makes sure the adapter is stopped before being updated
Expand Down
4 changes: 2 additions & 2 deletions src-admin/package-lock.json

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

11 changes: 5 additions & 6 deletions src-admin/src/Tabs/Bridges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,15 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
}

if (anyAdded) {
if (!alreadyExist.length) {
if (!alreadyExist.length && becauseOfLicense.length) {
this.setState({
message: `${I18n.t('Following object IDs was not added because of the license')}:${becauseOfLicense.join(', ')}`,
});
} else if (!becauseOfLicense.length) {
} else if (!becauseOfLicense.length && alreadyExist.length) {
this.setState({
message: `${I18n.t('Following object IDs was not added because already exists')}:${alreadyExist.join(', ')}`,
});
} else {
} else if (becauseOfLicense.length && alreadyExist.length) {
this.setState({
message:
`${I18n.t('Following object IDs was not added because of the license')}:${becauseOfLicense.join(', ')}` +
Expand All @@ -327,12 +327,11 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
});
}
} else {
if (!becauseOfLicense.length) {
if (!becauseOfLicense.length && alreadyExist.length) {
this.setState({ message: I18n.t('No devices was added, as they are already in the list') });
} else if (!alreadyExist.length) {
} else if (!alreadyExist.length && becauseOfLicense.length) {
this.setState({ message: I18n.t('No devices was added, as they are not allowed by license') });
} else {
// Actually this branch could not happen
this.setState({
message: I18n.t('No devices was added, as they are already in the list or not allowed by license'),
});
Expand Down
13 changes: 8 additions & 5 deletions src-admin/src/Tabs/BridgesAndDevices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class BridgesAndDevices<TProps extends BridgesAndDevicesProps, TState extends Br
) : null;

if (qrCode) {
result[2] = qrCode;
result[1] = qrCode;
}

const hasError = !!this.props.nodeStates[deviceOrBridge.uuid].error;
Expand Down Expand Up @@ -361,10 +361,13 @@ class BridgesAndDevices<TProps extends BridgesAndDevicesProps, TState extends Br
</Tooltip>
);

if (qrCode) {
result[2] = extendedInfo;
}
if (this.props.nodeStates[deviceOrBridge.uuid].status) {
result[2] = extendedInfo;

if (
this.props.nodeStates[deviceOrBridge.uuid].status &&
this.props.nodeStates[deviceOrBridge.uuid].status !== 'waitingForCommissioning' &&
this.props.nodeStates[deviceOrBridge.uuid].status !== 'creating'
) {
result[0] = (
<Tooltip
key="status"
Expand Down
11 changes: 5 additions & 6 deletions src-admin/src/Tabs/Devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -532,15 +532,15 @@ class Devices extends BridgesAndDevices<DevicesProps, DevicesState> {
}

if (anyAdded) {
if (!alreadyExist.length) {
if (!alreadyExist.length && becauseOfLicense.length) {
this.setState({
message: `${I18n.t('Following object IDs was not added because of the license')}:${becauseOfLicense.join(', ')}`,
});
} else if (!becauseOfLicense.length) {
} else if (alreadyExist.length && !becauseOfLicense.length) {
this.setState({
message: `${I18n.t('Following object IDs was not added because already exists')}:${alreadyExist.join(', ')}`,
});
} else {
} else if (alreadyExist.length && becauseOfLicense.length) {
this.setState({
message:
`${I18n.t('Following object IDs was not added because of the license')}:${becauseOfLicense.join(', ')}` +
Expand All @@ -549,12 +549,11 @@ class Devices extends BridgesAndDevices<DevicesProps, DevicesState> {
});
}
} else {
if (!becauseOfLicense.length) {
if (alreadyExist && !becauseOfLicense.length) {
this.setState({ message: I18n.t('No devices was added, as they are already in the list') });
} else if (!alreadyExist.length) {
} else if (!alreadyExist.length && becauseOfLicense.length) {
this.setState({ message: I18n.t('No devices was added, as they are not allowed by license') });
} else {
// Actually this branch could not happen
this.setState({
message: I18n.t('No devices was added, as they are already in the list or not allowed by license'),
});
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export class MatterAdapter extends utils.Adapter {
return;
}
if (this.sendToUI) {
this.log.debug(`Send to GUI: ${JSON.stringify(data)}`);
for (let i = 0; i < this.#_guiSubscribes.length; i++) {
await this.sendToUI({ clientId: this.#_guiSubscribes[i].clientId, data });
}
Expand Down
7 changes: 3 additions & 4 deletions src/matter/IoBrokerObjectStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class IoBrokerObjectStorage implements MaybeAsyncStorage {
}

async clear(): Promise<void> {
this.#adapter.log.warn(`[STORAGE] Clearing all storage for ${this.#storageRootOid}`);
this.#adapter.log.info(`[STORAGE] Clearing all storage for ${this.#storageRootOid}`);
try {
await this.#adapter.delObjectAsync(this.#storageRootOid, { recursive: true });
} catch (error) {
Expand All @@ -89,7 +89,7 @@ export class IoBrokerObjectStorage implements MaybeAsyncStorage {
return;
}
if (this.#localStorageManager && this.#isLocallyStored(contexts)) {
this.#adapter.log.warn(`[STORAGE] Clearing all storage for ${contexts.join('$$')} in local storage`);
this.#adapter.log.info(`[STORAGE] Clearing all storage for ${contexts.join('$$')} in local storage`);
return this.#localStorageManager.clearAll(contexts);
}

Expand All @@ -98,7 +98,7 @@ export class IoBrokerObjectStorage implements MaybeAsyncStorage {
startkey: `${contextKey}`,
endkey: `${contextKey}\u9999`,
});
this.#adapter.log.warn(`[STORAGE] Clearing all storage (${objs.rows.length} keys found) for ${contextKey}`);
this.#adapter.log.info(`[STORAGE] Clearing all storage (${objs.rows.length} keys found) for ${contextKey}`);
const namespaceLen = this.#adapter.namespace.length + 1;
for (const state of objs.rows) {
if (state.value) {
Expand Down Expand Up @@ -250,7 +250,6 @@ export class IoBrokerObjectStorage implements MaybeAsyncStorage {
}

const oid = this.buildKey(contexts, key);
this.#adapter.log.warn(`[STORAGE] Deleting key "${key}" as "${oid}"`);

try {
await this.#adapter.delObjectAsync(oid);
Expand Down
4 changes: 3 additions & 1 deletion src/matter/to-iobroker/GenericDeviceToIoBroker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,9 @@ export abstract class GenericDeviceToIoBroker {
this.#adapter.log.debug(`Node ${this.#node.nodeId} is not connected, do not poll attributes`);
}

this.#pollTimeout = setTimeout(() => this.#pollAttributes(attributes), this.#pollInterval);
if (!this.#destroyed) {
this.#pollTimeout = setTimeout(() => this.#pollAttributes(attributes), this.#pollInterval);
}
}

async destroy(): Promise<void> {
Expand Down

0 comments on commit d37dcd8

Please sign in to comment.