From 16cff39620c99e2f8fb6651e98ac805074bac875 Mon Sep 17 00:00:00 2001 From: Marcus Griep Date: Sat, 7 Mar 2026 21:07:35 -0700 Subject: [PATCH] feat: add WN38 Black Globe Thermometer sensor support Add bgt, wbgt, and bgtbatt sensor mappings with F-to-C conversions. --- aioecowitt/calc.py | 2 ++ aioecowitt/sensor.py | 9 ++++++ tests/const.py | 37 +++++++++++++++++++++++ tests/test_calc.py | 70 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 117 insertions(+), 1 deletion(-) diff --git a/aioecowitt/calc.py b/aioecowitt/calc.py index 3ddb4c2..cec5785 100644 --- a/aioecowitt/calc.py +++ b/aioecowitt/calc.py @@ -79,6 +79,8 @@ def weather_datapoints( # noqa: C901, PLR0912 ("tf_ch6", "tf_ch6c"), ("tf_ch7", "tf_ch7c"), ("tf_ch8", "tf_ch8c"), + ("bgt", "bgtc"), + ("wbgt", "wbgtc"), ): convert_fahrenheit_to_celsius(data, source, dst) diff --git a/aioecowitt/sensor.py b/aioecowitt/sensor.py index c31b203..c4463c2 100644 --- a/aioecowitt/sensor.py +++ b/aioecowitt/sensor.py @@ -190,6 +190,10 @@ class EcoWittMapping: "dewpoint7c": EcoWittMapping("Dewpoint 7", EcoWittSensorTypes.TEMPERATURE_C), "dewpoint8c": EcoWittMapping("Dewpoint 8", EcoWittSensorTypes.TEMPERATURE_C), "windchillc": EcoWittMapping("Windchill", EcoWittSensorTypes.TEMPERATURE_C), + "bgtc": EcoWittMapping("Black Globe Temperature", EcoWittSensorTypes.TEMPERATURE_C), + "wbgtc": EcoWittMapping( + "Wet Bulb Globe Temperature", EcoWittSensorTypes.TEMPERATURE_C + ), "tempf": EcoWittMapping("Outdoor Temperature", EcoWittSensorTypes.TEMPERATURE_F), "tempfeelsf": EcoWittMapping( "Feels like Temperature", @@ -215,6 +219,10 @@ class EcoWittMapping: "dewpoint7f": EcoWittMapping("Dewpoint 7", EcoWittSensorTypes.TEMPERATURE_F), "dewpoint8f": EcoWittMapping("Dewpoint 8", EcoWittSensorTypes.TEMPERATURE_F), "windchillf": EcoWittMapping("Windchill", EcoWittSensorTypes.TEMPERATURE_F), + "bgt": EcoWittMapping("Black Globe Temperature", EcoWittSensorTypes.TEMPERATURE_F), + "wbgt": EcoWittMapping( + "Wet Bulb Globe Temperature", EcoWittSensorTypes.TEMPERATURE_F + ), "solarradiation": EcoWittMapping( "Solar Radiation", EcoWittSensorTypes.WATT_METERS_SQUARED ), @@ -341,6 +349,7 @@ class EcoWittMapping: "wh80batt": EcoWittMapping("WH80 Battery", EcoWittSensorTypes.BATTERY_VOLTAGE), "wh85batt": EcoWittMapping("WH85 Battery", EcoWittSensorTypes.BATTERY_VOLTAGE), "wh90batt": EcoWittMapping("WH90 Battery", EcoWittSensorTypes.BATTERY_VOLTAGE), + "bgtbatt": EcoWittMapping("WN38 Battery", EcoWittSensorTypes.BATTERY_VOLTAGE), "soilbatt1": EcoWittMapping("Soil Battery 1", EcoWittSensorTypes.BATTERY_VOLTAGE), "soilbatt2": EcoWittMapping("Soil Battery 2", EcoWittSensorTypes.BATTERY_VOLTAGE), "soilbatt3": EcoWittMapping("Soil Battery 3", EcoWittSensorTypes.BATTERY_VOLTAGE), diff --git a/tests/const.py b/tests/const.py index 1c43aa6..49fc35e 100644 --- a/tests/const.py +++ b/tests/const.py @@ -62,6 +62,43 @@ "model": "GW2000A", } +GW1200B_WN38_DATA = { + "PASSKEY": "0123456789ABCDEF0123456789ABCDEF", + "stationtype": "GW1200B_V1.4.6", + "runtime": "25268", + "heap": "79076", + "dateutc": "2026-03-08 03:57:53", + "tempinf": "61.34", + "humidityin": "31", + "baromrelin": "29.926", + "baromabsin": "24.598", + "tempf": "45.86", + "humidity": "34", + "bgt": "43.16", + "wbgt": "37.94", + "winddir": "325", + "windspeedmph": "5.37", + "windgustmph": "7.38", + "maxdailygust": "16.78", + "solarradiation": "0.00", + "uv": "0", + "rainratein": "0.000", + "eventrainin": "0.000", + "hourlyrainin": "0.000", + "dailyrainin": "0.098", + "weeklyrainin": "0.244", + "monthlyrainin": "0.244", + "yearlyrainin": "0.248", + "totalrainin": "0.248", + "wh40batt": "1.4", + "wh57batt": "4", + "wh90batt": "2.90", + "bgtbatt": "1.54", + "freq": "915M", + "model": "GW1200B", + "interval": "60", +} + GW2000A_V3_DATA = { "PASSKEY": "345544D8EAF42E1B8824A86D8250D5A3", "stationtype": "GW2000A_V3.1.0", diff --git a/tests/test_calc.py b/tests/test_calc.py index 088f7fc..4086e5a 100644 --- a/tests/test_calc.py +++ b/tests/test_calc.py @@ -2,7 +2,7 @@ from aioecowitt import calc -from .const import EASYWEATHER_DATA, GW2000A_DATA +from .const import EASYWEATHER_DATA, GW1200B_WN38_DATA, GW2000A_DATA def test_gw2000a_v2() -> None: @@ -70,6 +70,74 @@ def test_gw2000a_v2() -> None: } +def test_gw1200b_wn38() -> None: + """Test GW1200B with WN38 Black Globe Thermometer sensors.""" + values = calc.weather_datapoints(GW1200B_WN38_DATA.copy()) + + assert values == { + "PASSKEY": "0123456789ABCDEF0123456789ABCDEF", + "baromabshpa": 832.9, + "baromabsin": 24.598, + "baromrelhpa": 1013.3, + "baromrelin": 29.926, + "bgt": 43.16, + "bgtbatt": 1.54, + "bgtc": 6.2, + "dailyrainin": 0.098, + "dailyrainmm": 2.5, + "dateutc": "2026-03-08 03:57:53", + "dewpointc": -7.2, + "dewpointf": 19.1, + "dewpointinc": -0.8, + "dewpointinf": 30.5, + "eventrainin": 0.0, + "eventrainmm": 0.0, + "freq": "915M", + "hourlyrainin": 0.0, + "hourlyrainmm": 0.0, + "humidity": 34, + "humidityin": 31, + "interval": "60", + "maxdailygust": 16.78, + "maxdailygustkmh": 27.0, + "model": "GW1200B", + "monthlyrainin": 0.244, + "monthlyrainmm": 6.2, + "rainratein": 0.0, + "rainratemm": 0.0, + "runtime": "25268", + "heap": "79076", + "solarradiation": 0.0, + "solarradiation_lux": 0.0, + "stationtype": "GW1200B_V1.4.6", + "tempc": 7.7, + "tempf": 45.86, + "tempfeelsc": 6.2, + "tempfeelsf": 43.1, + "tempinc": 16.3, + "tempinf": 61.34, + "totalrainin": 0.248, + "totalrainmm": 6.3, + "uv": 0, + "wbgt": 37.94, + "wbgtc": 3.3, + "weeklyrainin": 0.244, + "weeklyrainmm": 6.2, + "wh40batt": 1.4, + "wh57batt": 80, + "wh90batt": 2.9, + "windchillc": 6.2, + "windchillf": 43.1, + "winddir": 325, + "windgustkmh": 11.9, + "windgustmph": 7.38, + "windspeedkmh": 8.6, + "windspeedmph": 5.37, + "yearlyrainin": 0.248, + "yearlyrainmm": 6.3, + } + + def test_easyweather() -> None: """Test EasyWeather station.""" values = calc.weather_datapoints(EASYWEATHER_DATA.copy())