from __future__ import annotations

from enum import Enum
from typing import Any

from pydantic import BaseModel


class Severity(str, Enum):
    info = "info"
    warning = "warning"
    error = "error"


class HAEventType(str, Enum):
    ha_integration_failed = "ha_integration_failed"
    ha_entity_unavailable_long = "ha_entity_unavailable_long"
    ha_websocket_dead = "ha_websocket_dead"
    ha_websocket_recovered = "ha_websocket_recovered"
    ha_automation_failing = "ha_automation_failing"
    ha_update_available = "ha_update_available"
    ha_recorder_lag = "ha_recorder_lag"
    ha_system_health_degraded = "ha_system_health_degraded"


class EventRecord(BaseModel):
    id: str
    timestamp: int
    date: str
    type: str
    severity: str
    node: str
    service: str
    message: str
    payload: dict[str, Any] = {}


class CheckResult(BaseModel):
    healthy: bool
    event_type: str | None = None  # None means no event to emit
    severity: Severity = Severity.info
    message: str = ""
    payload: dict[str, Any] = {}
