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

export const overkizDomain = "overkiz";
export const overkizDefaultName = "Overkiz";

export type TOverkizRawData = TSimpleLocalRawData;
export interface IOverkizSnapshot extends ISimpleLocalSnapshot {}
export interface IOverkizConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  accessToken?: string;
  apiType?: 'local' | 'cloud';
  protocol?: 'http' | 'https';
  verifySsl?: boolean;
}
export interface IHomeAssistantOverkizConfig extends IOverkizConfig {}

export const overkizProfile: ISimpleLocalIntegrationProfile = {
  domain: overkizDomain,
  displayName: "Overkiz",
  manufacturer: "Overkiz",
  model: "Overkiz local integration",
  defaultName: overkizDefaultName,
  defaultPort: 8443,
  defaultProtocol: 'https',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "button",
    "cover",
    "light",
    "number",
    "select",
    "sensor",
    "switch",
  ],
  serviceDomains: [
    "button",
    "cover",
    "light",
    "number",
    "select",
    "switch",
  ],
  controlServices: [
    "close_cover",
    "execute_command",
    "open_cover",
    "press",
    "select_option",
    "set_cover_position_and_tilt",
    "set_value",
    "stop_cover",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "overkiz",
    "Overkiz",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/overkiz",
    "upstreamDomain": "overkiz",
    "integrationType": "hub",
    "iotClass": "local_polling",
    "requirements": [
      "pyoverkiz==1.20.0",
    ],
    "codeowners": [
      "@imicknl",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/overkiz",
    "loggers": [
      "boto3",
      "botocore",
      "pyhumps",
      "pyoverkiz",
      "s3transfer",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "close_cover",
        "execute_command",
        "open_cover",
        "press",
        "select_option",
        "set_cover_position_and_tilt",
        "set_value",
        "stop_cover",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "binary_sensor",
        "button",
        "cover",
        "light",
        "number",
        "select",
        "sensor",
        "switch",
      ],
      "polling": "local Somfy Developer Mode API snapshots via /enduser-mobile-web/1/enduserAPI/setup with Bearer token authentication",
      "controls": "execute_command and basic mapped on/off/open/close/stop services use local exec/apply when data.deviceUrl is provided; other controls require an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "GET /enduser-mobile-web/1/enduserAPI/setup against Somfy Developer Mode local gateways with Bearer token authentication",
        "POST /enduser-mobile-web/1/enduserAPI/exec/apply for native execute_command and basic mapped on/off/open/close/stop services when data.deviceUrl is provided",
        "runtime mapping for Overkiz gateway/device state snapshots and Home Assistant platform metadata",
        "manual snapshots, rawData, snapshotProvider, and injected native clients",
      ],
      "explicitUnsupported": [
        "Overkiz cloud login/OAuth/Cognito authentication because it requires pyoverkiz cloud auth dependencies and vendor cloud flows",
        "local token generation or activation because it requires a cloud-authenticated account before the local gateway token exists",
        "event listener long-polling parity and scenario execution beyond explicit execute_command calls",
        "TLS certificate bypass/custom CA injection in native fetch; local HTTPS requires a trusted gateway certificate or external Node CA configuration",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without a local Developer Mode token, injected client.execute, or commandExecutor",
      ],
    },
  },
};
