Back to Feed
article 3m read

A hub that called a day-old bedroom temperature live

A bridge replayed an old sensor reading with a new seen-at time, and my hub, which stamped messages with their arrival time anyway, treated it as current. Now the hub keeps the device's own report time, one rule decides live, stale or unknown, and the history stops inventing flat lines.

Article DepthPractice

Flow

From a resent value to an honest screen

  1. 1Two clocks

    The bridge resends old values with a new time, and the hub used the time each message arrived.

  2. 2Spot the resends

    Real radio messages carry a signal-strength number. Resends don't, so they keep the last real time.

  3. 3One rule

    Live, stale or unknown by report time and device type, with one missed report forgiven.

  4. 4History

    Write a point only when a real report arrives.

  5. 5Power totals

    Save nothing unless a plug is reporting, instead of saving an empty zero.

  6. 6Screens

    Check the server on a timer, since a quiet sensor sends nothing.

The bedroom temperature showed as current on my hub. It was a day old.

Two clocks, both wrong

The sensor talks by radio to a bridge, and the bridge passes its messages on to my hub. The bridge remembers each device's last state. When it restarts, or a device rejoins, it sends that state again with a new seen-at time. So an old value shows up looking new.

My hub didn't even use that time. It used the time each message arrived. So any resend made an old value look fresh. A device's time should only move when the device sends a new reading.

Everyone had their own idea of live

The device list, the charts, the narrator, the planner and the assistant each judged "live" on their own. Most of them just checked if the device was online, or if a value was in the cache. A day-old reading passed every check.

Real reports versus resends

The agent wrote the change. A message that really came over the radio has a signal-strength number. A resend from the bridge's memory doesn't. So the hub now keeps the device's own report time. A message without that number keeps the last real time, or gets none.

That's how the bridge acts today. It isn't a promise. If it changes, things either all go stale or the bug comes back. Copies the broker kept around only count if they're newer than what the hub has.

One rule for everyone

One shared rule now says live, stale or unknown:

  • Live means the report is within the device's normal gap, with one miss forgiven.
  • Plugs and lights report every few minutes. Battery sensors report about hourly.
  • No time, or a time far in the future, means unknown.

Every screen and helper asks that rule. A stale device shows when it was last heard from, not the old number. The planner admits it has nothing recent instead of guessing.

The flat line nobody measured

The history writer copied cached values on a timer. A dead sensor drew a flat line of fake readings. Now it writes only when a real report arrives. A one-off cleanup script can remove the fake rows, with a dry run and a backup first.

What broke next

Sensors in the device list showed no reading at all. Now they show the reading and when it was taken. And once power totals only counted fresh plugs, an empty set added up to zero, which would have been saved as real. Now nothing is saved unless a plug is reporting.

A quiet sensor also sends no message, so screens never redrew. Now they check the server on a timer.

The bridge could change its mind

A test replays the bedroom case and checks the time didn't move. It can't prove the bridge will keep acting the same way.

Where it can still fool me

Some quiet, healthy sensors will show stale. I'd rather that than a fake live reading. The bridge habit under the whole thing is still the weak spot.

Keep reading

Pick up a connected idea or branch into a nearby one.

5 paths forward