mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-11-04 20:32:24 +01:00
`_get_companion_stats` hardcoded `battery_mv: 0`, so every MeshCore companion client connected to a Python repeater showed no battery, even when a sensor plug-in was reporting one. The protocol side is already complete: the frame server packs `battery_mv` into the STATS_TYPE_CORE frame and clients request it via CMD_GET_BATT_AND_STORAGE. Surface the first sensor reading that publishes a usable battery voltage, accepting either `battery_voltage_mv` or `battery_voltage_v`. This covers an attached UPS HAT as well as the battery of an openHop modem the repeater is driving, which is the case that prompted this: a solar-powered modem whose battery was invisible to the companion app right up until it went flat. Returns 0 when no sensor reports a battery, which is what clients already expect from a mains-powered node, and the lookup never raises — stats must not be able to take down the companion connection.