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

export const eurotronicCometblueDomain = 'eurotronic_cometblue';
export const eurotronicCometblueDefaultName = 'Eurotronic Comet Blue';
export const eurotronicCometblueControlServices = [
  'set_temperature',
  'set_hvac_mode',
  'set_preset_mode',
  'turn_on',
  'turn_off',
  'press',
];

export type TEurotronicCometblueRawData = TSimpleLocalRawData;
export interface IEurotronicCometblueSnapshot extends ISimpleLocalSnapshot {}
export interface IEurotronicCometblueConfig extends ISimpleLocalConfig {
  address?: string;
  pin?: string | number;
}
export interface IHomeAssistantEurotronicCometblueConfig extends IEurotronicCometblueConfig {}

export const eurotronicCometblueProfile: ISimpleLocalIntegrationProfile = {
  domain: 'eurotronic_cometblue',
  displayName: 'Eurotronic Comet Blue',
  manufacturer: 'Eurotronic',
  model: 'Comet Blue',
  defaultName: eurotronicCometblueDefaultName,
  defaultProtocol: 'local',
  status: 'control-runtime',
  platforms: [
    'climate',
    'sensor',
    'button',
  ],
  serviceDomains: [
    'climate',
    'button',
  ],
  controlServices: eurotronicCometblueControlServices,
  discoverySources: [
    'manual',
    'bluetooth',
    'custom',
  ],
  discoveryKeywords: [
    'eurotronic',
    'comet blue',
    'cometblue',
    '47e9ee00-47e9-11e4-8939-164230d1df67',
    'bluetooth trv',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/eurotronic_cometblue',
    upstreamDomain: 'eurotronic_cometblue',
    integrationType: 'device',
    iotClass: 'local_polling',
    qualityScale: 'bronze',
    qualityScaleRulesPath: 'homeassistant/components/eurotronic_cometblue/quality_scale.yaml',
    requirements: [
      'eurotronic-cometblue-ha==1.4.0',
    ],
    dependencies: [
      'bluetooth',
    ],
    afterDependencies: [],
    codeowners: [
      '@rikroe',
    ],
    configFlow: true,
    bluetooth: [
      {
        connectable: true,
        service_uuid: '47e9ee00-47e9-11e4-8939-164230d1df67',
      },
    ],
    loggers: [
      'eurotronic_cometblue_ha',
    ],
    runtime: {
      type: 'control-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        ...eurotronicCometblueControlServices,
      ],
      platforms: [
        'climate',
        'sensor',
        'button',
      ],
      controls: true,
    },
    localApi: {
      implemented: [
        'manual Bluetooth snapshot setup from discovered device metadata, snapshots, rawData, snapshotProvider, and injected native clients',
        'generic local read runtime for thermostat, battery, and sync-time button snapshots',
        'executor-gated thermostat and sync-time button commands through injected client.execute or commandExecutor',
      ],
      explicitUnsupported: [
        'claiming live command success without injected client.execute or commandExecutor',
        'validating the Bluetooth PIN or opening BLE sessions without an injected native client or snapshotProvider',
        'cloud account flows and remote API polling',
      ],
    },
  },
};
