From 7f56330e3b844f5ac3e723b901451eadc18aa744 Mon Sep 17 00:00:00 2001 From: John Hess Date: Wed, 24 Jan 2024 20:26:58 -0700 Subject: [PATCH] Bump thermopro-ble to 0.9.0 (#108820) --- CODEOWNERS | 4 +- .../components/thermopro/manifest.json | 4 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/thermopro/__init__.py | 20 +++++ tests/components/thermopro/test_sensor.py | 84 ++++++++++++++++++- 6 files changed, 109 insertions(+), 7 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index dae1d0f1806..339d4aca6ea 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1351,8 +1351,8 @@ build.json @home-assistant/supervisor /homeassistant/components/tfiac/ @fredrike @mellado /homeassistant/components/thermobeacon/ @bdraco /tests/components/thermobeacon/ @bdraco -/homeassistant/components/thermopro/ @bdraco -/tests/components/thermopro/ @bdraco +/homeassistant/components/thermopro/ @bdraco @h3ss +/tests/components/thermopro/ @bdraco @h3ss /homeassistant/components/thethingsnetwork/ @fabaff /homeassistant/components/thread/ @home-assistant/core /tests/components/thread/ @home-assistant/core diff --git a/homeassistant/components/thermopro/manifest.json b/homeassistant/components/thermopro/manifest.json index 237cd39fb66..817df22d6e1 100644 --- a/homeassistant/components/thermopro/manifest.json +++ b/homeassistant/components/thermopro/manifest.json @@ -15,10 +15,10 @@ "connectable": false } ], - "codeowners": ["@bdraco"], + "codeowners": ["@bdraco", "@h3ss"], "config_flow": true, "dependencies": ["bluetooth_adapters"], "documentation": "https://www.home-assistant.io/integrations/thermopro", "iot_class": "local_push", - "requirements": ["thermopro-ble==0.8.0"] + "requirements": ["thermopro-ble==0.9.0"] } diff --git a/requirements_all.txt b/requirements_all.txt index 67189ca9044..848c6948490 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2672,7 +2672,7 @@ tessie-api==0.0.9 thermobeacon-ble==0.6.2 # homeassistant.components.thermopro -thermopro-ble==0.8.0 +thermopro-ble==0.9.0 # homeassistant.components.thermoworks_smoke thermoworks-smoke==0.1.8 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3c0bffd42d0..4c5cbe5cb8b 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2028,7 +2028,7 @@ tessie-api==0.0.9 thermobeacon-ble==0.6.2 # homeassistant.components.thermopro -thermopro-ble==0.8.0 +thermopro-ble==0.9.0 # homeassistant.components.tilt_ble tilt-ble==0.2.3 diff --git a/tests/components/thermopro/__init__.py b/tests/components/thermopro/__init__.py index a7dd5fcf9c5..f66b608f6d3 100644 --- a/tests/components/thermopro/__init__.py +++ b/tests/components/thermopro/__init__.py @@ -23,3 +23,23 @@ TP357_SERVICE_INFO = BluetoothServiceInfo( service_data={}, source="local", ) + +TP962R_SERVICE_INFO = BluetoothServiceInfo( + name="TP962R (0000)", + manufacturer_data={14081: b"\x00;\x0b7\x00"}, + service_uuids=["72fbb631-6f6b-d1ba-db55-2ee6fdd942bd"], + address="aa:bb:cc:dd:ee:ff", + rssi=-52, + service_data={}, + source="local", +) + +TP962R_SERVICE_INFO_2 = BluetoothServiceInfo( + name="TP962R (0000)", + manufacturer_data={17152: b"\x00\x17\nC\x00", 14081: b"\x00;\x0b7\x00"}, + service_uuids=["72fbb631-6f6b-d1ba-db55-2ee6fdd942bd"], + address="aa:bb:cc:dd:ee:ff", + rssi=-52, + service_data={}, + source="local", +) diff --git a/tests/components/thermopro/test_sensor.py b/tests/components/thermopro/test_sensor.py index bead3a53dea..d754991f3d8 100644 --- a/tests/components/thermopro/test_sensor.py +++ b/tests/components/thermopro/test_sensor.py @@ -4,12 +4,94 @@ from homeassistant.components.thermopro.const import DOMAIN from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT from homeassistant.core import HomeAssistant -from . import TP357_SERVICE_INFO +from . import TP357_SERVICE_INFO, TP962R_SERVICE_INFO, TP962R_SERVICE_INFO_2 from tests.common import MockConfigEntry from tests.components.bluetooth import inject_bluetooth_service_info +async def test_sensors_tp962r(hass: HomeAssistant) -> None: + """Test setting up creates the sensors.""" + entry = MockConfigEntry( + domain=DOMAIN, + unique_id="aa:bb:cc:dd:ee:ff", + ) + entry.add_to_hass(hass) + + assert await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() + + assert len(hass.states.async_all()) == 0 + inject_bluetooth_service_info(hass, TP962R_SERVICE_INFO) + await hass.async_block_till_done() + assert len(hass.states.async_all()) == 3 + + temp_sensor = hass.states.get("sensor.tp962r_0000_probe_2_internal_temperature") + temp_sensor_attributes = temp_sensor.attributes + assert temp_sensor.state == "25" + assert ( + temp_sensor_attributes[ATTR_FRIENDLY_NAME] + == "TP962R (0000) Probe 2 Internal Temperature" + ) + assert temp_sensor_attributes[ATTR_UNIT_OF_MEASUREMENT] == "°C" + assert temp_sensor_attributes[ATTR_STATE_CLASS] == "measurement" + + temp_sensor = hass.states.get("sensor.tp962r_0000_probe_2_ambient_temperature") + temp_sensor_attributes = temp_sensor.attributes + assert temp_sensor.state == "25" + assert ( + temp_sensor_attributes[ATTR_FRIENDLY_NAME] + == "TP962R (0000) Probe 2 Ambient Temperature" + ) + assert temp_sensor_attributes[ATTR_UNIT_OF_MEASUREMENT] == "°C" + assert temp_sensor_attributes[ATTR_STATE_CLASS] == "measurement" + + battery_sensor = hass.states.get("sensor.tp962r_0000_probe_2_battery") + battery_sensor_attributes = battery_sensor.attributes + assert battery_sensor.state == "100" + assert ( + battery_sensor_attributes[ATTR_FRIENDLY_NAME] == "TP962R (0000) Probe 2 Battery" + ) + assert battery_sensor_attributes[ATTR_UNIT_OF_MEASUREMENT] == "%" + assert battery_sensor_attributes[ATTR_STATE_CLASS] == "measurement" + + inject_bluetooth_service_info(hass, TP962R_SERVICE_INFO_2) + await hass.async_block_till_done() + assert len(hass.states.async_all()) == 6 + + temp_sensor = hass.states.get("sensor.tp962r_0000_probe_1_internal_temperature") + temp_sensor_attributes = temp_sensor.attributes + assert temp_sensor.state == "37" + assert ( + temp_sensor_attributes[ATTR_FRIENDLY_NAME] + == "TP962R (0000) Probe 1 Internal Temperature" + ) + assert temp_sensor_attributes[ATTR_UNIT_OF_MEASUREMENT] == "°C" + assert temp_sensor_attributes[ATTR_STATE_CLASS] == "measurement" + + temp_sensor = hass.states.get("sensor.tp962r_0000_probe_1_ambient_temperature") + temp_sensor_attributes = temp_sensor.attributes + assert temp_sensor.state == "37" + assert ( + temp_sensor_attributes[ATTR_FRIENDLY_NAME] + == "TP962R (0000) Probe 1 Ambient Temperature" + ) + assert temp_sensor_attributes[ATTR_UNIT_OF_MEASUREMENT] == "°C" + assert temp_sensor_attributes[ATTR_STATE_CLASS] == "measurement" + + battery_sensor = hass.states.get("sensor.tp962r_0000_probe_1_battery") + battery_sensor_attributes = battery_sensor.attributes + assert battery_sensor.state == "82.0" + assert ( + battery_sensor_attributes[ATTR_FRIENDLY_NAME] == "TP962R (0000) Probe 1 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() + + async def test_sensors(hass: HomeAssistant) -> None: """Test setting up creates the sensors.""" entry = MockConfigEntry(