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

export const plugwiseDomain = "plugwise";
export const plugwiseDefaultName = "Plugwise";
export const plugwiseDefaultPort = 80;
export const plugwiseDefaultUsername = "smile";
export const plugwiseDomainObjectsPath = "/core/domain_objects";

export type TPlugwiseRawData = TSimpleLocalRawData;
export interface IPlugwiseSnapshot extends ISimpleLocalSnapshot {}
export interface IPlugwiseConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  domainObjectsPath?: string;
}
export interface IHomeAssistantPlugwiseConfig extends IPlugwiseConfig {}

export const plugwiseProfile: ISimpleLocalIntegrationProfile = {
  domain: plugwiseDomain,
  displayName: "Plugwise",
  manufacturer: "Plugwise",
  model: "Plugwise local integration",
  defaultName: plugwiseDefaultName,
  defaultPort: plugwiseDefaultPort,
  defaultHttpPath: plugwiseDomainObjectsPath,
  defaultProtocol: 'http',
  status: "read-only-runtime",
  platforms: [
    "binary_sensor",
    "button",
    "climate",
    "number",
    "select",
    "sensor",
    "switch",
  ],
  serviceDomains: [
    "button",
    "climate",
    "number",
    "select",
    "switch",
  ],
  controlServices: [
    "press",
    "select_option",
    "set_hvac_mode",
    "set_temperature",
    "set_value",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'mdns',
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "plugwise",
    "Plugwise",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/plugwise",
    "upstreamDomain": "plugwise",
    "integrationType": "hub",
    "iotClass": "local_polling",
    "qualityScale": "platinum",
    "requirements": [
      "plugwise==1.11.3",
    ],
    "codeowners": [
      "@CoMPaTech",
      "@bouwew",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/plugwise",
    "loggers": [
      "plugwise",
    ],
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "press",
        "select_option",
        "set_hvac_mode",
        "set_temperature",
        "set_value",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "binary_sensor",
        "button",
        "climate",
        "number",
        "select",
        "sensor",
        "switch",
      ],
      "controls": "native HTTP polling is read-only; control writes require injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "native Plugwise Smile HTTP Basic-auth polling of /core/domain_objects for read-only XML snapshots",
        "safe generic mapping of gateway metadata and XML measurement values into snapshot entities",
        "manual local setup for Plugwise endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Plugwise device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor",
      ],
      "explicitUnsupported": [
        "native Plugwise climate/switch/select/number writes because Home Assistant delegates ID resolution and XML payload semantics to the unavailable plugwise Python library",
        "full Home Assistant Plugwise entity parity because the raw XML schema is device-specific and parsed by the unavailable plugwise Python library",
        "Plugwise USB Stick serial support because Home Assistant documents it as unsupported and it requires a serial/BLE-style stack outside the local HTTP Smile API",
        "Home Assistant entity registry migrations and repair flows",
        "claiming write success without injected client.execute or commandExecutor",
      ],
    },
  },
};
