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

export const onkyoDomain = "onkyo";
export const onkyoDefaultName = "Onkyo";
export const onkyoDefaultPort = 60128;
export const onkyoDefaultTimeoutMs = 5000;

export type TOnkyoRawData = TSimpleLocalRawData;
export interface IOnkyoSnapshot extends ISimpleLocalSnapshot {}
export interface IOnkyoConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantOnkyoConfig extends IOnkyoConfig {}

export const onkyoProfile: ISimpleLocalIntegrationProfile = {
  domain: onkyoDomain,
  displayName: "Onkyo",
  manufacturer: "Onkyo",
  model: "Onkyo local integration",
  defaultName: onkyoDefaultName,
  defaultPort: onkyoDefaultPort,
  defaultProtocol: 'tcp',
  status: "control-runtime",
  platforms: [
    "media_player",
    "switch",
  ],
  serviceDomains: [
    "media_player",
    "switch",
  ],
  controlServices: [
    "media_pause",
    "media_play",
    "media_stop",
    "select_source",
    "toggle",
    "turn_off",
    "turn_on",
    "volume_down",
    "volume_mute",
    "volume_set",
    "volume_up",
    "onkyo_select_hdmi_output",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "onkyo",
    "Onkyo",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/onkyo",
    "upstreamDomain": "onkyo",
    "integrationType": "device",
    "iotClass": "local_push",
    "qualityScale": "bronze",
    "requirements": [
      "aioonkyo==0.4.0",
    ],
    "dependencies": [
      "network",
    ],
    "codeowners": [
      "@arturpragacz",
      "@eclair4151",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/onkyo",
    "loggers": [
      "aioonkyo",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "media_pause",
        "media_play",
        "media_stop",
        "select_source",
        "toggle",
        "turn_off",
        "turn_on",
        "volume_down",
        "volume_mute",
        "volume_set",
        "volume_up",
        "onkyo_select_hdmi_output",
      ],
      "platforms": [
        "media_player",
        "switch",
      ],
      "controls": "native eISCP TCP commands for main-zone media controls; injected client.execute or commandExecutor remains supported",
    },
    "localApi": {
      "status": "Native Onkyo/Pioneer eISCP TCP polling and main-zone control are implemented for manual host/port configurations; UDP discovery/interview and persistent push subscriptions are not implemented.",
      "implemented": [
        "native eISCP TCP polling on port 60128 for main-zone power, volume, mute, input source, and listening mode status",
        "native eISCP TCP control for power, volume, mute, source selection, HDMI output, and NET play/pause/stop commands",
        "manual local setup for Onkyo endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Onkyo device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor when no live eISCP host is configured",
      ],
      "explicitUnsupported": [
        "UDP eISCP discovery/interview broadcast semantics; use manual host configuration or external discovery metadata",
        "persistent local_push subscription and unsolicited status update processing; this client performs focused request/response TCP polling and commands",
        "multi-zone and channel-muting switch discovery beyond main-zone eISCP status/control",
        "Home Assistant entity registry migrations and repair flows",
      ],
    },
  },
};
