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

export const fritzboxDomain = 'fritzbox';
export const fritzboxDefaultName = 'FRITZ!SmartHome';
export const fritzboxDefaultHost = 'fritz.box';
export const fritzboxDefaultUsername = 'admin';

export type TFritzboxRawData = TSimpleLocalRawData;
export interface IFritzboxSnapshot extends ISimpleLocalSnapshot {}
export interface IFritzboxConfig extends ISimpleLocalConfig {
  ain?: string;
}
export interface IHomeAssistantFritzboxConfig extends IFritzboxConfig {}

export const fritzboxProfile: ISimpleLocalIntegrationProfile = {
  domain: fritzboxDomain,
  displayName: 'FRITZ!SmartHome',
  manufacturer: 'AVM',
  model: 'FRITZ!SmartHome',
  defaultName: fritzboxDefaultName,
  defaultPort: 80,
  defaultProtocol: 'http',
  status: 'read-only-runtime',
  platforms: [
    'binary_sensor',
    'button',
    'climate',
    'cover',
    'light',
    'sensor',
    'switch',
  ],
  serviceDomains: [
    'binary_sensor',
    'button',
    'climate',
    'cover',
    'light',
    'sensor',
    'switch',
  ],
  controlServices: [
    'press',
    'turn_on',
    'turn_off',
    'toggle',
    'set_temperature',
    'set_hvac_mode',
    'set_preset_mode',
    'open_cover',
    'close_cover',
    'stop_cover',
    'set_cover_position',
  ],
  discoverySources: [
    'manual',
    'ssdp',
    'custom',
  ],
  discoveryKeywords: [
    'fritzbox',
    'fritz!box',
    'fritz!smarthome',
    'avm',
    'aha',
    'smart home',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/fritzbox',
    upstreamDomain: 'fritzbox',
    integrationType: 'hub',
    iotClass: 'local_polling',
    qualityScale: undefined,
    requirements: [
      'pyfritzhome==0.6.20',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@mib1185',
      '@flabbamann',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/fritzbox',
    loggers: [
      'pyfritzhome',
    ],
    ssdp: [
      {
        st: 'urn:schemas-upnp-org:device:fritzbox:1',
      },
    ],
    defaults: {
      host: fritzboxDefaultHost,
      username: fritzboxDefaultUsername,
      updateIntervalSeconds: 30,
    },
    platforms: [
      'binary_sensor',
      'button',
      'climate',
      'cover',
      'light',
      'sensor',
      'switch',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'press',
        'turn_on',
        'turn_off',
        'toggle',
        'set_temperature',
        'set_hvac_mode',
        'set_preset_mode',
        'open_cover',
        'close_cover',
        'stop_cover',
        'set_cover_position',
      ],
      platforms: [
        'binary_sensor',
        'button',
        'climate',
        'cover',
        'light',
        'sensor',
        'switch',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual and SSDP-seeded local setup for FRITZ!Box host credentials, snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime mapping for FRITZ!SmartHome device, template, trigger, sensor, binary sensor, light, climate, cover, button, and switch snapshots',
        'safe control delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'native pyfritzhome login, AHA session handling, and polling in this TypeScript package',
        'claiming FRITZ!SmartHome writes succeeded without an injected client.execute or commandExecutor',
        'Home Assistant entity registry migration and device cleanup behavior',
      ],
    },
  },
};
