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

export const mqttRoomDomain = "mqtt_room";
export const mqttRoomDefaultName = "MQTT Room Presence";
export const mqttRoomLiveUnsupportedReason = "MQTT Room Presence live room updates require Home Assistant's mqtt.async_subscribe broker semantics for the state_topic/+ wildcard topic and QoS 1; the HA source documents no direct local HTTP/TCP/TLS/file protocol for room presence payloads.";

export type TMqttRoomRawData = TSimpleLocalRawData;
export interface IMqttRoomSnapshot extends ISimpleLocalSnapshot {}
export interface IMqttRoomConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantMqttRoomConfig extends IMqttRoomConfig {}

export const mqttRoomProfile: ISimpleLocalIntegrationProfile = {
  domain: mqttRoomDomain,
  displayName: "MQTT Room Presence",
  manufacturer: "MQTT Room Presence",
  model: "MQTT Room Presence local integration",
  defaultName: mqttRoomDefaultName,
  defaultProtocol: 'local',
  status: "read-only-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "mqtt_room",
    "MQTT Room Presence",
    "Mqtt Room",
    "MQTT",
    "Room",
    "Presence",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/mqtt_room",
    "upstreamDomain": "mqtt_room",
    "iotClass": "local_push",
    "qualityScale": "legacy",
    "requirements": [],
    "dependencies": [
      "mqtt",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/mqtt_room",
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": false,
      "blocker": mqttRoomLiveUnsupportedReason,
    },
    "localApi": {
      "status": "snapshot/injected-client only: Home Assistant mqtt_room subscribes to state_topic/+ through the HA MQTT integration and requires MQTT broker wildcard/QoS semantics; no direct local HTTP/TCP/TLS/file protocol is available in HA source.",
      "implemented": [
        "safe manual snapshots, rawData, snapshotProvider, and injected native-client snapshot behavior for MQTT Room Presence",
        "runtime mapping for MQTT Room Presence device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native MQTT Room Presence room update handling because Home Assistant delegates state_topic/+ reads to mqtt.async_subscribe broker wildcard semantics",
        "opening or emulating an MQTT broker/client session, topic subscription, QoS, retained-message, or wildcard behavior without adding an MQTT dependency",
        "claiming live MQTT Room Presence polling, pairing, subscription, or write success without an injected native client or snapshotProvider",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
