The Illusion of Vendor Metrics

The Anatomy of a 900x Bug
- Tuya devices do NOT push add_ele asynchronously in local mode. While they happily push real-time power (cur_power) on their own, the energy interval (add_ele) never arrived in the push stream.
- add_ele only appeared when I explicitly polled the device using status() or updatedps().
- When polled, the device returned a cached interval value (e.g., 100 Wh). It did not reset this value after the poll.
- Expected: Receive 100 Wh interval update every ~30 minutes = 0.2 kWh / hour
- Actual: Receive the same cached 100 Wh every 2 seconds = 180 kWh / hour
The Lesson: Math > Black Boxes
Time-Series Surgery in InfluxDB

Python
# What I thought would work
delete_api.delete(
start="2026-05-11T00:45:00Z",
stop="2026-05-12T14:34:00Z",
predicate='_measurement="smart_plug" AND _field="energy"',
bucket="iot"
)
The "Zero-Out and Offset" Strategy
Python
# Offset by 1 microsecond to avoid collisions
write_ts = curr_time.replace(microsecond=min(curr_time.microsecond + 1, 999999))
The Result
Device | Corrupted Total | Reconstructed Total |
|---|---|---|
| MCB AC & Water Heater | 300.5 kWh | 11.07 kWh |
| AC Plug Guest Room | 314.4 kWh | 9.71 kWh |
| Smart Plug Bedroom | 30.9 kWh | 0.53 kWh |