Repository navigation
v0.4.2
🐛 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 NonestaysNone- 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.