Reverse-Engineering a Water Meter From Its Own Home Assistant Entities
A device with no saved source config was still reporting real sensor data - so a working YAML got rebuilt entirely backwards from the entity names it left behind, then flashed anyway.
Table of contents
A device was still reporting real sensor data into Home Assistant - five live entities, updating normally - with no source configuration anywhere. No YAML on disk, no entry in the dashboard, nothing in version control. Whatever firmware was actually running on it had been flashed at some point in the past and then never saved anywhere again. The question wasn't how to fix it. It was whether a config could be reconstructed for a device with no source at all, working backwards from nothing but the entities it happened to still be reporting.
Starting from symptoms, not source
The only ground truth available was what Home Assistant already knew: a handful of binary sensors and a numeric sensor, their names, and their units. That's thin, but it's not nothing - entity names and units carry real implications about the firmware that produced them. A sensor reporting in gallons with a steadily increasing value looks like a water meter counting pulses. Multiple binary sensors with overlapping, slightly different names looks like someone was debugging a flaky signal by watching it three different ways at once.
Working from that, a plausible YAML config came together: a pulse_meter platform assuming one pulse equals one gallon, a single GPIO pin reused across all three binary sensor definitions via ESPHome's mechanism for sharing one pin across multiple consumers, and a debounce filter on the "real" reading to distinguish it from the two raw/duplicate reads sitting alongside it. Every one of those choices was a guess, not a fact - the actual GPIO pin, the real pulse-to-gallon ratio, and the exact reason three near-identical sensors existed were all inferred from naming conventions and plausibility, not confirmed against the physical device.
"Validates clean" is not the same claim as "is correct"
The config passed esphome config's validation - "Configuration is valid!" - and that's a real, useful check. It catches YAML syntax errors, bad references, and nonsensical platform options. It does not and cannot catch "this is wired to the wrong GPIO" or "this pulse count doesn't actually mean one gallon." A syntax checker has no way to know what's physically true about a device it's never seen. The config was committed with an explicit header comment making that gap plain: don't flash this without reviewing the guesses first.
It got flashed anyway, the same day
The warning didn't survive contact with curiosity for very long. The device was flashed same-day, and the dashboard reported it healthy afterward - online, with the deployed firmware's configuration hash matching what was expected. That's a real, meaningful confirmation: the guessed config didn't just validate syntactically, it compiled into firmware that actually ran on the real hardware without crashing or dropping off the network. It is still not proof that the pulse-to-gallon calibration is correct - only that the firmware didn't fail in a way that would announce a wrong guess on its own.
The side effects nobody planned for
Reflashing a device that already had an operating history in Home Assistant doesn't happen in a vacuum, and two real effects showed up afterward, neither one actually broken:
- The original binary sensor entities went permanently unavailable. The new firmware registered fresh ones under different internal IDs, so the old three became orphaned clutter - safe to delete, but not something that cleans itself up automatically.
- The water-consumption total sensor dropped noticeably across the reflash, because the pulse count that fed it didn't carry over through the OTA update. That sensor feeds Home Assistant's energy tracking, which treats a sudden drop in a steadily-increasing counter as a meter reset rather than negative usage - so the dip corrects itself over time in the graph rather than needing a manual fix.
Neither side effect was a failure. Both were simply the predictable consequence of swapping firmware under a system that had been quietly building assumptions about continuity.
What "it works" actually proved here
A config built entirely from inference, validated only by a syntax checker, and flashed onto a live device anyway is a calculated bet, not a neutral, zero-risk action - even when it lands fine. "Compiles clean" and "the dashboard says healthy" are both real signals, and both stop well short of "the numbers this device reports are correct." That last gap - whether one pulse really does mean one gallon - is still just an assumption sitting quietly inside a sensor nobody's indoors meter can currently contradict.