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

export const pglabDomain = "pglab";
export const pglabDefaultName = "PG LAB Electronics";

export type TPglabRawData = TSimpleLocalRawData;
export interface IPglabSnapshot extends ISimpleLocalSnapshot {}
export interface IPglabConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantPglabConfig extends IPglabConfig {}

export const pglabProfile: ISimpleLocalIntegrationProfile = {
  domain: pglabDomain,
  displayName: "PG LAB Electronics",
  manufacturer: "PG LAB Electronics",
  model: "PG LAB Electronics local integration",
  defaultName: pglabDefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "cover",
    "sensor",
    "switch",
  ],
  serviceDomains: [
    "cover",
    "switch",
  ],
  controlServices: [
    "close_cover",
    "open_cover",
    "stop_cover",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "pglab",
    "PG LAB Electronics",
    "Pglab",
    "PG",
    "LAB",
    "Electronics",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/pglab",
    "upstreamDomain": "pglab",
    "integrationType": "hub",
    "iotClass": "local_push",
    "qualityScale": "bronze",
    "requirements": [
      "pypglab==0.0.5",
    ],
    "dependencies": [
      "mqtt",
    ],
    "codeowners": [
      "@pglab-electronics",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/pglab",
    "loggers": [
      "pglab",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "close_cover",
        "open_cover",
        "stop_cover",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "cover",
        "sensor",
        "switch",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "status": "Blocked for native live client: Home Assistant pglab uses pypglab over the MQTT integration with pglab/discovery/# subscriptions and publish/subscribe callbacks; no direct HTTP/TCP/TLS/file protocol is documented in the HA source.",
      "implemented": [
        "manual local setup for PG LAB Electronics snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for PG LAB Electronics device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native PG LAB live discovery/subscription/control requires pypglab==0.0.5 plus Home Assistant MQTT broker semantics through mqtt.async_publish, async_prepare_subscribe_topics, async_subscribe_topics, and async_unsubscribe_topics",
        "claiming relay/shutter write success without MQTT publish/subscribe acknowledgement from pypglab or an injected client.execute/commandExecutor",
        "direct HTTP/TCP/TLS/file polling; HA source exposes only MQTT topic pglab/discovery/# and pypglab device/entity abstractions",
        "Home Assistant entity registry migrations and repair flows",
      ],
    },
  },
};
