/** Odpověď GET /api/v1/sites/{id}/configuration */

export type SiteConfigurationSite = {
  id: number
  code: string
  name: string
  timezone: string
  latitude: number | null
  longitude: number | null
  active: boolean
  notes: string | null
  created_at: string
}

export type SiteConfigurationEndpoint = {
  id: number
  site_id: number
  endpoint_type: string
  host: string
  port: number | null
  protocol: string | null
  unit_id: number | null
  auth_reference: string | null
  enabled: boolean
  notes: string | null
}

export type SiteConfigurationOperational = {
  heartbeat_last_seen: string | null
  heartbeat_status: string | null
  has_active_plan: boolean
  active_plan_created_at: string | null
}

/** Řádek `ems.site_pv_forecast_calibration` (GET /configuration → `pv_forecast_calibration`). */
export type SitePvForecastCalibrationRow = {
  site_id: number
  delta_learn_min_ts: string
  pv_curtailment_policy_effective_from?: string | null
  top_n_days?: number | null
  non_top_day_factor?: number | string | null
  day_weight_gamma?: number | string | null
  half_life_days?: number | string | null
  threshold_w?: number | null
  updated_at?: string
}

export type SiteConfigurationResponse = {
  site: SiteConfigurationSite
  grid_connection: Record<string, unknown> | null
  market_config: Record<string, unknown> | null
  market_config_note: string
  endpoints: SiteConfigurationEndpoint[]
  inverters: Record<string, unknown>[]
  batteries: Record<string, unknown>[]
  pv_arrays: Record<string, unknown>[]
  ev_chargers: Record<string, unknown>[]
  vehicles: Record<string, unknown>[]
  heat_pumps: Record<string, unknown>[]
  operating_mode: Record<string, unknown> | null
  active_overrides: Record<string, unknown>[]
  /** Kalibrace PV delty; null pokud v DB chybí řádek (měl by existovat po V057). */
  pv_forecast_calibration?: SitePvForecastCalibrationRow | null
  operational: SiteConfigurationOperational
}
