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

export const mystromDomain = "mystrom";
export const mystromDefaultName = "myStrom";
export const mystromDefaultPort = 80;
export const mystromDefaultTimeoutMs = 5000;

export type TMystromRawData = TSimpleLocalRawData;
export interface IMystromSnapshot extends ISimpleLocalSnapshot {}
export interface IMystromConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  deviceType?: number | string;
}
export interface IHomeAssistantMystromConfig extends IMystromConfig {}

export const mystromProfile: ISimpleLocalIntegrationProfile = {
  domain: mystromDomain,
  displayName: "myStrom",
  manufacturer: "myStrom",
  model: "myStrom local integration",
  defaultName: mystromDefaultName,
  defaultPort: mystromDefaultPort,
  defaultHttpPath: '/api/v1/info',
  defaultProtocol: 'http',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "light",
    "sensor",
    "switch",
  ],
  serviceDomains: [
    "light",
    "switch",
  ],
  controlServices: [
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "mystrom",
    "myStrom",
    "Mystrom",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/mystrom",
    "upstreamDomain": "mystrom",
    "integrationType": "device",
    "iotClass": "local_polling",
    "requirements": [
      "python-mystrom==2.5.0",
    ],
    "dependencies": [
      "http",
    ],
    "codeowners": [
      "@fabaff",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/mystrom",
    "loggers": [
      "pymystrom",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "binary_sensor",
        "light",
        "sensor",
        "switch",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "native local HTTP discovery and polling through /api/v1/info, /info.json, /report, /api/v1/device/{mac}, /api/v1/light, /api/v1/motion, and /temp where supported by the device type",
        "native local HTTP switch relay control through /relay?state=1|0 and /toggle",
        "native local HTTP bulb control through form-encoded /api/v1/device/{mac} action and HSV brightness payloads",
        "manual local setup for myStrom endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for myStrom device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "claiming live myStrom pairing, firmware management, button webhook subscription, or write success without a reachable documented local HTTP endpoint or injected executor",
        "Home Assistant entity registry migrations and repair flows",
        "myStrom WiFi Button push callback handling beyond documenting Home Assistant's /api/mystrom webhook behavior",
      ],
    },
  },
};
