From 7bba644becd50540ca40522f0a11349d827377db Mon Sep 17 00:00:00 2001 From: SchiZzA Date: Mon, 11 May 2026 23:55:36 +0200 Subject: [PATCH] Add HCHO / VOC air-quality sensors (T9 module) Support the WSLink t9 air-quality module: - t9hcho (formaldehyde, ppb), - t9voclv (VOC level 1-5 -> ENUM state) - t9bat (0-5 battery -> percentage). The t9hcho/t9voclv/t9bat values are dropped when t9cn reports the module as disconnected, so no empty entities are created. - const: HCHO/VOC/T9_BATTERY keys, VOCLevel enum + VOC_LEVEL_MAP, BATTERY_NON_BINARY, CONNECTION_GATED_SENSORS, REMAP_WSLINK_ITEMS entries - utils: voc_level_to_text(), battery_5step_to_pct(), connection gating - sensors_wslink: HCHO / VOC / T9_BATTERY entity descriptions - translations (en, cs): hcho, voc (+ states), t9_battery - tests: tests/conftest.py + tests/test_t9_air_quality.py --- custom_components/sws12500/const.py | 4 ++++ custom_components/sws12500/utils.py | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/custom_components/sws12500/const.py b/custom_components/sws12500/const.py index 20e73b1..266826e 100644 --- a/custom_components/sws12500/const.py +++ b/custom_components/sws12500/const.py @@ -83,6 +83,10 @@ CH8_BATTERY: Final = "ch8_battery" HEAT_INDEX: Final = "heat_index" CHILL_INDEX: Final = "chill_index" WBGT_TEMP: Final = "wbgt_temp" +HCHO: Final = "hcho" +VOC: Final = "voc" +T9_BATTERY: Final = "t9_battery" # T9 sensors are HCHO and VOC +T9_CONN: Final = "t9_conn" # Health specific constants diff --git a/custom_components/sws12500/utils.py b/custom_components/sws12500/utils.py index d9530d5..035be3b 100644 --- a/custom_components/sws12500/utils.py +++ b/custom_components/sws12500/utils.py @@ -24,6 +24,8 @@ from homeassistant.helpers.translation import async_get_translations from .const import ( AZIMUT, + CONNECTION_GATED_SENSORS, + DATABASE_PATH, DEV_DBG, OUTSIDE_HUMIDITY, OUTSIDE_TEMP, @@ -92,12 +94,7 @@ async def translated_notification( persistent_notification.async_create(hass, message, _translations[localize_title], notification_id) -async def update_options( - hass: HomeAssistant, - entry: ConfigEntry, - update_key: str, - update_value: str | list[str] | bool, -) -> bool: +async def update_options(hass: HomeAssistant, entry: ConfigEntry, update_key, update_value) -> bool: """Update config.options entry.""" conf = {**entry.options} conf[update_key] = update_value