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

export const kaleidescapeDomain = "kaleidescape";
export const kaleidescapeDefaultName = "Kaleidescape";

export type TKaleidescapeRawData = TSimpleLocalRawData;
export interface IKaleidescapeSnapshot extends ISimpleLocalSnapshot {}
export interface IKaleidescapeConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantKaleidescapeConfig extends IKaleidescapeConfig {}

export const kaleidescapeProfile: ISimpleLocalIntegrationProfile = {
  domain: kaleidescapeDomain,
  displayName: "Kaleidescape",
  manufacturer: "Kaleidescape",
  model: "Kaleidescape local integration",
  defaultName: kaleidescapeDefaultName,
  defaultPort: 10000,
  defaultProtocol: 'tcp',
  status: "control-runtime",
  platforms: [
    "button",
    "media_player",
    "sensor",
  ],
  serviceDomains: [
    "button",
    "media_player",
    "remote",
  ],
  controlServices: [
    "media_next_track",
    "media_pause",
    "media_play",
    "media_previous_track",
    "media_stop",
    "press",
    "send_command",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "kaleidescape",
    "Kaleidescape",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/kaleidescape",
    "upstreamDomain": "kaleidescape",
    "integrationType": "device",
    "iotClass": "local_push",
    "requirements": [
      "pykaleidescape==1.1.5",
    ],
    "codeowners": [
      "@SteveEasley",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/kaleidescape",
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "media_next_track",
        "media_pause",
        "media_play",
        "media_previous_track",
        "media_stop",
        "press",
        "send_command",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "button",
        "media_player",
        "sensor",
      ],
      "controls": "native local TCP System Control Protocol commands with injected executor fallback",
    },
    "localApi": {
      "implemented": [
        "native local TCP polling over the Kaleidescape System Control Protocol on port 10000",
        "native local TCP media, power, and remote control commands used by Home Assistant pykaleidescape 1.1.5",
        "runtime mapping for Kaleidescape device snapshots and Home Assistant platform metadata",
        "manual snapshots, rawData, snapshotProvider, injected native clients, and commandExecutor fallback",
      ],
      "explicitUnsupported": [
        "TLS transport; Home Assistant pykaleidescape uses plain local TCP",
        "long-lived Home Assistant dispatcher event subscription semantics beyond request/response polling",
        "server-only Kaleidescape devices without a movie zone as controllable media players",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without a successful protocol response, injected client.execute, or commandExecutor",
      ],
    },
  },
};
