( cluster: string, attributes: Record<string, unknown>, )
| 336 | * to update state directly instead of invoking a command. |
| 337 | */ |
| 338 | export 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 | } |
no outgoing calls
no test coverage detected