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

export const livisiDomain = "livisi";
export const livisiDefaultName = "LIVISI Smart Home";
export const livisiDefaultPort = 8080;
export const livisiDefaultTimeoutMs = 2000;

export type TLivisiRawData = TSimpleLocalRawData;
export interface ILivisiSnapshot extends ISimpleLocalSnapshot {}
export interface ILivisiConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  ipAddress?: string;
}

export const livisiProfile: ISimpleLocalIntegrationProfile = {
  domain: livisiDomain,
  displayName: "LIVISI Smart Home",
  manufacturer: "LIVISI Smart Home",
  model: "LIVISI Smart Home local integration",
  defaultName: livisiDefaultName,
  defaultPort: livisiDefaultPort,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "climate",
    "switch",
  ],
  serviceDomains: [
    "climate",
    "switch",
  ],
  controlServices: [
    "set_hvac_mode",
    "set_temperature",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "livisi",
    "LIVISI Smart Home",
    "Livisi",
    "LIVISI",
    "Smart",
    "Home",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/livisi",
    "upstreamDomain": "livisi",
    "integrationType": "hub",
    "iotClass": "local_polling",
    "requirements": [
      "livisi==0.0.25",
    ],
    "codeowners": [
      "@StefanIacobLivisi",
      "@planbnet",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/livisi",
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "set_hvac_mode",
        "set_temperature",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "binary_sensor",
        "climate",
        "switch",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "native local HTTP polling against the LIVISI SHC /auth/token, /status, /device, /capability, /location, and capability state endpoints",
        "native local HTTP command dispatch to /action for switch onState and VRCC set_temperature services after SHC authorization succeeds",
        "manual local setup for LIVISI Smart Home snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for LIVISI Smart Home device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor when no SHC HTTP endpoint is configured",
      ],
      "explicitUnsupported": [
        "LIVISI websocket event subscription: Home Assistant uses the livisi Python websockets client and this repository has no WebSocket client dependency; polling remains local HTTP",
        "LIVISI pairing/bootstrap flows beyond using an already configured local SHC host and admin password/token",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
