Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions src/data/zha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,52 @@ export interface Cluster {
type: string;
}

export interface ClusterConfigurationData {
cluster_name: string;
cluster_id: number;
success: boolean;
}

export interface ClusterAttributeData {
cluster_name: string;
cluster_id: number;
attributes: AttributeConfigurationStatus[];
}

export interface AttributeConfigurationStatus {
id: number;
name: string;
success: boolean | undefined;
min: number;
max: number;
change: number;
}

export interface ClusterConfigurationStatus {
cluster: Cluster;
bindSuccess: boolean | undefined;
attributes: Map<number, AttributeConfigurationStatus>;
}

interface ClusterConfigurationBindEvent {
type: "zha_channel_bind";
zha_channel_msg_data: ClusterConfigurationData;
}

interface ClusterConfigurationReportConfigurationEvent {
type: "zha_channel_configure_reporting";
zha_channel_msg_data: ClusterAttributeData;
}

interface ClusterConfigurationEventFinish {
type: "zha_channel_cfg_done";
}

export type ClusterConfigurationEvent =
| ClusterConfigurationReportConfigurationEvent
| ClusterConfigurationBindEvent
| ClusterConfigurationEventFinish;

export interface Command {
name: string;
id: number;
Expand Down Expand Up @@ -83,10 +129,10 @@ export interface ZHAGroupMember {
export const reconfigureNode = (
hass: HomeAssistant,
ieeeAddress: string,
callbackFunction: any
callbackFunction: (message: ClusterConfigurationEvent) => void
) => {
return hass.connection.subscribeMessage(
(message) => callbackFunction(message),
(message: ClusterConfigurationEvent) => callbackFunction(message),
{
type: "zha/devices/reconfigure",
ieee: ieeeAddress,
Expand Down Expand Up @@ -301,3 +347,7 @@ export const DEVICE_MESSAGE_TYPES = [
DEVICE_FULLY_INITIALIZED,
];
export const LOG_OUTPUT = "log_output";
export const ZHA_CHANNEL_MSG = "zha_channel_message";
export const ZHA_CHANNEL_MSG_BIND = "zha_channel_bind";
export const ZHA_CHANNEL_MSG_CFG_RPT = "zha_channel_configure_reporting";
export const ZHA_CHANNEL_CFG_DONE = "zha_channel_cfg_done";
Loading