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

export const lgSoundbarDomain = "lg_soundbar";
export const lgSoundbarDefaultName = "LG Soundbars";

export type TLgSoundbarRawData = TSimpleLocalRawData;
export interface ILgSoundbarSnapshot extends ISimpleLocalSnapshot {}
export interface ILgSoundbarConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantLgSoundbarConfig extends ILgSoundbarConfig {}

export const lgSoundbarProfile: ISimpleLocalIntegrationProfile = {
  domain: lgSoundbarDomain,
  displayName: "LG Soundbars",
  manufacturer: "LG Soundbars",
  model: "LG Soundbars local integration",
  defaultName: lgSoundbarDefaultName,
  defaultPort: 9741,
  defaultProtocol: 'tcp',
  status: "control-runtime",
  platforms: [
    "media_player",
  ],
  serviceDomains: [
    "media_player",
  ],
  controlServices: [
    "media_pause",
    "media_play",
    "volume_down",
    "volume_up",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "lg_soundbar",
    "LG Soundbars",
    "Lg Soundbar",
    "LG",
    "Soundbars",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/lg_soundbar",
    "upstreamDomain": "lg_soundbar",
    "integrationType": "device",
    "iotClass": "local_polling",
    "requirements": [
      "temescal==0.5",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/lg_soundbar",
    "loggers": [
      "temescal",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "media_pause",
        "media_play",
        "volume_down",
        "volume_up",
      ],
      "platforms": [
        "media_player",
      ],
      "controls": "native encrypted TCP control on port 9741 when host/url is configured; otherwise delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "native LG Soundbar encrypted TCP polling for PRODUCT_INFO, MAC_INFO_DEV, EQ_VIEW_INFO, SPK_LIST_VIEW_INFO, FUNC_VIEW_INFO, SETTING_VIEW_INFO, and PLAY_INFO on port 9741",
        "native LG Soundbar encrypted TCP controls for power, volume, mute, source, sound mode, and play/pause packets documented by temescal 0.5",
        "manual local setup for LG Soundbars endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for LG Soundbars device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor when native TCP is not configured",
      ],
      "explicitUnsupported": [
        "LG Wi-Fi speaker app discovery; Home Assistant and temescal expect mDNS/netdisco discovery outside the TCP client",
        "long-running unsolicited event subscription; native runtime performs request/response TCP polling and one-shot control writes",
        "claiming LG Soundbar command success without host/url, injected client.execute, or commandExecutor",
        "Home Assistant entity registry migrations and repair flows",
      ],
    },
  },
};
