import { ChannelCategory, DataTypeType, DeviceCategory, PropertyCategory } from '../../../modules/devices/devices.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 { expose_type?: string; property?: string; is_list?: boolean; has_features?: string[]; any_property?: string[]; model?: string; manufacturer?: 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 FeatureMapping { z2m_feature: string; type?: 'simple' | 'composite'; direction?: TransformDirection; panel?: PanelPropertyConfig; transformer?: string; transform?: InlineTransform; nested_features?: FeatureMapping[]; } export interface PropertyMapping { z2m_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; features?: FeatureMapping[]; properties?: PropertyMapping[]; static_properties?: StaticPropertyConfig[]; derived_properties?: DerivedPropertyConfig[]; } export interface MappingDefinition { name: string; description?: string; priority?: number; match: MatchCondition; device_category: string; channels: ChannelMapping[]; } export interface ResolvedMapping { name: string; description?: string; priority: number; match: MatchCondition; deviceCategory: DeviceCategory; channels: ResolvedChannel[]; } export interface ResolvedChannel { identifier: string; name?: string; category: ChannelCategory; parentIdentifier?: string; features?: ResolvedFeature[]; 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 ResolvedFeature { z2mFeature: string; type: 'simple' | 'composite'; direction: TransformDirection; panel?: ResolvedPanelProperty; transformerName?: string; inlineTransform?: InlineTransform; nestedFeatures?: ResolvedFeature[]; } export interface ResolvedProperty { z2mProperty: 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; }