Skip to content

Commit

Permalink
Bump aiovantage dependency, use different approach to fetching thermo…
Browse files Browse the repository at this point in the history
…stat sensors to increase backwards compatibility
  • Loading branch information
loopj committed Sep 5, 2023
1 parent b7954ee commit 377c2d4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down
19 changes: 12 additions & 7 deletions custom_components/vantage/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = (
Expand All @@ -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,
)
)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/vantage/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"custom_components.vantage"
],
"requirements": [
"aiovantage==0.12.5"
"aiovantage==0.12.6"
],
"version": "0.10.0-beta4",
"zeroconf": [
Expand Down
1 change: 1 addition & 0 deletions custom_components/vantage/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 377c2d4

Please sign in to comment.