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

export const lupusecDomain = "lupusec";
export const lupusecDefaultName = "Lupus Electronics LUPUSEC";

export type TLupusecRawData = TSimpleLocalRawData;
export interface ILupusecSnapshot extends ISimpleLocalSnapshot {}
export interface ILupusecConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  model?: 1 | 2;
}
export interface IHomeAssistantLupusecConfig extends ILupusecConfig {}

export const lupusecProfile: ISimpleLocalIntegrationProfile = {
  domain: lupusecDomain,
  displayName: "Lupus Electronics LUPUSEC",
  manufacturer: "Lupus Electronics LUPUSEC",
  model: "Lupus Electronics LUPUSEC local integration",
  defaultName: lupusecDefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "sensor",
    "switch",
  ],
  serviceDomains: [
    "switch",
  ],
  controlServices: [
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "lupusec",
    "Lupus Electronics LUPUSEC",
    "Lupusec",
    "Lupus",
    "Electronics",
    "LUPUSEC",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/lupusec",
    "upstreamDomain": "lupusec",
    "integrationType": "hub",
    "iotClass": "local_polling",
    "requirements": [
      "lupupy==0.3.2",
    ],
    "codeowners": [
      "@majuss",
      "@suaveolent",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/lupusec",
    "loggers": [
      "lupupy",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "binary_sensor",
        "sensor",
        "switch",
      ],
      "polling": "native local HTTP reads for XT1/XT2 panelCondGet and device/sensor lists when host, username, and password are configured",
      "controls": "read-only natively; writes are delegated only to an injected client.execute or commandExecutor because lupupy does not implement a documented local power-switch write endpoint",
    },
    "localApi": {
      "status": "native read-only HTTP implemented; native writes blocked without documented LUPUSEC switch endpoint",
      "implemented": [
        "native local HTTP XT2 tokenGet, panelCondGet, and deviceListGet snapshot reads using Basic auth plus X-Token",
        "native local HTTP XT1 model detection and sensorListGet/panelCondGet reads when responses are JSON-compatible",
        "manual local setup for Lupus Electronics LUPUSEC endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Lupus Electronics LUPUSEC device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native LUPUSEC power-switch writes because HA/lupupy 0.3.2 leaves LupusecDevice.set_status unimplemented and no documented local write endpoint is present in the HA source",
        "XT1 YAML-style response parsing without an injected snapshotProvider because no YAML parser dependency is available",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
