diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 161bc52..66dd09b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: hooks: - id: mypy additional_dependencies: - - aiovantage==0.12.5 + - aiovantage==0.12.6 - voluptuous-stubs==0.1.1 - homeassistant-stubs==2023.8.1 args: [] diff --git a/custom_components/vantage/climate.py b/custom_components/vantage/climate.py index 20dd22e..47ea52d 100644 --- a/custom_components/vantage/climate.py +++ b/custom_components/vantage/climate.py @@ -7,7 +7,7 @@ from typing import Any from aiovantage import Vantage, VantageEvent -from aiovantage.models import Temperature, Thermostat +from aiovantage.models import Thermostat from homeassistant.components.climate import ( ATTR_TARGET_TEMP_HIGH, @@ -75,10 +75,9 @@ def __post_init__(self) -> None: """Initialize a Vantage Cover.""" # Look up the sensors attached to this thermostat - self.sensors = self.client.thermostats.sensors(self.obj.id) - self.temperature = self.sensors.get(setpoint=None) - self.cool_setpoint = self.sensors.get(setpoint=Temperature.Setpoint.COOL) - self.heat_setpoint = self.sensors.get(setpoint=Temperature.Setpoint.HEAT) + self.temperature = self.client.thermostats.indoor_sensor(self.obj.id).first() + self.cool_setpoint = self.client.thermostats.cool_setpoint(self.obj.id).first() + self.heat_setpoint = self.client.thermostats.heat_setpoint(self.obj.id).first() # Set up the entity attributes self._attr_supported_features = ( @@ -103,11 +102,17 @@ async def async_added_to_hass(self) -> None: """Register callbacks.""" await super().async_added_to_hass() - # Register a callback for when the temperature sensors are updated + # Register a callback for when child temperature sensors are updated + sensor_ids = [ + obj.id + for obj in [self.temperature, self.cool_setpoint, self.heat_setpoint] + if obj is not None + ] + self.async_on_remove( self.client.temperature_sensors.subscribe( lambda e, o, d: self.async_write_ha_state(), - (obj.id for obj in self.sensors), + sensor_ids, VantageEvent.OBJECT_UPDATED, ) ) diff --git a/custom_components/vantage/manifest.json b/custom_components/vantage/manifest.json index 17d5c16..fc5347c 100644 --- a/custom_components/vantage/manifest.json +++ b/custom_components/vantage/manifest.json @@ -17,7 +17,7 @@ "custom_components.vantage" ], "requirements": [ - "aiovantage==0.12.5" + "aiovantage==0.12.6" ], "version": "0.10.0-beta4", "zeroconf": [ diff --git a/custom_components/vantage/sensor.py b/custom_components/vantage/sensor.py index 1627b13..a975b81 100644 --- a/custom_components/vantage/sensor.py +++ b/custom_components/vantage/sensor.py @@ -51,6 +51,7 @@ class VantageTemperatureSensor(VantageEntity[Temperature], SensorEntity): _attr_device_class = SensorDeviceClass.TEMPERATURE _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS _attr_state_class = "measurement" + _attr_suggested_display_precision = 1 def __post_init__(self) -> None: """Initialize a Vantage temperature sensor.""" diff --git a/requirements.txt b/requirements.txt index fd87954..906f461 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ homeassistant==2023.8.1 colorlog==6.7.0 # Use a specific version of aiovantage -aiovantage==0.12.5 +aiovantage==0.12.6 # Use a local version of aiovantage # -e ../aiovantage