Skip to content

fix: handle string, uint, and uint64 types in toFloat64#352

Merged
KpaBap merged 1 commit intomasterfrom
fix/toFloat64-string-uint-support
Apr 1, 2026
Merged

fix: handle string, uint, and uint64 types in toFloat64#352
KpaBap merged 1 commit intomasterfrom
fix/toFloat64-string-uint-support

Conversation

@Kpa-clawbot
Copy link
Copy Markdown
Owner

Summary

Fixes #350toFloat64() silently drops SNR/RSSI values when bridges send strings instead of numbers.

Problem

Some MQTT bridges serialize numeric fields (SNR, RSSI, battery_mv, etc.) as JSON strings like "-7.5" instead of numbers. The existing toFloat64() switch only handled float64, float32, int, int64, and json.Number, so string values fell through to the default case returning (0, false) — silently dropping the data.

Changes

  • cmd/ingestor/main.go: Added string, uint, and uint64 cases to toFloat64()

    • string: uses strconv.ParseFloat(strings.TrimSpace(n), 64) to handle whitespace-padded numeric strings
    • uint / uint64: straightforward numeric conversion
    • Added strconv import
  • cmd/ingestor/main_test.go: Updated TestToFloat64 with new cases:

    • Valid string ("3.14"), string with spaces (" -7.5 "), string integer ("42")
    • Invalid string ("hello"), empty string
    • uint(10), uint64(999)

Testing

All ingestor tests pass (go test ./...).

Bridges may send SNR/RSSI values as strings instead of numbers,
causing toFloat64 to silently return (0, false) and drop the data.

Add string case using strconv.ParseFloat with TrimSpace, plus uint
and uint64 cases for completeness. Update tests accordingly.

Fixes #350
@Kpa-clawbot Kpa-clawbot force-pushed the fix/toFloat64-string-uint-support branch from a30a890 to 8d52b39 Compare April 1, 2026 13:56
@KpaBap KpaBap merged commit b2279b2 into master Apr 1, 2026
3 checks passed
@KpaBap KpaBap deleted the fix/toFloat64-string-uint-support branch April 1, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: toFloat64 silently drops SNR/RSSI when bridge sends strings instead of numbers

2 participants