MCPcopy
hub / github.com/homebridge/homebridge / mapAttributesToCommand

Function mapAttributesToCommand

src/matter/ClusterCommandMapper.ts:338–358  ·  view source on GitHub ↗
(
  cluster: string,
  attributes: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

336 * to update state directly instead of invoking a command.
337 */
338export function mapAttributesToCommand(
339 cluster: string,
340 attributes: Record<string, unknown>,
341): { command: string, args?: Record<string, unknown> } | null {
342 const mapping = CLUSTER_COMMAND_MAPPINGS[cluster]
343
344 if (!mapping) {
345 throw new Error(`Command mapping not implemented for cluster: ${cluster}`)
346 }
347
348 const result = mapping.map(attributes)
349
350 if (result === null) {
351 // Some clusters trigger change handlers automatically via attribute updates
352 // These don't need explicit commands (e.g., fanMode, systemMode changes)
353 // The caller should handle null by updating state directly
354 return null
355 }
356
357 return result
358}

Callers 2

handleTriggerCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected