Skip to content

Commit

Permalink
Update 20.12.24 (#238)
Browse files Browse the repository at this point in the history
* Fix rounding of battery state in second place

* Adjust matter,js Env handling

* Fix ending Discovery

* matter.js Environment exposing

* upgrades matter.js

* stop  and cleanup on upgrade

* BREAKING!! Correct encrypted field

* Readme

* Address two Sentry UI issues

.. they can happen for bridges/devices that do not have been started.

* another update
  • Loading branch information
Apollon77 authored Dec 20, 2024
1 parent 108df78 commit 8c2aaff
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 81 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__
* BREAKING: Please re-enter your ioBroker Pro Cloud Password!
* (@Apollon77) Makes sure the adapter is stopped before being updated
* (@Apollon77) Optimizes device discovery and allows to stop it again

### 0.2.10 (2024-12-19)
* (@bluefox) Makes the Adapter UI also available as standalone tab
* (@bluefox) Added error details when adding the same state twice to a bridge or device
Expand Down
6 changes: 4 additions & 2 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@
"keywords": [
"matter"
],
"eraseOnUpload": true,
"stopTimeout": 30000,
"stopBeforeUpdate": true,
"enabled": true,
"compact": false,
"singletonHost": true,
Expand All @@ -167,11 +169,11 @@
}
},
"protectedNative": [
"password",
"pass",
"login"
],
"encryptedNative": [
"password"
"pass"
],
"native": {
"interface": "",
Expand Down
118 changes: 59 additions & 59 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
"url": "https://github.com/ioBroker/ioBroker.matter"
},
"optionalDependencies": {
"@matter/nodejs-ble": "0.12.0-alpha.0-20241219-af74a6a14"
"@matter/nodejs-ble": "0.12.0-alpha.0-20241220-2c53108aa"
},
"dependencies": {
"@iobroker/adapter-core": "^3.2.3",
"@iobroker/i18n": "^0.3.1",
"@iobroker/dm-utils": "^0.6.11",
"@iobroker/type-detector": "^4.1.1",
"@matter/main": "0.12.0-alpha.0-20241219-af74a6a14",
"@matter/nodejs": "0.12.0-alpha.0-20241219-af74a6a14",
"@project-chip/matter.js": "0.12.0-alpha.0-20241219-af74a6a14",
"@matter/main": "0.12.0-alpha.0-20241220-2c53108aa",
"@matter/nodejs": "0.12.0-alpha.0-20241220-2c53108aa",
"@project-chip/matter.js": "0.12.0-alpha.0-20241220-2c53108aa",
"axios": "^1.7.9",
"jsonwebtoken": "^9.0.2"
},
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.

6 changes: 3 additions & 3 deletions src-admin/src/Tabs/Bridges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,9 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
devicesInBridge={this.props.matter.bridges[this.state.addDeviceDialog.bridgeIndex].list.length}
checkAddedDevices={
this.props.nodeStates[this.props.matter.bridges[this.state.addDeviceDialog.bridgeIndex].uuid]
.status === 'waitingForCommissioning'
? MAX_UN_COMMISSIONED_DEVICES
: 0
?.status !== 'waitingForCommissioning'
? 0
: MAX_UN_COMMISSIONED_DEVICES
}
matter={this.props.matter}
socket={this.props.socket}
Expand Down
5 changes: 3 additions & 2 deletions src-admin/src/Tabs/BridgesAndDevices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,9 @@ class BridgesAndDevices<TProps extends BridgesAndDevicesProps, TState extends Br
'All information of this device or bridge will be deleted and you must reconnect (with PIN or QR code) again.',
)}
</p>
{this.props.nodeStates[this.state.showResetDialog.bridgeOrDevice.uuid].status !==
'waitingForCommissioning' ? (
{this.props.nodeStates[this.state.showResetDialog.bridgeOrDevice.uuid] &&
this.props.nodeStates[this.state.showResetDialog.bridgeOrDevice.uuid].status !==
'waitingForCommissioning' ? (
<p style={{ color: this.props.themeType === 'dark' ? '#9c0a0a' : '#910000' }}>
{I18n.t(
'This device/bridge is linked to some ecosystem. If it is deleted here, you must manually remove it from your ecosystem!',
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ export class MatterAdapter extends utils.Adapter {
};
}

get matterEnvironment(): Environment {
return this.#matterEnvironment;
}

async shutDownMatterNodes(): Promise<void> {
for (const { device } of this.#devices.values()) {
await device?.destroy();
Expand Down Expand Up @@ -1085,7 +1089,6 @@ export class MatterAdapter extends utils.Adapter {
const matterController = new MatterController({
adapter: this,
controllerOptions,
matterEnvironment: this.#matterEnvironment,
updateCallback: () => this.#refreshControllerDevices(),
});
matterController.init(); // add bridge to server
Expand Down
1 change: 1 addition & 0 deletions src/matter/BridgedDevicesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ class BridgedDevices extends BaseServerNode {
NetworkCommissioningServer.withFeatures(NetworkCommissioning.Feature.EthernetNetworkInterface),
),
{
environment: this.adapter.matterEnvironment,
id: this.#parameters.uuid,
network: {
port: this.#parameters.port,
Expand Down
11 changes: 4 additions & 7 deletions src/matter/ControllerNode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Environment, Logger, NodeId, singleton, VendorId, type ServerAddressIp } from '@matter/main';
import { Logger, NodeId, singleton, VendorId, type ServerAddressIp } from '@matter/main';
import { GeneralCommissioning } from '@matter/main/clusters';
import {
Ble,
Expand All @@ -19,7 +19,6 @@ import { inspect } from 'util';
export interface ControllerCreateOptions {
adapter: MatterAdapter;
controllerOptions: MatterControllerConfig;
matterEnvironment: Environment;
updateCallback: () => void;
}

Expand All @@ -39,7 +38,6 @@ type EndUserCommissioningOptions = (
class Controller implements GeneralNode {
#parameters: MatterControllerConfig;
readonly #adapter: MatterAdapter;
readonly #matterEnvironment: Environment;
readonly #updateCallback: () => void;
#commissioningController?: CommissioningController;
#nodes = new Map<string, GeneralMatterNode>();
Expand All @@ -51,7 +49,6 @@ class Controller implements GeneralNode {
constructor(options: ControllerCreateOptions) {
this.#adapter = options.adapter;
this.#parameters = options.controllerOptions;
this.#matterEnvironment = options.matterEnvironment;
this.#updateCallback = options.updateCallback;
}

Expand Down Expand Up @@ -244,7 +241,7 @@ class Controller implements GeneralNode {
this.#commissioningController = new CommissioningController({
autoConnect: false,
environment: {
environment: this.#matterEnvironment,
environment: this.#adapter.matterEnvironment,
id: 'controller',
},
});
Expand Down Expand Up @@ -510,9 +507,9 @@ class Controller implements GeneralNode {
}

async #discoveryStop(): Promise<void> {
this.#discovering = false;
await this.#adapter.setState('controller.info.discovering', false, true);
if (this.#commissioningController && this.#discovering) {
this.#discovering = false;
await this.#adapter.setState('controller.info.discovering', false, true);
this.#adapter.log.info(`Stop the discovering...`);
this.#commissioningController.cancelCommissionableDeviceDiscovery(
{},
Expand Down
1 change: 1 addition & 0 deletions src/matter/DeviceNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Device extends BaseServerNode {
NetworkCommissioningServer.withFeatures(NetworkCommissioning.Feature.EthernetNetworkInterface),
),
{
environment: this.adapter.matterEnvironment,
id: this.#parameters.uuid,
network: {
port: this.#parameters.port,
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 @@ -612,7 +612,7 @@ export abstract class GenericDeviceToIoBroker {
const voltage = await powerSource.getBatVoltageAttribute();
const percentRemaining = await powerSource.getBatPercentRemainingAttribute();
if (typeof voltage === 'number') {
states.batteryVoltage = `${(voltage / 1_000).toFixed(2)} V${typeof percentRemaining === 'number' ? ` (${percentRemaining}%)` : ''}`;
states.batteryVoltage = `${(voltage / 1_000).toFixed(2)} V${typeof percentRemaining === 'number' ? ` (${Math.round(percentRemaining / 2)}%)` : ''}`;
} else if (typeof percentRemaining === 'number') {
states.batteryVoltage = `${Math.round(percentRemaining / 2)}%`;
}
Expand Down

0 comments on commit 8c2aaff

Please sign in to comment.