Skip to content

Commit

Permalink
Add SmokeCO2Alarm Controller device type (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 authored Jan 23, 2025
1 parent f051381 commit a38041c
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 86 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ With the ioBroker Matter Adapter it is possible to map the following use cases:
* (2+) fireAlarm
* (-2) mediaPlayer
* warning - how?
* gate - aka blinds?
* windowTilt - how?
* levelSlider - how?
* gate - aka blinds because matter has no other device type?
* windowTilt - as discussed as composed device with two contact sensors ... one for open close and one for tilt
* levelSlider - ideally as non-lighting dimmed socket?
* Matter device types
* (7) Fan -> airCondition?
* (4+) Air Quality Sensor -> ???
Expand All @@ -50,7 +50,6 @@ With the ioBroker Matter Adapter it is possible to map the following use cases:
* (3+) Robot Vacuum cleaner -> vacuumCleaner
* (3) Flow Sensor -> ??? DEF
* (3) Room Air Conditioner -> airCondition
* (2+) Smoke & CO Alarm -> fireAlarm? warning?
* (2+) Dishwasher-> ???
* (2) Basic Video Player -> mediaPlayer
* (2) Laundry Washer -> ???
Expand All @@ -77,6 +76,11 @@ With the ioBroker Matter Adapter it is possible to map the following use cases:
-->

## Changelog
### __WORK IN PROGRESS__
* (@Apollon77) Added SmokeCO2Alarm -> FireAlarm to Controller device types
* (@Apollon77) Detects BLE only QR codes and respond with error message
* (@Apollon77) For Dimming and Color changes direct the device to execute the changes also when device is off

### 0.4.1 (2025-01-22)
* (@bluefox) Optimized UI
* (@Apollon77) Improved handling for Power Source cluster on root endpoint
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-20250121-0ab1b29a1"
"@matter/nodejs-ble": "0.12.0"
},
"dependencies": {
"@iobroker/adapter-core": "^3.2.3",
"@iobroker/i18n": "^0.3.1",
"@iobroker/dm-utils": "^1.0.6",
"@iobroker/type-detector": "^4.1.1",
"@matter/main": "0.12.0-alpha.0-20250121-0ab1b29a1",
"@matter/nodejs": "0.12.0-alpha.0-20250121-0ab1b29a1",
"@project-chip/matter.js": "0.12.0-alpha.0-20250121-0ab1b29a1",
"@matter/main": "0.12.0",
"@matter/nodejs": "0.12.0",
"@project-chip/matter.js": "0.12.0",
"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.

7 changes: 7 additions & 0 deletions src/lib/devices/FireAlarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ export class FireAlarm extends GenericDevice {
}
return this.#getValueState.value;
}

updateValue(value: boolean): Promise<void> {
if (!this.#getValueState) {
throw new Error('Value state not found');
}
return this.#getValueState.updateValue(value);
}
}
8 changes: 7 additions & 1 deletion src/matter/ControllerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type DiscoveryData,
CommissioningError,
} from '@matter/main/protocol';
import { ManualPairingCodeCodec, QrPairingCodeCodec } from '@matter/main/types';
import { ManualPairingCodeCodec, QrPairingCodeCodec, DiscoveryCapabilitiesSchema } from '@matter/main/types';
import { NodeJsBle } from '@matter/nodejs-ble';
import { CommissioningController, type NodeCommissioningOptions } from '@project-chip/matter.js';
import {
Expand Down Expand Up @@ -388,6 +388,12 @@ class Controller implements GeneralNode {
} else if ('qrCode' in data && data.qrCode.length > 0) {
const pairingCodeCodec = QrPairingCodeCodec.decode(data.qrCode);
// TODO handle the case where multiple devices are included
const capabilities = DiscoveryCapabilitiesSchema.decode(pairingCodeCodec[0].discoveryCapabilities);
if (!capabilities.onIpNetwork && capabilities.ble && !this.#useBle) {
throw new Error(
'This device can only be paired using BLE but BLE is disabled. Please use the ioBroker Visu App to pair this device or enable the Host BLE.',
);
}
longDiscriminator = pairingCodeCodec[0].discriminator;
shortDiscriminator = undefined;
passcode = pairingCodeCodec[0].passcode;
Expand Down
8 changes: 4 additions & 4 deletions src/matter/to-iobroker/ColorTemperatureLightToIoBroker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export class ColorTemperatureLightToIoBroker extends GenericElectricityDataDevic
await this.appEndpoint.getClusterClient(LevelControl.Complete)?.moveToLevel({
level,
transitionTime: transitionTime !== null ? Math.round(transitionTime / 100) : null,
optionsMask: {},
optionsOverride: {},
optionsMask: { executeIfOff: true },
optionsOverride: { executeIfOff: true },
});
},
convertValue: value => Math.round((value / 254) * 100),
Expand All @@ -127,8 +127,8 @@ export class ColorTemperatureLightToIoBroker extends GenericElectricityDataDevic
await this.appEndpoint.getClusterClient(ColorControl.Complete)?.moveToColorTemperature({
colorTemperatureMireds,
transitionTime,
optionsMask: {},
optionsOverride: {},
optionsMask: { executeIfOff: true },
optionsOverride: { executeIfOff: true },
});
},
convertValue: value => Math.round(miredsToKelvin(value)),
Expand Down
4 changes: 2 additions & 2 deletions src/matter/to-iobroker/DimmableToIoBroker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export class DimmableToIoBroker extends GenericElectricityDataDeviceToIoBroker {
await this.appEndpoint.getClusterClient(LevelControl.Complete)?.moveToLevel({
level,
transitionTime: transitionTime !== null ? Math.round(transitionTime / 100) : null,
optionsMask: {},
optionsOverride: {},
optionsMask: { executeIfOff: true },
optionsOverride: { executeIfOff: true },
});
},
convertValue: value => Math.round((value / 254) * 100),
Expand Down
16 changes: 8 additions & 8 deletions src/matter/to-iobroker/ExtendedColorLightToIoBroker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ export class ExtendedColorLightToIoBroker extends GenericElectricityDataDeviceTo
hue: matterHue,
saturation: matterSaturation,
transitionTime,
optionsMask: {},
optionsOverride: {},
optionsMask: { executeIfOff: true },
optionsOverride: { executeIfOff: true },
});
}

Expand All @@ -163,8 +163,8 @@ export class ExtendedColorLightToIoBroker extends GenericElectricityDataDeviceTo
colorX: matterX,
colorY: matterY,
transitionTime,
optionsMask: {},
optionsOverride: {},
optionsMask: { executeIfOff: true },
optionsOverride: { executeIfOff: true },
});
},
});
Expand Down Expand Up @@ -231,8 +231,8 @@ export class ExtendedColorLightToIoBroker extends GenericElectricityDataDeviceTo
await this.appEndpoint.getClusterClient(LevelControl.Complete)?.moveToLevel({
level,
transitionTime: transitionTime !== null ? Math.round(transitionTime / 100) : null,
optionsMask: {},
optionsOverride: {},
optionsMask: { executeIfOff: true },
optionsOverride: { executeIfOff: true },
});
},
convertValue: value => Math.round((value / 254) * 100),
Expand All @@ -253,8 +253,8 @@ export class ExtendedColorLightToIoBroker extends GenericElectricityDataDeviceTo
await this.appEndpoint.getClusterClient(ColorControl.Complete)?.moveToColorTemperature({
colorTemperatureMireds,
transitionTime,
optionsMask: {},
optionsOverride: {},
optionsMask: { executeIfOff: true },
optionsOverride: { executeIfOff: true },
});
},
convertValue: value => Math.round(miredsToKelvin(value)),
Expand Down
Loading

0 comments on commit a38041c

Please sign in to comment.