Skip to content

v0.4.2

Choose a tag to compare

@MateoGreil MateoGreil released this 04 Sep 21:19
· 93 commits to main since this release

🐛 Normalize time-series numeric samples to float

Fixes the root cause of MateoGreil/homeassistant-comwatt#56 (TypeError: '<' not supported between instances of 'str' and 'int').

Why

Some Comwatt accounts get their time-series samples serialized as JSON strings ("12.34") instead of JSON numbers, which crashes numeric consumers — most visibly the Home Assistant integration's site-energy folding (value < 0 on a string).

What

New normalize_time_series() coerces every top-level list except timestamps to uniform float | None samples:

  • JSON numbers → float
  • numeric strings ("12.34") → float
  • None stays None
  • booleans, empty or unparseable strings → None (a usable number gap)

Applied on site-time-series, time-series and the deprecated site-networks-ts-time-ago endpoints. Non-list fields and unknown structures pass through unchanged, so extra API metadata is never altered.

Compatibility

No API changes — response shapes are unchanged apart from sample types. Consumers that previously worked received JSON numbers and still receive float; consumers on string-serialized accounts stop crashing.