🐛 fix: normalize time-series numeric samples to float #56
Loading…
Reference in a new issue
No description provided.
Delete branch "fix-string-series-values"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes the root cause of MateoGreil/homeassistant-comwatt#56 (v0.8.x fails to set up with
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. The first numeric consumer downstream is the HA integration's site-energy folding (value < 0), which crashes the whole setup on those accounts.What
normalize_time_series()(new_series.py) coerces every top-level list excepttimestampsto uniformfloat | Nonesamples:float"12.34") →floatNonestaysNoneNone(usable as a number gap)Applied on
site-time-series,time-seriesand the deprecatedsite-networks-ts-time-agoendpoints. Non-list fields and unknown structures are returned unchanged, so extra API metadata is never altered.Tests
4 new tests in
test_aggregations.py: string-sample coercion per endpoint, and non-series fields left untouched.Release plan
Bump
__version__to 0.4.2 → tag → PyPI, then the integration bumps itsmanifest.jsonrequirement tocomwatt-client==0.4.2for v0.8.2 (companion PR: mat/homeassistant-comwatt#113 hardens the persisted-state loader against the follow-up crash reported in the same issue).Some accounts get their time-series samples serialized as JSON strings ("12.34") instead of numbers, which crashes numeric consumers with TypeError: '<' not supported between instances of 'str' and 'int'. normalize_time_series() coerces every list except timestamps to float/None samples on site-time-series, time-series and the deprecated site-networks-ts-time-ago endpoints.1a3bb168c28b96072db5