Skip to content

Commit

Permalink
Update 291124 (#176)
Browse files Browse the repository at this point in the history
* matter.js update

* matter.js update

* Also use deleted-flag for devices on UI delete

* Add handling for object deletion during runtime

* Close handling and use adapter setTimeout

* use adapter version as Software/Hardware Version in Matter

 partly addresses #175

* Fixes "auto" flags in backend when make no sense in objects

* Corrrectls set auto flags in UI

fixes #139

* Add logging for incoming state changes for debugging reasons

* Expose adapter for easier access

* Migrate to Behavior logic

... lets use the power of matter.js :-)
This prevents the cyclinc state updates

* Warn when states are not mapped

* Readme

* Readme

* Fix UI...

* update matter.js

* not needed anymore

* Only show product/Vendor ids for Device Dialog for devices
  • Loading branch information
Apollon77 authored Nov 30, 2024
1 parent a899e90 commit b765ff1
Show file tree
Hide file tree
Showing 24 changed files with 447 additions and 148 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ TBD
-->

## Changelog

### __WORK IN PROGRESS__
* (@Apollon77) Makes sure to delete all objects and stop device when a device is deleted in UI
* (@Apollon77) When a devices/bridge object is deleted and adapter runs we try to detect this and stop the device/bridge
* (@Apollon77) Optimizes close handling of adapter
* (@Apollon77) Uses adapter version as Software and Hardware versions in the exposed Matter devices
* (@Apollon77) Fixes "auto" flags in backend when make no sense in objects
* (@Apollon77) Fixes "auto" flag in UI
* (@Apollon77) Prevents cyclic state updates when a state is updated by the adapter to matter
* (@Apollon77) Log warnings when device optional device states are not mapped
* (@Apollon77) Hides Product-ID and VendorId fields in UI when adding devices into a bridge

### 0.2.2 (2024-11-28)
* (@Apollon77) Uses plain matter.js logs for better readability
* (@Apollon77) Prevents ghost connection entries in the UI
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.11.6"
"@matter/nodejs-ble": "0.11.8"
},
"dependencies": {
"@iobroker/adapter-core": "^3.2.2",
"@iobroker/i18n": "^0.3.1",
"@iobroker/dm-utils": "^0.6.9",
"@iobroker/type-detector": "^4.0.1",
"@matter/main": "0.11.6",
"@matter/nodejs": "0.11.6",
"@project-chip/matter.js": "0.11.6",
"@matter/main": "0.11.8",
"@matter/nodejs": "0.11.8",
"@project-chip/matter.js": "0.11.8",
"axios": "^1.7.8",
"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.

12 changes: 9 additions & 3 deletions src-admin/src/Tabs/Bridges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ interface AddCustomDeviceDialog {
oid: string;
name: string;
deviceType: Types | '';
detectedDeviceType?: Types;
bridgeIndex: number;
hasOnState?: boolean;
}
Expand Down Expand Up @@ -796,6 +797,7 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
addCustomDeviceDialog: {
oid,
name,
detectedDeviceType: deviceType,
deviceType: SUPPORTED_DEVICES.includes(deviceType) ? deviceType : '',
bridgeIndex: this.bridgeIndex as number,
hasOnState: controls[0].devices[0].hasOnState,
Expand All @@ -819,7 +821,7 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
socket={this.props.socket}
detectedDevices={this.props.detectedDevices}
setDetectedDevices={(detectedDevices: DetectedRoom[]) => this.props.setDetectedDevices(detectedDevices)}
type="device"
type="bridge"
name={this.props.matter.bridges[this.state.addDeviceDialog.bridgeIndex].name}
/>
);
Expand Down Expand Up @@ -992,14 +994,18 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
onClick={() => {
const addCustomDeviceDialog = this.state.addCustomDeviceDialog;
if (addCustomDeviceDialog) {
const isAutoType =
!!addCustomDeviceDialog.detectedDeviceType &&
addCustomDeviceDialog.detectedDeviceType === addCustomDeviceDialog.deviceType;
void this.addDevicesToBridge(
[
{
_id: addCustomDeviceDialog.oid,
common: {
name: addCustomDeviceDialog.name,
},
deviceType: addCustomDeviceDialog.deviceType as Types,
deviceType: (addCustomDeviceDialog.deviceType ??
addCustomDeviceDialog.detectedDeviceType) as Types,
hasOnState: addCustomDeviceDialog.hasOnState,
// ignored
type: 'device',
Expand All @@ -1008,7 +1014,7 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
},
],
addCustomDeviceDialog.bridgeIndex,
false,
isAutoType,
);
}

Expand Down
20 changes: 14 additions & 6 deletions src-admin/src/Tabs/Devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ interface DevicesState extends BridgesAndDevicesState {
oid: string;
name: string;
deviceType: Types | '';
detectedDeviceType?: Types;
vendorID: string;
productID: string;
noComposed?: boolean;
Expand Down Expand Up @@ -657,24 +658,30 @@ class Devices extends BridgesAndDevices<DevicesProps, DevicesState> {
<DialogActions>
<Button
onClick={() => {
this.state.addCustomDeviceDialog &&
const addCustomDeviceDialog = this.state.addCustomDeviceDialog;
if (addCustomDeviceDialog) {
const isAutoType =
!!addCustomDeviceDialog.detectedDeviceType &&
addCustomDeviceDialog.detectedDeviceType === addCustomDeviceDialog.deviceType;
void this.addDevices(
[
{
_id: this.state.addCustomDeviceDialog.oid,
_id: addCustomDeviceDialog.oid,
common: {
name: this.state.addCustomDeviceDialog.name,
name: addCustomDeviceDialog.name,
},
deviceType: this.state.addCustomDeviceDialog.deviceType as Types,
hasOnState: !!this.state.addCustomDeviceDialog.hasOnState,
deviceType: (addCustomDeviceDialog.deviceType ??
addCustomDeviceDialog.detectedDeviceType) as Types,
hasOnState: !!addCustomDeviceDialog.hasOnState,
// ignored
type: 'device',
states: [],
roomName: '',
},
],
false,
isAutoType,
);
}

this.setState({ addCustomDeviceDialog: null });
}}
Expand Down Expand Up @@ -812,6 +819,7 @@ class Devices extends BridgesAndDevices<DevicesProps, DevicesState> {
addCustomDeviceDialog: {
oid,
name,
detectedDeviceType: deviceType,
deviceType: SUPPORTED_DEVICES.includes(deviceType) ? deviceType : '',
hasOnState: controls[0].devices[0].hasOnState,
vendorID: '0xFFF1',
Expand Down
7 changes: 6 additions & 1 deletion src-admin/src/components/ConfigHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,12 @@ class ConfigHandler {
if (!newDev) {
this.config.devices.splice(d, 1);
console.log(`Device ${oldDev.uuid} created`);
await this.socket.delObject(`matter.${this.instance}.devices.${oldDev.uuid}`);
const obj: ioBroker.ChannelObject = (await this.socket.getObject(
`matter.${this.instance}.devices.${oldDev.uuid}`,
)) as ioBroker.ChannelObject;
obj.native.deleted = true;
console.log(`Device ${obj._id} deleted`);
await this.socket.setObject(obj._id, obj);
}
}

Expand Down
Loading

0 comments on commit b765ff1

Please sign in to comment.