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

export const nikoHomeControlDomain = "niko_home_control";
export const nikoHomeControlDefaultName = "Niko Home Control";

export type TNikoHomeControlRawData = TSimpleLocalRawData;
export interface INikoHomeControlSnapshot extends ISimpleLocalSnapshot {}
export interface INikoHomeControlConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  protocol?: 'tcp';
}
export interface IHomeAssistantNikoHomeControlConfig extends INikoHomeControlConfig {}

export const nikoHomeControlProfile: ISimpleLocalIntegrationProfile = {
  domain: nikoHomeControlDomain,
  displayName: "Niko Home Control",
  manufacturer: "Niko Home Control",
  model: "Niko Home Control local integration",
  defaultName: nikoHomeControlDefaultName,
  defaultPort: 8000,
  defaultProtocol: 'tcp',
  status: "control-runtime",
  platforms: [
    "button",
    "climate",
    "cover",
    "light",
  ],
  serviceDomains: [
    "button",
    "climate",
    "cover",
    "light",
  ],
  controlServices: [
    "close_cover",
    "open_cover",
    "press",
    "set_hvac_mode",
    "set_temperature",
    "stop_cover",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "niko_home_control",
    "Niko Home Control",
    "Niko",
    "Home",
    "Control",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/niko_home_control",
    "upstreamDomain": "niko_home_control",
    "integrationType": "hub",
    "iotClass": "local_push",
    "requirements": [
      "nhc==0.8.0",
    ],
    "codeowners": [
      "@VandeurenGlenn",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/niko_home_control",
    "loggers": [
      "nikohomecontrol",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "close_cover",
        "open_cover",
        "press",
        "set_hvac_mode",
        "set_temperature",
        "stop_cover",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "button",
        "climate",
        "cover",
        "light",
      ],
      "controls": "native TCP JSON executeactions/executethermostat for addressed entities, or delegated to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "status": "native TCP JSON request/response client implemented for controller snapshots and addressed commands on port 8000; continuous event subscription is not claimed",
      "implemented": [
        "native Niko Home Control TCP JSON snapshot reads using listlocations, listthermostat, listenergy, systeminfo, and listactions",
        "native addressed commands using executeactions for lights/covers/scenes and executethermostat for thermostat mode/setpoint",
        "manual local setup for Niko Home Control endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Niko Home Control device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor when no live endpoint is configured",
      ],
      "explicitUnsupported": [
        "claiming continuous Home Assistant-style local_push event subscription; this client performs explicit TCP request/response snapshots and addressed commands",
        "claiming pairing or cloud setup; the HA integration only documents a local host and nhc TCP controller connection",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without either a live TCP write or injected client.execute/commandExecutor",
      ],
    },
  },
};
