Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion homeassistant/components/airzone/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ def __init__(
) -> None:
"""Initialize."""
super().__init__(coordinator, entry, system_zone_id, zone_data)

_id = entry.entry_id if (entry.unique_id is None) else entry.unique_id
Comment thread
Noltari marked this conversation as resolved.
Outdated

self._attr_name = f"{zone_data[AZD_NAME]} {description.name}"
self._attr_unique_id = f"{entry.entry_id}_{system_zone_id}_{description.key}"
self._attr_unique_id = f"{_id}_{system_zone_id}_{description.key}"
self.attributes = description.attributes
self.entity_description = description

Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/airzone/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ def __init__(
) -> None:
"""Initialize Airzone climate entity."""
super().__init__(coordinator, entry, system_zone_id, zone_data)

_id = entry.entry_id if (entry.unique_id is None) else entry.unique_id

self._attr_name = f"{zone_data[AZD_NAME]}"
self._attr_unique_id = f"{entry.entry_id}_{system_zone_id}"
self._attr_unique_id = f"{_id}_{system_zone_id}"
Comment thread
Noltari marked this conversation as resolved.
Outdated
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
self._attr_target_temperature_step = API_TEMPERATURE_STEP
self._attr_max_temp = self.get_zone_value(AZD_TEMP_MAX)
Expand Down
7 changes: 6 additions & 1 deletion homeassistant/components/airzone/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from homeassistant.const import CONF_HOST, CONF_ID, CONF_PORT
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.device_registry import format_mac

from .const import DOMAIN

Expand Down Expand Up @@ -61,13 +62,17 @@ async def async_step_user(
)

try:
await airzone.validate()
mac = await airzone.validate()
except InvalidSystem:
data_schema = SYSTEM_ID_SCHEMA
errors["base"] = "invalid_system_id"
except AirzoneError:
errors["base"] = "cannot_connect"
else:
if mac:
await self.async_set_unique_id(format_mac(mac))
self._abort_if_unique_id_configured()
Comment thread
Noltari marked this conversation as resolved.
Outdated

title = f"Airzone {user_input[CONF_HOST]}:{user_input[CONF_PORT]}"
return self.async_create_entry(title=title, data=user_input)

Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/airzone/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ def __init__(
) -> None:
"""Initialize."""
super().__init__(coordinator, entry, system_zone_id, zone_data)

_id = entry.entry_id if (entry.unique_id is None) else entry.unique_id

self._attr_name = f"{zone_data[AZD_NAME]} {description.name}"
self._attr_unique_id = f"{entry.entry_id}_{system_zone_id}_{description.key}"
self._attr_unique_id = f"{_id}_{system_zone_id}_{description.key}"
self.entity_description = description

if description.key == AZD_TEMP:
Expand Down
4 changes: 2 additions & 2 deletions tests/components/airzone/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from homeassistant.const import CONF_HOST, CONF_ID, CONF_PORT
from homeassistant.core import HomeAssistant

from .util import CONFIG, CONFIG_ID1, CONFIG_NO_ID, HVAC_MOCK
from .util import CONFIG, CONFIG_ID1, CONFIG_NO_ID, HVAC_MOCK, HVAC_WEBSERVER_MOCK

from tests.common import MockConfigEntry

Expand All @@ -35,7 +35,7 @@ async def test_form(hass: HomeAssistant) -> None:
side_effect=SystemOutOfRange,
), patch(
"homeassistant.components.airzone.AirzoneLocalApi.get_webserver",
side_effect=InvalidMethod,
return_value=HVAC_WEBSERVER_MOCK,
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
Expand Down
9 changes: 9 additions & 0 deletions tests/components/airzone/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
API_HEAT_STAGE,
API_HEAT_STAGES,
API_HUMIDITY,
API_MAC,
API_MAX_TEMP,
API_MIN_TEMP,
API_MODE,
Expand All @@ -23,6 +24,8 @@
API_SYSTEM_ID,
API_SYSTEMS,
API_UNITS,
API_WIFI_CHANNEL,
API_WIFI_RSSI,
API_ZONE_ID,
)
from aioairzone.exceptions import InvalidMethod, SystemOutOfRange
Expand Down Expand Up @@ -160,6 +163,12 @@
]
}

HVAC_WEBSERVER_MOCK = {
API_MAC: "11:22:33:44:55:66",
API_WIFI_CHANNEL: 6,
API_WIFI_RSSI: -42,
}


async def async_init_integration(
hass: HomeAssistant,
Expand Down