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

export const inelsDomain = "inels";
export const inelsDefaultName = "iNELS";

export type TInelsRawData = TSimpleLocalRawData;
export interface IInelsSnapshot extends ISimpleLocalSnapshot {}
export interface IInelsConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}

export const inelsProfile: ISimpleLocalIntegrationProfile = {
  domain: inelsDomain,
  displayName: "iNELS",
  manufacturer: "iNELS",
  model: "iNELS local integration",
  defaultName: inelsDefaultName,
  defaultProtocol: 'mqtt',
  status: "control-runtime",
  platforms: [
    "switch",
  ],
  serviceDomains: [
    "switch",
  ],
  controlServices: [
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "inels",
    "iNELS",
    "Inels",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/inels",
    "upstreamDomain": "inels",
    "integrationType": "hub",
    "iotClass": "local_push",
    "qualityScale": "bronze",
    "requirements": [
      "elkoep-aio-mqtt==0.1.0b4",
    ],
    "dependencies": [
      "mqtt",
    ],
    "codeowners": [
      "@epdevlab",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/inels",
    "runtime": {
      "type": "control-runtime",
      "status": "snapshot/injected-client only: Home Assistant source uses MQTT broker callbacks plus the elkoep-aio-mqtt/inelsmqtt Python library, not a documented direct local HTTP/TCP/file protocol",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "switch",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor because native iNELS control is MQTT-broker based",
    },
    "localApi": {
      "status": "unsupported for live native TypeScript in this package: HA requires MQTT broker semantics and elkoep-aio-mqtt/inelsmqtt device models",
      "implemented": [
        "manual local setup for iNELS endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for iNELS device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "live iNELS discovery, state subscription, and writes from Home Assistant require MQTT broker semantics on inels/status/# plus elkoep-aio-mqtt/inelsmqtt; no direct local HTTP/TCP/TLS/file protocol is documented in HA source",
        "reimplementing inelsmqtt device state parsing or MQTT publish/subscribe flows without an MQTT broker client dependency",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
