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

export const indevoltDomain = "indevolt";
export const indevoltDefaultName = "Indevolt";

export type TIndevoltRawData = TSimpleLocalRawData;
export interface IIndevoltSnapshot extends ISimpleLocalSnapshot {}
export interface IIndevoltConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}

export const indevoltProfile: ISimpleLocalIntegrationProfile = {
  domain: indevoltDomain,
  displayName: "Indevolt",
  manufacturer: "Indevolt",
  model: "Indevolt local integration",
  defaultName: indevoltDefaultName,
  defaultPort: 8080,
  defaultHttpPath: 'rpc/Sys.GetConfig',
  defaultProtocol: 'http',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "button",
    "number",
    "select",
    "sensor",
    "switch",
  ],
  serviceDomains: [
    "button",
    "number",
    "select",
    "switch",
  ],
  controlServices: [
    "charge",
    "discharge",
    "press",
    "select_option",
    "set_value",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "indevolt",
    "Indevolt",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/indevolt",
    "upstreamDomain": "indevolt",
    "integrationType": "device",
    "iotClass": "local_polling",
    "qualityScale": "silver",
    "requirements": [
      "indevolt-api==1.7.1",
    ],
    "codeowners": [
      "@xirt",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/indevolt",
    "runtime": {
      "type": "control-runtime",
      "polling": "native local HTTP RPC under /rpc/Sys.GetConfig, /rpc/Indevolt.GetData, and /rpc/Indevolt.SetData",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "charge",
        "discharge",
        "press",
        "select_option",
        "set_value",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "binary_sensor",
        "button",
        "number",
        "select",
        "sensor",
        "switch",
      ],
      "controls": "native HTTP RPC for charge/discharge/stop, energy mode select, writable numbers, and switches; unsupported services remain delegated only to injected executors",
    },
    "localApi": {
      "implemented": [
        "native local HTTP polling of /rpc/Sys.GetConfig and /rpc/Indevolt.GetData?config={...}",
        "native local HTTP writes through /rpc/Indevolt.SetData?config={...} for documented cJson points",
        "runtime mapping for Indevolt sensors, binary sensors, number/select/switch controls, and stop button metadata",
        "manual rawData/snapshot/snapshotProvider and injected native client fallbacks remain supported",
      ],
      "explicitUnsupported": [
        "UDP active/passive discovery from indevolt-api; this package currently implements the documented HTTP RPC path only and does not add node dgram plumbing",
        "pairing or cloud onboarding; Home Assistant only documents local HTTP RPC against an already reachable device",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success for unsupported services without a successful HTTP SetData result or injected client.execute/commandExecutor",
      ],
    },
  },
};
