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

export const kebaDomain = "keba";
export const kebaDefaultName = "Keba Charging Station";

export type TKebaRawData = TSimpleLocalRawData;
export interface IKebaSnapshot extends ISimpleLocalSnapshot {}
export interface IKebaConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantKebaConfig extends IKebaConfig {}

export const kebaProfile: ISimpleLocalIntegrationProfile = {
  domain: kebaDomain,
  displayName: "Keba Charging Station",
  manufacturer: "Keba Charging Station",
  model: "Keba Charging Station local integration",
  defaultName: kebaDefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "sensor",
    "switch",
  ],
  serviceDomains: [
    "switch",
  ],
  controlServices: [
    "authorize",
    "deauthorize",
    "disable",
    "enable",
    "request_data",
    "set_current",
    "set_energy",
    "set_failsafe",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "keba",
    "Keba Charging Station",
    "Keba",
    "Charging",
    "Station",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/keba",
    "upstreamDomain": "keba",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [
      "keba-kecontact==1.3.0",
    ],
    "codeowners": [
      "@dannerph",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/keba",
    "loggers": [
      "keba_kecontact",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "authorize",
        "deauthorize",
        "disable",
        "enable",
        "request_data",
        "set_current",
        "set_energy",
        "set_failsafe",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "binary_sensor",
        "sensor",
        "switch",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor; native KEBA KeContact UDP control is not implemented in this TypeScript port",
    },
    "localApi": {
      "status": "blocked: Home Assistant delegates to keba-kecontact, whose documented local protocol is KEBA KeContact UDP via asyncio-dgram; this repo exposes no shared UDP/dgram helper and this assignment is limited to HTTP/TCP/TLS/file-capable local protocols.",
      "implemented": [
        "manual local setup for Keba Charging Station snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Keba Charging Station device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native live KEBA polling/control: Home Assistant uses keba-kecontact==1.3.0, which documents KEBA KeContact UDP commands and depends on asyncio-dgram; no HTTP/TCP/TLS/file protocol is exposed by the HA source",
        "adding ad-hoc node:dgram UDP transport in this domain while shared plugins only expose net/tls/fs and the requested implementation scope excludes UDP",
        "claiming live Keba Charging Station polling, pairing, subscription, or write success without an injected native client or snapshotProvider",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
