UNPKG

homebridge-weather-noaa

Version:

Homebridge plugin providing temperature and humidity sensors using the NOAA / NWS API.

44 lines (43 loc) 1.68 kB
import { API, Characteristic, DynamicPlatformPlugin, Logging, PlatformAccessory, PlatformConfig, Service } from 'homebridge'; export declare class NOAAWeatherPlatform implements DynamicPlatformPlugin { readonly log: Logging; readonly config: PlatformConfig; readonly api: API; readonly Service: typeof Service; readonly Characteristic: typeof Characteristic; readonly accessories: Map<string, PlatformAccessory>; private readonly userAgent; private readonly timers; private readonly metrics; constructor(log: Logging, config: PlatformConfig, api: API); configureAccessory(accessory: PlatformAccessory): void; private shutdown; /** * NWS-recommended User-Agent format: "(myapp.com, contact)". * https://www.weather.gov/documentation/services-web-api * * The optional contact field is sanitized to strip CR/LF, preventing * HTTP header injection from a misconfigured config.json value. */ private buildUserAgent; private getNumberConfig; private getBoolConfig; private getStationIdConfig; /** * Fetch JSON from the NWS API with bounded retries and rate-limit handling. * Native fetch + AbortController; no third-party HTTP client required. */ private fetchJson; private parseRetryAfter; private sleep; private writeCacheAtomic; private readStationCache; private discoverDevices; private discoverStation; private startPolling; private fetchAndPushObservation; /** Convert NWS QuantitativeValue to °C, honoring unitCode and QC flag. */ private extractTemperatureC; private extractHumidity; private logMetrics; }