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

export const incomfortDomain = "incomfort";
export const incomfortDefaultName = "Intergas gateway";

export type TIncomfortRawData = TSimpleLocalRawData;
export interface IIncomfortSnapshot extends ISimpleLocalSnapshot {}
export interface IIncomfortConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}

export const incomfortProfile: ISimpleLocalIntegrationProfile = {
  domain: incomfortDomain,
  displayName: "Intergas gateway",
  manufacturer: "Intergas",
  model: "InComfort/Intouch Lan2RF gateway",
  defaultName: incomfortDefaultName,
  defaultPort: 80,
  defaultHttpPath: 'heaterlist.json',
  defaultProtocol: 'http',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "climate",
    "sensor",
  ],
  serviceDomains: [
    "climate",
  ],
  controlServices: [
    "set_hvac_mode",
    "set_temperature",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "incomfort",
    "Intergas gateway",
    "Incomfort",
    "Intergas",
    "gateway",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/incomfort",
    "upstreamDomain": "incomfort",
    "integrationType": "hub",
    "iotClass": "local_polling",
    "qualityScale": "platinum",
    "requirements": [
      "incomfort-client==0.7.0",
    ],
    "codeowners": [
      "@jbouwh",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/incomfort",
    "loggers": [
      "incomfortclient",
    ],
    "runtime": {
      "type": "control-runtime",
      "polling": "native local HTTP requests to /heaterlist.json and /data.json?heater=n",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "set_temperature",
        "set_hvac_mode",
      ],
      "platforms": [
        "binary_sensor",
        "climate",
        "sensor",
      ],
      "controls": "set_temperature uses the documented gateway HTTP setpoint endpoint; set_hvac_mode is not a gateway operation and remains delegated/unsupported unless an executor is injected",
    },
    "localApi": {
      "implemented": [
        "native local HTTP polling of Intergas Lan2RF /heaterlist.json and per-heater /data.json?heater=n endpoints",
        "runtime mapping for boiler binary sensors, temperature/pressure/RSSI sensors, and thermostat climate entities",
        "native thermostat set_temperature through /data.json?heater=n&thermostat=m&setpoint=x",
        "manual rawData/snapshot/snapshotProvider and injected native client fallbacks remain supported",
      ],
      "explicitUnsupported": [
        "live pairing or gateway/heater binding repair; Home Assistant relies on the gateway's existing Lan2RF binding and raises InvalidHeaterList when no heaters are bound",
        "set_hvac_mode as a live gateway write; the Home Assistant method is a no-op because only heat mode is exposed by the protocol",
        "native water_heater platform entities because the current shared TypeScript platform union has no water_heater platform; boiler status is exposed as sensors and attributes",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success for unsupported services without an injected client.execute or commandExecutor",
      ],
    },
  },
};
