From 1b7da6566c15cc31507694b38b8658714eb10e37 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Sat, 12 Mar 2022 13:54:40 +0000 Subject: [PATCH] parse: fix weather h00 = 100% humidity fix #70 --- aprslib/parsing/weather.py | 2 +- tests/test_parse_weather_data.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/aprslib/parsing/weather.py b/aprslib/parsing/weather.py index 6754f1d..1ed140f 100644 --- a/aprslib/parsing/weather.py +++ b/aprslib/parsing/weather.py @@ -33,7 +33,7 @@ val_map = { 'r': lambda x: int(x) * rain_multiplier, 'p': lambda x: int(x) * rain_multiplier, 'P': lambda x: int(x) * rain_multiplier, - 'h': lambda x: int(x), + 'h': lambda x: 100 if int(x) == 0 else int(x), 'b': lambda x: float(x) / 10, 'l': lambda x: int(x) + 1000, 'L': lambda x: int(x), diff --git a/tests/test_parse_weather_data.py b/tests/test_parse_weather_data.py index 634ed5f..53c8251 100644 --- a/tests/test_parse_weather_data.py +++ b/tests/test_parse_weather_data.py @@ -113,11 +113,17 @@ class ParseCommentWeather(unittest.TestCase): def test_humidity(self): expected = "", { - "humidity": 0.0 + "humidity": 100 } result = parse_weather_data("h00") self.assertEqual(expected, result) + expected = "", { + "humidity": 1 + } + result = parse_weather_data("h01") + self.assertEqual(expected, result) + expected = "", { "humidity": 99 }