From 5411f3cea145b9ab503a204a5c508032d7d13548 Mon Sep 17 00:00:00 2001 From: Andy Dodd Date: Thu, 18 Jun 2020 15:21:40 -0400 Subject: [PATCH] Add calculated dewpoint for indoor and all 8 TH channels, refactor to loop through all sensors for which we can expect temp and humidity to both be available --- pyecowitt/ecowitt.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyecowitt/ecowitt.py b/pyecowitt/ecowitt.py index cf6e51a..5465355 100644 --- a/pyecowitt/ecowitt.py +++ b/pyecowitt/ecowitt.py @@ -184,10 +184,11 @@ def convert_units(self, data): data["windchillf"] = self._wind_chill(data["tempf"], data["windspeedmph"]) data["windchillc"] = self._ftoc(data["windchillf"]) - if "tempc" in data and "humidity" in data: - data["dewpointc"] = self.get_dew_point_c(data["tempc"], - data["humidity"]) - data["dewpointf"] = round((data["dewpointc"] * 9.0 / 5.0) + 32.0, 2) + for j in ['', 'in', '1', '2', '3', '4', '5', '6', '7', '8']: + if "temp" + j + "c" in data and "humidity" + j in data: + data["dewpoint" + j + "c"] = self.get_dew_point_c(data["temp" + j + "c"], + data["humidity" + j]) + data["dewpoint" + j + "f"] = round((data["dewpoint" + j + "c"] * 9.0 / 5.0) + 32.0, 2) # Soil moisture (WH51) for j in range(1, 9):