import type { ISimpleLocalConfig, ISimpleLocalIntegrationProfile, ISimpleLocalSnapshot, TSimpleLocalRawData } from '../../core/index.js';

export const flexitDomain = 'flexit';
export const flexitDefaultName = 'Flexit';
export const flexitDefaultHub = 'modbus_hub';

export type TFlexitRawData = TSimpleLocalRawData;
export interface IFlexitSnapshot extends ISimpleLocalSnapshot {}
export interface IFlexitConfig extends ISimpleLocalConfig {
  hub?: string;
  slave?: number;
}
export interface IHomeAssistantFlexitConfig extends IFlexitConfig {}

export const flexitProfile: ISimpleLocalIntegrationProfile = {
  domain: 'flexit',
  displayName: 'Flexit',
  manufacturer: 'Flexit',
  model: 'CI66 Modbus adapter',
  defaultName: flexitDefaultName,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'climate',
  ],
  serviceDomains: [
    'climate',
  ],
  controlServices: [
    'set_fan_mode',
    'set_temperature',
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'flexit',
    'ci66',
    'modbus',
    'ventilation',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/flexit',
    upstreamDomain: 'flexit',
    iotClass: 'local_polling',
    qualityScale: 'legacy',
    requirements: [],
    dependencies: [
      'modbus',
    ],
    afterDependencies: [],
    codeowners: [],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/flexit',
    defaults: {
      hub: flexitDefaultHub,
      slaveMin: 0,
      slaveMax: 32,
      fanModes: ['Off', 'Low', 'Medium', 'High'],
      temperatureUnit: 'C',
    },
    platforms: [
      'climate',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'set_fan_mode',
        'set_temperature',
      ],
      platforms: [
        'climate',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local setup for Modbus hub/slave metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime device and climate entity mapping for Flexit CI66 snapshots',
        'safe control delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'native Modbus register reads and writes in this TypeScript package',
        'claiming target temperature or fan mode write success without an injected client.execute or commandExecutor',
        'Home Assistant YAML platform setup and Modbus hub lookup',
      ],
    },
  },
};
