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

export const oemDomain = "oem";
export const oemDefaultName = "OpenEnergyMonitor WiFi Thermostat";

export type TOemRawData = TSimpleLocalRawData;
export interface IOemSnapshot extends ISimpleLocalSnapshot {}
export interface IOemConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantOemConfig extends IOemConfig {}

export const oemProfile: ISimpleLocalIntegrationProfile = {
  domain: oemDomain,
  displayName: "OpenEnergyMonitor WiFi Thermostat",
  manufacturer: "OpenEnergyMonitor WiFi Thermostat",
  model: "OpenEnergyMonitor WiFi Thermostat local integration",
  defaultName: oemDefaultName,
  defaultPort: 80,
  defaultProtocol: 'http',
  status: "control-runtime",
  platforms: [
    "climate",
  ],
  serviceDomains: [
    "climate",
  ],
  controlServices: [
    "set_hvac_mode",
    "set_temperature",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "oem",
    "OpenEnergyMonitor WiFi Thermostat",
    "Oem",
    "OpenEnergyMonitor",
    "WiFi",
    "Thermostat",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/oem",
    "upstreamDomain": "oem",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [
      "oemthermostat==1.1.1",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/oem",
    "loggers": [
      "oemthermostat",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "set_hvac_mode",
        "set_temperature",
      ],
      "platforms": [
        "climate",
      ],
      "controls": "native HTTP set_hvac_mode/set_temperature with injected executor override",
    },
    "localApi": {
      "implemented": [
        "native HTTP polling for OpenEnergyMonitor WiFi Thermostat /control/thermostat.cgi state",
        "native HTTP control for thermostat_manualsetpoint and thermostat_state writes",
        "manual local setup for OpenEnergyMonitor WiFi Thermostat endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for OpenEnergyMonitor WiFi Thermostat device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor when provided",
      ],
      "explicitUnsupported": [
        "pairing, subscription, MQTT forwarding, or non-HTTP thermostat configuration pages",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without a real native HTTP response, injected client.execute, or commandExecutor",
      ],
    },
  },
};
