Skip to content

Commit

Permalink
Working on controller
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Nov 13, 2023
1 parent 19de1d3 commit eb70e65
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/matter/clusters/Identify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class Identify extends Base {
await this.createChannel(nodeId, this.endpoint.getDeviceTypes());

// create Identify channel
let id = `controller.${Base.toJSON(nodeId).replace(/"/g, '')}.identify`;
let channelObj = await this.adapter.getObjectAsync(id);
const _id = `controller.${Base.toJSON(nodeId).replace(/"/g, '')}.identify`;
let channelObj = await this.adapter.getObjectAsync(_id);
if (!channelObj) {
channelObj = {
_id: id,
_id,
type: 'channel',
common: {
name: 'Identify',
Expand Down Expand Up @@ -83,7 +83,7 @@ class Identify extends Base {
cluster.addIdentifyTimeAttributeListener(this.handlerTime);
cluster.addIdentifyTypeAttributeListener(this.handlerType);

this.createState(
const triggerId = await this.createState(
'identify.trigger',
{
name: 'Identify trigger',
Expand All @@ -103,14 +103,19 @@ class Identify extends Base {
}

if (state.val) {
const identifyTime = await this.adapter.getStateAsync(`${id}.time`);
try {
const identifyTime = await this.adapter.getStateAsync(timeId);

await cluster.identify({
identifyTime: parseInt((identifyTime?.val || 0).toString(), 10) || 5,
});
await cluster.identify({
identifyTime: parseInt((identifyTime?.val || 0).toString(), 10) || 5,
});
} catch (e) {
this.adapter.log.error(`Cannot send command identify: ${e.message}, stack: ${e.stack}`);
}
}
};
await this.subscribe(id, triggerIdentifyHandler);

await this.subscribe(triggerId, triggerIdentifyHandler);
}
async destroy() {
await super.destroy();
Expand Down

0 comments on commit eb70e65

Please sign in to comment.