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

export const mediaroomDomain = "mediaroom";
export const mediaroomDefaultName = "Mediaroom";
export const mediaroomDefaultPort = 8082;

export type TMediaroomRawData = TSimpleLocalRawData;
export interface IMediaroomSnapshot extends ISimpleLocalSnapshot {}
export interface IMediaroomConfig extends ISimpleLocalConfig {
  url?: string;
  optimistic?: boolean;
  keyDelayMs?: number;
  macAddress?: string;
  deviceId?: string;
}

export const mediaroomProfile: ISimpleLocalIntegrationProfile = {
  domain: mediaroomDomain,
  displayName: "Mediaroom",
  manufacturer: "Mediaroom",
  model: "Mediaroom local integration",
  defaultName: mediaroomDefaultName,
  defaultPort: mediaroomDefaultPort,
  defaultProtocol: 'tcp',
  status: "control-runtime",
  platforms: [
    "media_player",
  ],
  serviceDomains: [
    "media_player",
  ],
  controlServices: [
    "turn_on",
    "turn_off",
    "media_pause",
    "media_play",
    "media_stop",
    "media_next_track",
    "media_previous_track",
    "play_media",
    "volume_mute",
    "volume_down",
    "volume_up",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "mediaroom",
    "Mediaroom",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/mediaroom",
    "upstreamDomain": "mediaroom",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [
      "pymediaroom==0.6.5.4",
    ],
    "codeowners": [
      "@dgomes",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/mediaroom",
    "loggers": [
      "pymediaroom",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "turn_on",
        "turn_off",
        "media_pause",
        "media_play",
        "media_stop",
        "media_next_track",
        "media_previous_track",
        "play_media",
        "volume_mute",
        "volume_down",
        "volume_up",
      ],
      "platforms": [
        "media_player",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "native TCP control on port 8082 using the pymediaroom key=<code> protocol for power, playback, channel, program, mute, and volume commands",
        "TCP reachability snapshots for configured Mediaroom STBs without inventing playback state",
        "runtime mapping for Mediaroom media_player snapshots and Home Assistant platform metadata",
        "safe snapshot/rawData/snapshotProvider/injected-client operation when no live endpoint is configured",
      ],
      "explicitUnsupported": [
        "pymediaroom UDP multicast NOTIFY state subscription/discovery on 239.255.255.250:8082; the current TypeScript runtime uses the approved TCP path and does not claim live channel/state updates",
        "claiming a known playback state from TCP reachability alone unless optimistic/manual snapshot data supplies it",
        "Home Assistant entity registry migrations and repair flows",
        "undocumented Mediaroom features outside the published pymediaroom command key table",
      ],
    },
  },
};
