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

export const palazzettiDomain = "palazzetti";
export const palazzettiDefaultName = "Palazzetti";
export const palazzettiDefaultPort = 80;

export type TPalazzettiRawData = TSimpleLocalRawData;
export interface IPalazzettiSnapshot extends ISimpleLocalSnapshot {}
export interface IPalazzettiConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantPalazzettiConfig extends IPalazzettiConfig {}

export const palazzettiProfile: ISimpleLocalIntegrationProfile = {
  domain: palazzettiDomain,
  displayName: "Palazzetti",
  manufacturer: "Palazzetti",
  model: "Palazzetti local integration",
  defaultName: palazzettiDefaultName,
  defaultPort: palazzettiDefaultPort,
  defaultProtocol: 'http',
  status: "control-runtime",
  platforms: [
    "button",
    "climate",
    "number",
    "sensor",
  ],
  serviceDomains: [
    "button",
    "climate",
    "number",
  ],
  controlServices: [
    "press",
    "set_hvac_mode",
    "set_fan_mode",
    "set_temperature",
    "set_value",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'dhcp',
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "palazzetti",
    "Palazzetti",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/palazzetti",
    "upstreamDomain": "palazzetti",
    "integrationType": "device",
    "iotClass": "local_polling",
    "requirements": [
      "pypalazzetti==0.1.20",
    ],
    "codeowners": [
      "@dotvav",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/palazzetti",
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "press",
        "set_hvac_mode",
        "set_fan_mode",
        "set_temperature",
        "set_value",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "button",
        "climate",
        "number",
        "sensor",
      ],
      "controls": "native local sendmsg HTTP when config.host/config.url is set; otherwise delegated to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "native HTTP polling and controls through the Palazzetti Connection Box/WPalaControl /cgi-bin/sendmsg.lua API used by Home Assistant",
        "manual local setup for Palazzetti endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for live Palazzetti climate, button, number, and sensor snapshots and Home Assistant platform metadata",
        "safe fallback command delegation to injected client.execute or commandExecutor",
      ],
      "explicitUnsupported": [
        "Palazzetti cloud/pairing flows; Home Assistant uses the local Connection Box/WPalaControl HTTP API",
        "TLS, UDP, serial, or undocumented binary transports not present in the Home Assistant integration or pypalazzetti client",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
