import { ChannelCategory, DataTypeType, DeviceCategory, PropertyCategory } from '../../../modules/devices/devices.constants'; import { ComponentType } from '../devices-shelly-ng.constants'; import { AnyTransformerDefinition, InlineTransform, TransformDirection } from './transformers'; export interface ThresholdDerivation { type: 'threshold'; thresholds: ThresholdEntry[]; } export interface ThresholdEntry { max?: number; min?: number; value: string; } export interface BooleanDerivation { type: 'boolean_map'; true_value: string; false_value: string; } export interface PositionStatusDerivation { type: 'position_status'; closed_value: string; opened_value: string; partial_value?: string; } export type AnyDerivation = ThresholdDerivation | BooleanDerivation | PositionStatusDerivation; export interface DerivationDefinition { description?: string; rule: AnyDerivation; } export interface DerivationRulesConfig { version: string; derivations: Record; } export interface MappingConfig { version: string; transformers?: Record; derivations?: Record; mappings: MappingDefinition[]; } export interface MatchCondition { component_type?: string; device_category?: string; model?: string; profile?: string; all_of?: MatchCondition[]; any_of?: MatchCondition[]; } export interface PanelPropertyConfig { identifier: string; name?: string; data_type: string; format?: number[] | string[]; unit?: string; settable?: boolean; queryable?: boolean; invalid?: string | number | boolean; } export interface PropertyMapping { shelly_property: string; direction?: TransformDirection; panel: PanelPropertyConfig; transformer?: string; transform?: InlineTransform; } export interface StaticPropertyConfig { identifier: string; name?: string; data_type: string; format?: number[] | string[]; unit?: string; value: string | number | boolean; } export interface DerivedPropertyConfig { identifier: string; name?: string; data_type: string; format?: number[] | string[]; unit?: string; source_property: string; derivation?: string; derive?: AnyDerivation; } export interface ChannelMapping { identifier: string; name?: string; category: string; parent_identifier?: string; properties?: PropertyMapping[]; static_properties?: StaticPropertyConfig[]; derived_properties?: DerivedPropertyConfig[]; } export interface MappingDefinition { name: string; description?: string; priority?: number; match: MatchCondition; channels: ChannelMapping[]; } export interface ResolvedMapping { name: string; description?: string; priority: number; match: ResolvedMatchCondition; channels: ResolvedChannel[]; } export interface ResolvedMatchCondition { componentType?: ComponentType; deviceCategory?: DeviceCategory; model?: string; profile?: string; allOf?: ResolvedMatchCondition[]; anyOf?: ResolvedMatchCondition[]; } export interface ResolvedChannel { identifier: string; name?: string; category: ChannelCategory; parentIdentifier?: string; properties?: ResolvedProperty[]; staticProperties?: ResolvedStaticProperty[]; derivedProperties?: ResolvedDerivedProperty[]; } export interface ResolvedStaticProperty { identifier: PropertyCategory; name?: string; dataType: DataTypeType; format?: number[] | string[]; unit?: string; value: string | number | boolean; } export interface ResolvedDerivedProperty { identifier: PropertyCategory; name?: string; dataType: DataTypeType; format?: number[] | string[]; unit?: string; sourceProperty: PropertyCategory; derivationName?: string; inlineDerivation?: AnyDerivation; } export interface ResolvedProperty { shellyProperty: string; direction: TransformDirection; panel: ResolvedPanelProperty; transformerName?: string; inlineTransform?: InlineTransform; } export interface ResolvedPanelProperty { identifier: PropertyCategory; name?: string; dataType: DataTypeType; format?: number[] | string[]; unit?: string; settable: boolean; queryable: boolean; invalid?: string | number | boolean; } export interface MappingLoadResult { success: boolean; config?: MappingConfig; resolvedMappings?: ResolvedMapping[]; errors?: string[]; warnings?: string[]; source: string; } export type MappingSource = 'builtin' | 'user' | 'custom'; export interface MappingFileInfo { path: string; source: MappingSource; priority: number; } export interface MappingContext { componentType: ComponentType; componentKey: number; deviceCategory: DeviceCategory; model?: string; profile?: string; config?: Record; status?: Record; }