import { PlatformAccessory } from 'homebridge'; import type { AmbientWeatherSensorsPlatform } from './platform.js'; /** * Attach a `Battery` sub-service to an existing sensor accessory and * return a callback that updates the low/normal state on each * subsequent reading. Returns undefined when this sensor's probe * doesn't report a battery (i.e. `accessory.context.device.batteryLow` * is undefined) — caller should skip the Battery sub-service in * that case. * * Apple Home's automation framework triggers low-battery push * notifications off the `StatusLowBattery` characteristic * specifically, so that's the one users care about. The other two * characteristics HAP requires on a Battery service are filled in * to keep the tile sensible: * * - ChargingState → NOT_CHARGEABLE (AWN sensors are battery-only) * - BatteryLevel → 5% when low, 100% when normal. AWN doesn't * report an actual percentage — these are * display-only sentinels chosen so the * Home.app tile shows an alarming bar when * the battery is low. * * Adding the Battery service to an existing sensor accessory makes * it a sub-service rather than its own tile, matching HomeKit's * convention for battery-powered devices (the same way an Eve * Motion sensor exposes its own battery). */ /** * Row-driven attach contract (finding-#4 Stage 2). Under the row model * the HAP graph is a property of the effective map, NOT of transient * telemetry — a row whose signature says `battery:1` must get a Battery * sub-service even if AWN happened to omit the field on the discovery * tick. Callers that have a resolved row pass this shape: * * - `attach`: `row.hasBatterySubService` — attach unconditionally * when true; remove any existing sub-service when false. * - `initialLow`: the seed value. `'unknown'` (no usable reading) * seeds HAP's NORMAL placeholder ONLY on a FRESH service; on a * RESTORED service it PRESERVES the retained characteristics, so * an unknown reading never invents a healthy state (PR #67 review * R2-F3). A real boolean reading (and the first real * `setBatteryLow`) seed/override it either way. */ export interface BatteryServiceOptions { attach: boolean; initialLow: boolean | 'unknown'; } export declare function setupBatteryService(platform: AmbientWeatherSensorsPlatform, accessory: PlatformAccessory, options?: BatteryServiceOptions): ((low: boolean) => void) | undefined; //# sourceMappingURL=batteryService.d.ts.map