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

export const hassioDomain = 'hassio';
export const hassioDefaultName = 'Home Assistant Supervisor';

export type THassioRawData = TSimpleLocalRawData;
export interface IHassioSnapshot extends ISimpleLocalSnapshot {}
export interface IHassioConfig extends ISimpleLocalConfig {
  supervisor?: string;
  supervisorToken?: string;
}
export interface IHomeAssistantHassioConfig extends IHassioConfig {}

export const hassioProfile: ISimpleLocalIntegrationProfile = {
  domain: 'hassio',
  displayName: 'Home Assistant Supervisor',
  manufacturer: 'Home Assistant',
  model: 'Home Assistant Supervisor',
  defaultName: hassioDefaultName,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'binary_sensor',
    'sensor',
    'switch',
    'update',
  ],
  serviceDomains: [
    'hassio',
    'switch',
    'update',
  ],
  controlServices: [
    'addon_restart',
    'addon_start',
    'addon_stdin',
    'addon_stop',
    'app_restart',
    'app_start',
    'app_stdin',
    'app_stop',
    'backup_full',
    'backup_partial',
    'host_reboot',
    'host_shutdown',
    'install',
    'mount_reload',
    'restore_full',
    'restore_partial',
    'turn_off',
    'turn_on',
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'hassio',
    'supervisor',
    'home assistant supervisor',
    'hassos',
    'addon',
    'add-on',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/hassio',
    upstreamDomain: 'hassio',
    iotClass: 'local_polling',
    qualityScale: 'internal',
    requirements: [
      'aiohasupervisor==0.4.3',
    ],
    dependencies: [
      'http',
      'repairs',
    ],
    afterDependencies: [],
    codeowners: [
      '@home-assistant/supervisor',
    ],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/hassio',
    singleConfigEntry: true,
    homeAssistantPlatforms: [
      'binary_sensor',
      'sensor',
      'switch',
      'update',
    ],
    defaults: {
      supervisorEnv: 'SUPERVISOR',
      supervisorTokenEnv: 'SUPERVISOR_TOKEN',
      mainUpdateIntervalMinutes: 5,
      addonUpdateIntervalMinutes: 15,
      statsUpdateIntervalSeconds: 60,
    },
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'addon_restart',
        'addon_start',
        'addon_stdin',
        'addon_stop',
        'app_restart',
        'app_start',
        'app_stdin',
        'app_stop',
        'backup_full',
        'backup_partial',
        'host_reboot',
        'host_shutdown',
        'install',
        'mount_reload',
        'restore_full',
        'restore_partial',
        'turn_off',
        'turn_on',
      ],
      platforms: [
        'binary_sensor',
        'sensor',
        'switch',
        'update',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local setup for Supervisor snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime device and entity mapping for Supervisor, Core, OS, host, add-on, mount, and stats snapshots',
        'safe Supervisor command delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'direct aiohasupervisor API calls, environment-token proxying, ingress, websocket, auth, backup, and repairs orchestration in this TypeScript package',
        'claiming add-on, app, host, backup, restore, mount, update, or switch command success without injected client.execute or commandExecutor',
        'Home Assistant config-entry, device-registry, and Supervisor event lifecycle management',
      ],
    },
  },
};
