/** * Centralized schema definitions for all 22 ESPHome entity types. * * @remarks This module provides the message type IDs, field numbers, and wire types needed to encode commands and decode state responses. By centralizing these * definitions, we eliminate magic numbers scattered throughout the codebase and provide a single source of truth for protocol field mappings. * * @module schemas/entity-schemas */ import { WireType } from "../protocol/index.js"; export { WireType }; /** * Value types that describe how to interpret and encode/decode field data. */ export type ValueType = "bool" | "enum" | "fixed32" | "float" | "sint32" | "string" | "varint"; /** * Defines the wire format for a single protobuf field. */ export interface FieldSpec { fieldNumber: number; valueType: ValueType; wireType: WireType; } /** * Defines a field that uses the has_* pattern common in ESPHome commands. These fields have a boolean "has" field followed by the actual value field. */ export interface HasPatternField { hasFieldNumber: number; valueFieldNumber: number; valueType: ValueType; wireType: WireType; } /** * Defines a mapping from user-friendly string values to protocol enum numbers. Used to transform string options into numeric values before encoding. */ export type EnumMapping = Record; /** * Defines the command message structure for an entity type. */ export interface CommandSchema { deviceIdFieldNumber: number; enumMappings?: Record; fields: Record; hasPatternFields: Record; keyFieldNumber: number; messageType: number; } /** * Defines the state response message structure for an entity type. */ export interface StateSchema { deviceIdFieldNumber: number; fields: Record; keyFieldNumber: number; messageType: number; } /** * Defines the wire format for a repeated protobuf field containing multiple values of the same type. */ export interface RepeatedFieldSpec { fieldNumber: number; valueType: "enum" | "string" | "varint"; wireType: WireType; } /** * Defines the list entities response message structure for an entity type. */ export interface ListEntitiesSchema { deviceIdFieldNumber: number; fields: Record; keyFieldNumber: number; messageType: number; nameFieldNumber: number; objectIdFieldNumber: number; repeatedFields?: Record; } /** * Complete schema definition for a single entity type. */ export interface EntitySchema { command?: CommandSchema; listEntities: ListEntitiesSchema; state: StateSchema; type: string; } export declare const MESSAGE_TYPES: { readonly ALARM_CONTROL_PANEL_COMMAND_REQUEST: 96; readonly ALARM_CONTROL_PANEL_STATE_RESPONSE: 95; readonly BINARY_SENSOR_STATE_RESPONSE: 21; readonly BUTTON_COMMAND_REQUEST: 62; readonly CAMERA_IMAGE_RESPONSE: 44; readonly CLIMATE_COMMAND_REQUEST: 48; readonly CLIMATE_STATE_RESPONSE: 47; readonly COVER_COMMAND_REQUEST: 30; readonly COVER_STATE_RESPONSE: 22; readonly DATETIME_COMMAND_REQUEST: 114; readonly DATETIME_STATE_RESPONSE: 113; readonly DATE_COMMAND_REQUEST: 102; readonly DATE_STATE_RESPONSE: 101; readonly EVENT_RESPONSE: 108; readonly FAN_COMMAND_REQUEST: 31; readonly FAN_STATE_RESPONSE: 23; readonly LIGHT_COMMAND_REQUEST: 32; readonly LIGHT_STATE_RESPONSE: 24; readonly LIST_ENTITIES_ALARM_CONTROL_PANEL_RESPONSE: 94; readonly LIST_ENTITIES_BINARY_SENSOR_RESPONSE: 12; readonly LIST_ENTITIES_BUTTON_RESPONSE: 61; readonly LIST_ENTITIES_CAMERA_RESPONSE: 43; readonly LIST_ENTITIES_CLIMATE_RESPONSE: 46; readonly LIST_ENTITIES_COVER_RESPONSE: 13; readonly LIST_ENTITIES_DATETIME_RESPONSE: 112; readonly LIST_ENTITIES_DATE_RESPONSE: 100; readonly LIST_ENTITIES_EVENT_RESPONSE: 107; readonly LIST_ENTITIES_FAN_RESPONSE: 14; readonly LIST_ENTITIES_LIGHT_RESPONSE: 15; readonly LIST_ENTITIES_LOCK_RESPONSE: 58; readonly LIST_ENTITIES_MEDIA_PLAYER_RESPONSE: 63; readonly LIST_ENTITIES_NUMBER_RESPONSE: 49; readonly LIST_ENTITIES_SELECT_RESPONSE: 52; readonly LIST_ENTITIES_SENSOR_RESPONSE: 16; readonly LIST_ENTITIES_SIREN_RESPONSE: 55; readonly LIST_ENTITIES_SWITCH_RESPONSE: 17; readonly LIST_ENTITIES_TEXT_RESPONSE: 97; readonly LIST_ENTITIES_TEXT_SENSOR_RESPONSE: 18; readonly LIST_ENTITIES_TIME_RESPONSE: 103; readonly LIST_ENTITIES_UPDATE_RESPONSE: 116; readonly LIST_ENTITIES_VALVE_RESPONSE: 109; readonly LOCK_COMMAND_REQUEST: 60; readonly LOCK_STATE_RESPONSE: 59; readonly MEDIA_PLAYER_COMMAND_REQUEST: 65; readonly MEDIA_PLAYER_STATE_RESPONSE: 64; readonly NUMBER_COMMAND_REQUEST: 51; readonly NUMBER_STATE_RESPONSE: 50; readonly SELECT_COMMAND_REQUEST: 54; readonly SELECT_STATE_RESPONSE: 53; readonly SENSOR_STATE_RESPONSE: 25; readonly SIREN_COMMAND_REQUEST: 57; readonly SIREN_STATE_RESPONSE: 56; readonly SWITCH_COMMAND_REQUEST: 33; readonly SWITCH_STATE_RESPONSE: 26; readonly TEXT_COMMAND_REQUEST: 99; readonly TEXT_SENSOR_STATE_RESPONSE: 27; readonly TEXT_STATE_RESPONSE: 98; readonly TIME_COMMAND_REQUEST: 105; readonly TIME_STATE_RESPONSE: 104; readonly UPDATE_COMMAND_REQUEST: 118; readonly UPDATE_STATE_RESPONSE: 117; readonly VALVE_COMMAND_REQUEST: 111; readonly VALVE_STATE_RESPONSE: 110; }; /** * Schema definitions for all 22 ESPHome entity types. Each schema provides the complete field mapping for encoding commands and decoding state responses. */ export declare const ENTITY_SCHEMAS: Record; /** * Look up an entity schema by its state message type ID. * * @param messageType - The message type ID to look up. * @returns The matching entity schema, or undefined if not found. */ export declare function findSchemaByStateMessageType(messageType: number): EntitySchema | undefined; /** * Look up an entity schema by its list entities message type ID. * * @param messageType - The message type ID to look up. * @returns The matching entity schema, or undefined if not found. */ export declare function findSchemaByListEntitiesMessageType(messageType: number): EntitySchema | undefined; /** * Look up an entity schema by its command message type ID. * * @param messageType - The message type ID to look up. * @returns The matching entity schema, or undefined if not found. */ export declare function findSchemaByCommandMessageType(messageType: number): EntitySchema | undefined;