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

export const libreHardwareMonitorDomain = "libre_hardware_monitor";
export const libreHardwareMonitorDefaultName = "Libre Hardware Monitor";

export type TLibreHardwareMonitorRawData = TSimpleLocalRawData;
export interface ILibreHardwareMonitorSnapshot extends ISimpleLocalSnapshot {}
export interface ILibreHardwareMonitorConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantLibreHardwareMonitorConfig extends ILibreHardwareMonitorConfig {}

export const libreHardwareMonitorProfile: ISimpleLocalIntegrationProfile = {
  domain: libreHardwareMonitorDomain,
  displayName: "Libre Hardware Monitor",
  manufacturer: "Libre Hardware Monitor",
  model: "Libre Hardware Monitor local integration",
  defaultName: libreHardwareMonitorDefaultName,
  defaultPort: 8085,
  defaultHttpPath: '/data.json',
  defaultProtocol: 'http',
  status: "read-only-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "libre_hardware_monitor",
    "Libre Hardware Monitor",
    "Libre",
    "Hardware",
    "Monitor",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/libre_hardware_monitor",
    "upstreamDomain": "libre_hardware_monitor",
    "integrationType": "device",
    "iotClass": "local_polling",
    "qualityScale": "silver",
    "requirements": [
      "librehardwaremonitor-api==1.11.1",
    ],
    "codeowners": [
      "@Sab44",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/libre_hardware_monitor",
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": false,
    },
    "localApi": {
      "implemented": [
        "native Libre Hardware Monitor HTTP polling of /data.json on port 8085 with optional Basic authentication",
        "native parsing of Libre Hardware Monitor computer, hardware device, sensor value/min/max/unit, version, and deprecated-version data",
        "manual local setup for Libre Hardware Monitor endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Libre Hardware Monitor device snapshots and Home Assistant platform metadata",
      ],
      "explicitUnsupported": [
        "Libre Hardware Monitor writes or controls; the upstream API client exposes get_data only and Home Assistant creates sensor entities only",
        "claiming live Libre Hardware Monitor polling success without host/url, injected client, snapshotProvider, snapshot, or rawData",
        "Home Assistant entity registry migrations and repair flows",
      ],
    },
  },
};
