Skip to content

Commit 7f7fd30

Browse files
committed
Update PicoRemote.ts
1 parent 6060ff7 commit 7f7fd30

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/PicoRemote.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,18 +420,22 @@ export class PicoRemote {
420420
const type = this.accessory.context.device.DeviceType
421421
const dentry = BUTTON_MAP.get(type)
422422
if (!dentry) {
423+
this.platform.log.warn(`[Matter] PicoRemote type '${type}' not found in BUTTON_MAP, returning empty clusters.`)
423424
return { behaviors: [] }
424425
}
425426
// Gather all button labels for this remote
426427
const buttonLabels = Array.from(dentry.values()).map(v => v.label.toLowerCase())
427428
const clusters: Record<string, any> = { behaviors: [] }
429+
let hasRequired = false
428430
// On/Off cluster for remotes with On/Off buttons
429431
if (buttonLabels.includes('on') && buttonLabels.includes('off')) {
430432
clusters.onOff = { onOff: false }
433+
hasRequired = true
431434
}
432435
// LevelControl cluster for Raise/Lower
433436
if (buttonLabels.includes('raise') && buttonLabels.includes('lower')) {
434437
clusters.levelControl = { currentLevel: 0, minLevel: 0, maxLevel: 254 }
438+
hasRequired = true
435439
}
436440
// Scenes cluster for 4-button scene/zone remotes and Pico4Button
437441
if (type.includes('4ButtonScene') || type.includes('4ButtonZone') || type === 'Pico4Button') {
@@ -441,6 +445,12 @@ export class PicoRemote {
441445
if (type.includes('4Button2Group')) {
442446
clusters.onOff = { onOff: false }
443447
clusters.onOff2 = { onOff: false }
448+
hasRequired = true
449+
}
450+
// Fallback: If neither onOff nor levelControl is present, add onOff by default and log a warning
451+
if (!hasRequired) {
452+
this.platform.log.warn(`[Matter] PicoRemote type '${type}' did not match onOff or levelControl cluster requirements. Adding onOff cluster by default.`)
453+
clusters.onOff = { onOff: false }
444454
}
445455
// Add battery cluster for remotes (all Pico remotes are battery powered)
446456
clusters.battery = { batteryLevel: 100, batteryLow: false }

0 commit comments

Comments
 (0)