From 3184d3b168dcf2206a6f8e3c0439cfd2f08c680e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 19 Jan 2024 17:56:35 -1000 Subject: [PATCH] Bump thermopro-ble to 0.8.0 (#108319) --- .../components/thermopro/manifest.json | 6 +++++- homeassistant/components/thermopro/sensor.py | 11 +++++++++++ homeassistant/generated/bluetooth.py | 5 +++++ requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/thermopro/test_sensor.py | 17 ++++++++++++----- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/thermopro/manifest.json b/homeassistant/components/thermopro/manifest.json index a0a07d3cb00..237cd39fb66 100644 --- a/homeassistant/components/thermopro/manifest.json +++ b/homeassistant/components/thermopro/manifest.json @@ -9,6 +9,10 @@ { "local_name": "TP39*", "connectable": false + }, + { + "local_name": "TP96*", + "connectable": false } ], "codeowners": ["@bdraco"], @@ -16,5 +20,5 @@ "dependencies": ["bluetooth_adapters"], "documentation": "https://www.home-assistant.io/integrations/thermopro", "iot_class": "local_push", - "requirements": ["thermopro-ble==0.5.0"] + "requirements": ["thermopro-ble==0.8.0"] } diff --git a/homeassistant/components/thermopro/sensor.py b/homeassistant/components/thermopro/sensor.py index 107385615f8..37cbf10323f 100644 --- a/homeassistant/components/thermopro/sensor.py +++ b/homeassistant/components/thermopro/sensor.py @@ -25,6 +25,7 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, + EntityCategory, UnitOfTemperature, ) from homeassistant.core import HomeAssistant @@ -59,6 +60,16 @@ SENSOR_DESCRIPTIONS = { state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, ), + ( + ThermoProSensorDeviceClass.BATTERY, + Units.PERCENTAGE, + ): SensorEntityDescription( + key=f"{ThermoProSensorDeviceClass.BATTERY}_{Units.PERCENTAGE}", + device_class=SensorDeviceClass.BATTERY, + native_unit_of_measurement=PERCENTAGE, + state_class=SensorStateClass.MEASUREMENT, + entity_category=EntityCategory.DIAGNOSTIC, + ), } diff --git a/homeassistant/generated/bluetooth.py b/homeassistant/generated/bluetooth.py index cda39d8494f..9e3504efca0 100644 --- a/homeassistant/generated/bluetooth.py +++ b/homeassistant/generated/bluetooth.py @@ -534,6 +534,11 @@ BLUETOOTH: list[dict[str, bool | str | int | list[int]]] = [ "domain": "thermopro", "local_name": "TP39*", }, + { + "connectable": False, + "domain": "thermopro", + "local_name": "TP96*", + }, { "domain": "tilt_ble", "manufacturer_data_start": [ diff --git a/requirements_all.txt b/requirements_all.txt index e8eb10d2306..c3c07cabae8 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2662,7 +2662,7 @@ tessie-api==0.0.9 thermobeacon-ble==0.6.2 # homeassistant.components.thermopro -thermopro-ble==0.5.0 +thermopro-ble==0.8.0 # homeassistant.components.thermoworks_smoke thermoworks-smoke==0.1.8 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 86a00bc7e73..35cf67e74a1 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2018,7 +2018,7 @@ tessie-api==0.0.9 thermobeacon-ble==0.6.2 # homeassistant.components.thermopro -thermopro-ble==0.5.0 +thermopro-ble==0.8.0 # homeassistant.components.tilt_ble tilt-ble==0.2.3 diff --git a/tests/components/thermopro/test_sensor.py b/tests/components/thermopro/test_sensor.py index 236a9d27df6..bead3a53dea 100644 --- a/tests/components/thermopro/test_sensor.py +++ b/tests/components/thermopro/test_sensor.py @@ -24,14 +24,21 @@ async def test_sensors(hass: HomeAssistant) -> None: assert len(hass.states.async_all()) == 0 inject_bluetooth_service_info(hass, TP357_SERVICE_INFO) await hass.async_block_till_done() - assert len(hass.states.async_all()) == 2 + assert len(hass.states.async_all()) == 3 temp_sensor = hass.states.get("sensor.tp357_2142_temperature") - temp_sensor_attribtes = temp_sensor.attributes + temp_sensor_attributes = temp_sensor.attributes assert temp_sensor.state == "24.1" - assert temp_sensor_attribtes[ATTR_FRIENDLY_NAME] == "TP357 (2142) Temperature" - assert temp_sensor_attribtes[ATTR_UNIT_OF_MEASUREMENT] == "°C" - assert temp_sensor_attribtes[ATTR_STATE_CLASS] == "measurement" + assert temp_sensor_attributes[ATTR_FRIENDLY_NAME] == "TP357 (2142) Temperature" + assert temp_sensor_attributes[ATTR_UNIT_OF_MEASUREMENT] == "°C" + assert temp_sensor_attributes[ATTR_STATE_CLASS] == "measurement" + + battery_sensor = hass.states.get("sensor.tp357_2142_battery") + battery_sensor_attributes = battery_sensor.attributes + assert battery_sensor.state == "100" + assert battery_sensor_attributes[ATTR_FRIENDLY_NAME] == "TP357 (2142) Battery" + assert battery_sensor_attributes[ATTR_UNIT_OF_MEASUREMENT] == "%" + assert battery_sensor_attributes[ATTR_STATE_CLASS] == "measurement" assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_block_till_done()