From 06a8a7ff1ba7183f0f4ec3356ea0e8938ad00218 Mon Sep 17 00:00:00 2001 From: schizza Date: Sun, 26 Oct 2025 21:39:31 +0100 Subject: [PATCH] Adds WBGT temperature sensor via WSLink Adds the Wet Bulb Globe Temperature (WBGT) sensor to the integration, pulling data via the WSLink API. Corrects the state class for rain and wind direction. --- custom_components/sws12500/const.py | 3 +++ custom_components/sws12500/manifest.json | 2 +- custom_components/sws12500/sensors_wslink.py | 15 +++++++++++++-- custom_components/sws12500/translations/cs.json | 1 + custom_components/sws12500/translations/en.json | 1 + 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/custom_components/sws12500/const.py b/custom_components/sws12500/const.py index 125db17..8ff1897 100644 --- a/custom_components/sws12500/const.py +++ b/custom_components/sws12500/const.py @@ -91,6 +91,7 @@ CH4_HUMIDITY: Final = "ch4_humidity" CH4_CONNECTION: Final = "ch4_connection" HEAT_INDEX: Final = "heat_index" CHILL_INDEX: Final = "chill_index" +WBGT_TEMP: Final = "wbgt_temp" REMAP_ITEMS: dict[str, str] = { @@ -145,6 +146,7 @@ REMAP_WSLINK_ITEMS: dict[str, str] = { "t1bat": OUTSIDE_BATTERY, "inbat": INDOOR_BATTERY, "t234c1bat": CH2_BATTERY, + "t1wbgt": WBGT_TEMP, } # TODO: Add more sensors @@ -163,6 +165,7 @@ DISABLED_BY_DEFAULT: Final = [ CH4_TEMP, CH4_HUMIDITY, OUTSIDE_BATTERY, + WBGT_TEMP, ] BATTERY_LIST = [ diff --git a/custom_components/sws12500/manifest.json b/custom_components/sws12500/manifest.json index 0530d9b..c17b63e 100644 --- a/custom_components/sws12500/manifest.json +++ b/custom_components/sws12500/manifest.json @@ -10,6 +10,6 @@ "issue_tracker": "https://github.com/schizza/SWS-12500-custom-component/issues", "requirements": [], "ssdp": [], - "version": "1.6.7", + "version": "1.6.8", "zeroconf": [] } diff --git a/custom_components/sws12500/sensors_wslink.py b/custom_components/sws12500/sensors_wslink.py index d46bd4a..43ff151 100644 --- a/custom_components/sws12500/sensors_wslink.py +++ b/custom_components/sws12500/sensors_wslink.py @@ -48,6 +48,7 @@ from .const import ( WIND_SPEED, YEARLY_RAIN, UnitOfDir, + WBGT_TEMP, ) from .sensors_common import WeatherSensorEntityDescription from .utils import battery_level_to_icon, battery_level_to_text, wind_dir_to_text @@ -131,7 +132,7 @@ SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = ( WeatherSensorEntityDescription( key=WIND_DIR, native_unit_of_measurement=DEGREE, - state_class=SensorStateClass.MEASUREMENT, + state_class=None, device_class=SensorDeviceClass.WIND_DIRECTION, suggested_display_precision=None, icon="mdi:sign-direction", @@ -150,7 +151,7 @@ SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = ( key=RAIN, native_unit_of_measurement=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR, device_class=SensorDeviceClass.PRECIPITATION_INTENSITY, - state_class=SensorStateClass.TOTAL, + state_class=SensorStateClass.MEASUREMENT, suggested_unit_of_measurement=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR, suggested_display_precision=2, icon="mdi:weather-pouring", @@ -330,4 +331,14 @@ SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = ( device_class=SensorDeviceClass.ENUM, value_fn=lambda data: battery_level_to_text(data), ), + WeatherSensorEntityDescription( + key=WBGT_TEMP, + translation_key=WBGT_TEMP, + icon="mdi:thermometer", + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + suggested_display_precision=2, + value_fn=lambda data: cast("int", data), + ), ) diff --git a/custom_components/sws12500/translations/cs.json b/custom_components/sws12500/translations/cs.json index 7208bf8..50948ef 100644 --- a/custom_components/sws12500/translations/cs.json +++ b/custom_components/sws12500/translations/cs.json @@ -116,6 +116,7 @@ "weekly_rain": { "name": "Týdenní úhrn srážek" }, "monthly_rain": { "name": "Měsíční úhrn srážek" }, "yearly_rain": { "name": "Roční úhrn srážek" }, + "wbgt_temp": { "name": "WBGT index" }, "wind_azimut": { "name": "Azimut", "state": { diff --git a/custom_components/sws12500/translations/en.json b/custom_components/sws12500/translations/en.json index 581bfde..69317e2 100644 --- a/custom_components/sws12500/translations/en.json +++ b/custom_components/sws12500/translations/en.json @@ -116,6 +116,7 @@ "weekly_rain": { "name": "Weekly precipitation" }, "monthly_rain": { "name": "Monthly precipitation" }, "yearly_rain": { "name": "Yearly precipitation" }, + "wbgt_index": { "name": "WBGT index" }, "wind_azimut": { "name": "Bearing", "state": {