Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update aioairzone to v0.6.1 #93629

Merged
merged 2 commits into from
May 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions homeassistant/components/airzone/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from aioairzone.const import (
API_SYSTEM_ID,
API_ZONE_ID,
AZD_AVAILABLE,
AZD_FIRMWARE,
AZD_FULL_NAME,
AZD_ID,
Expand Down Expand Up @@ -66,6 +67,11 @@ def __init__(
)
self._attr_unique_id = entry.unique_id or entry.entry_id

@property
def available(self) -> bool:
"""Return system availability."""
return super().available and self.get_airzone_value(AZD_AVAILABLE)

def get_airzone_value(self, key: str) -> Any:
"""Return system value by key."""
value = None
Expand Down Expand Up @@ -130,6 +136,11 @@ def __init__(
)
self._attr_unique_id = entry.unique_id or entry.entry_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AirzoneSystemEntity and AirzoneZoneEntity almost look like they share enough to have a common base class


@property
def available(self) -> bool:
"""Return zone availability."""
return super().available and self.get_airzone_value(AZD_AVAILABLE)

def get_airzone_value(self, key: str) -> Any:
"""Return zone value by key."""
value = None
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/airzone/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"documentation": "https://www.home-assistant.io/integrations/airzone",
"iot_class": "local_polling",
"loggers": ["aioairzone"],
"requirements": ["aioairzone==0.5.6"]
"requirements": ["aioairzone==0.6.1"]
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ aioairq==0.2.4
aioairzone-cloud==0.1.6

# homeassistant.components.airzone
aioairzone==0.5.6
aioairzone==0.6.1

# homeassistant.components.ambient_station
aioambient==2023.04.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ aioairq==0.2.4
aioairzone-cloud==0.1.6

# homeassistant.components.airzone
aioairzone==0.5.6
aioairzone==0.6.1

# homeassistant.components.ambient_station
aioambient==2023.04.0
Expand Down
2 changes: 0 additions & 2 deletions tests/components/airzone/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
AZD_SYSTEM,
AZD_SYSTEMS,
AZD_ZONES,
AZD_ZONES_NUM,
RAW_HVAC,
RAW_VERSION,
RAW_WEBSERVER,
Expand Down Expand Up @@ -93,7 +92,6 @@ async def test_config_entry_diagnostics(
diag["coord_data"][AZD_SYSTEMS]["1"].items()
>= {
AZD_ID: 1,
AZD_ZONES_NUM: 5,
}.items()
)

Expand Down
50 changes: 49 additions & 1 deletion tests/components/airzone/test_sensor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
"""The sensor tests for the Airzone platform."""

from unittest.mock import patch

from aioairzone.const import API_DATA, API_SYSTEMS

from homeassistant.components.airzone.coordinator import SCAN_INTERVAL
from homeassistant.const import STATE_UNAVAILABLE
from homeassistant.core import HomeAssistant
from homeassistant.util.dt import utcnow

from .util import async_init_integration
from .util import (
HVAC_MOCK,
HVAC_SYSTEMS_MOCK,
HVAC_VERSION_MOCK,
HVAC_WEBSERVER_MOCK,
async_init_integration,
)

from tests.common import async_fire_time_changed


async def test_airzone_create_sensors(
Expand Down Expand Up @@ -58,3 +73,36 @@ async def test_airzone_create_sensors(

state = hass.states.get("sensor.dkn_plus_humidity")
assert state is None


async def test_airzone_sensors_availability(
hass: HomeAssistant, entity_registry_enabled_by_default: None
) -> None:
"""Test sensors availability."""

await async_init_integration(hass)

HVAC_MOCK_UNAVAILABLE_ZONE = {**HVAC_MOCK}
del HVAC_MOCK_UNAVAILABLE_ZONE[API_SYSTEMS][0][API_DATA][1]

with patch(
"homeassistant.components.airzone.AirzoneLocalApi.get_hvac",
return_value=HVAC_MOCK_UNAVAILABLE_ZONE,
), patch(
"homeassistant.components.airzone.AirzoneLocalApi.get_hvac_systems",
return_value=HVAC_SYSTEMS_MOCK,
), patch(
"homeassistant.components.airzone.AirzoneLocalApi.get_version",
return_value=HVAC_VERSION_MOCK,
), patch(
"homeassistant.components.airzone.AirzoneLocalApi.get_webserver",
return_value=HVAC_WEBSERVER_MOCK,
):
async_fire_time_changed(hass, utcnow() + SCAN_INTERVAL)
await hass.async_block_till_done()

state = hass.states.get("sensor.dorm_ppal_temperature")
assert state.state == STATE_UNAVAILABLE

state = hass.states.get("sensor.dorm_ppal_humidity")
assert state.state == STATE_UNAVAILABLE