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

export const kankunDomain = "kankun";
export const kankunDefaultName = "Kankun";

export type TKankunRawData = TSimpleLocalRawData;
export interface IKankunSnapshot extends ISimpleLocalSnapshot {}
export interface IKankunConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantKankunConfig extends IKankunConfig {}

export const kankunProfile: ISimpleLocalIntegrationProfile = {
  domain: kankunDomain,
  displayName: "Kankun",
  manufacturer: "Kankun",
  model: "Kankun local integration",
  defaultName: kankunDefaultName,
  defaultPort: 80,
  defaultHttpPath: '/cgi-bin/json.cgi',
  defaultProtocol: 'http',
  status: "control-runtime",
  platforms: [
    "switch",
  ],
  serviceDomains: [
    "switch",
  ],
  controlServices: [
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "kankun",
    "Kankun",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/kankun",
    "upstreamDomain": "kankun",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/kankun",
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "switch",
      ],
        "controls": "native local HTTP GET json.cgi?set=on/off control with injected executor fallback",
    },
    "localApi": {
      "implemented": [
        "native local HTTP GET /cgi-bin/json.cgi?get=state polling compatible with Home Assistant Kankun json.cgi usage",
        "native local HTTP GET /cgi-bin/json.cgi?set=on and ?set=off control with optional Basic authentication",
        "runtime mapping for Kankun device snapshots and Home Assistant platform metadata",
        "manual snapshots, rawData, snapshotProvider, injected native clients, and commandExecutor fallback",
      ],
      "explicitUnsupported": [
        "unmodified Kankun SP3 devices that do not expose the Home Assistant documented json.cgi HTTP API",
        "HTTPS/TLS transport; Home Assistant kankun constructs http:// json.cgi URLs only",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without a truthy json.cgi ok response, injected client.execute, or commandExecutor",
      ],
    },
  },
};
