/** * Blitzortung.org MQTT client for real-time lightning detection * Community-operated global lightning detection network (free, no API key required) * * Data access via public MQTT broker maintained for homeassistant-blitzortung integration * @see https://github.com/mrk-its/homeassistant-blitzortung * @see https://www.blitzortung.org/ */ import { LightningStrike, LightningFeedFailure } from '../types/lightning.js'; /** A subscription not accessed for longer than this is unsubscribed by the prune. */ export declare const SUBSCRIPTION_IDLE_THRESHOLD_MS: number; /** How often the prune runs. */ export declare const SUBSCRIPTION_PRUNE_INTERVAL_MS: number; /** * How often saved locations are re-warmed. Each re-warm re-stamps a saved location's * geohashes, so their access stamp is never older than this interval and can never pass * the idle threshold. Derived, never a second literal; the half margin absorbs event-loop * delay. */ export declare const PREWARM_REFRESH_INTERVAL_MS: number; /** * What one pre-warm call did. An out-parameter, like `subscribeToLocation`'s `phase`: the * service is a singleton shared by overlapping callers, so a result field would be read by * the wrong one. `status` stays unset when the call failed. */ export interface PrewarmOutcome { status?: 'subscribed' | 'refreshed' | 'skipped-capacity' | 'skipped-reconnecting'; } export declare class BlitzortungService { private client; private readonly brokerUrl; private readonly topicPrefix; private readonly reconnectPeriod; private readonly connectTimeout; private strikeBuffer; private readonly bufferDuration; private readonly maxBufferSize; private subscribedGeohashes; private geohashFirstSubscribed; private readonly maxSubscriptions; private isConnecting; private isConnected; private readonly feedFailures; private connectionLossGeneration; constructor(); /** * Connect to MQTT broker if not already connected */ private ensureConnected; /** * Handle incoming MQTT message */ private handleMessage; /** * Subscribe to geohash topics for a location */ private subscribeToLocation; /** * Evict oldest subscriptions to make room for new ones (LRU eviction) */ private evictOldestSubscriptions; /** * Periodically prune stale subscriptions (not accessed in last hour) */ private startSubscriptionPruning; /** * Get recent lightning strikes from buffer */ getLightningStrikes(latitude: number, longitude: number, radiusKm?: number, timeWindowMinutes?: number): Promise; /** * Begin buffering strikes for a location without waiting for or returning results. * * Subscribes the area's geohashes so the rolling buffer starts filling immediately. * Intended for pre-warming known locations (saved locations, at startup and on every * refresh) so that later queries have real monitoring coverage instead of starting from * zero. Never evicts another subscription to make room. Best-effort: failures are * swallowed and must never block or crash startup. What the call did is written to * `outcome`; the return stays `Promise`. */ prewarmLocation(latitude: number, longitude: number, radiusKm?: number, outcome?: PrewarmOutcome): Promise; /** * The transport outcome of the query that produced `strikes`. * * Null when that query reached the broker, subscribed, and stayed connected for its whole * collection window; otherwise the moment and sanitized cause of the transport failure it * swallowed. Keyed on the returned array rather than held as a "last failure" field, so * overlapping queries cannot exchange outcomes and a pre-warm - which has no result array - * cannot set one at all. The returned object is never mutated after construction, so no * defensive copy is made. */ getFeedFailure(strikes: LightningStrike[]): LightningFeedFailure | null; /** * Get the moment from which the entire queried area has been continuously * monitored, or null if any part of it is not currently subscribed (or the * broker is disconnected). Callers use this to detect that a "0 strikes" * result covers less than the requested time window. */ getCoverageStart(latitude: number, longitude: number, radiusKm: number): Date | null; /** * Filter strikes from buffer based on location and time window */ private filterStrikes; /** * Clean up old strikes from buffer */ private cleanupBuffer; /** * Start periodic buffer cleanup */ private startCleanupInterval; /** * Disconnect from MQTT broker * This method is available for graceful shutdown scenarios */ disconnect(): Promise; } export declare const blitzortungService: BlitzortungService; //# sourceMappingURL=blitzortung.d.ts.map