Skip to content

Commit d66b9f4

Browse files
authored
Bump actron-neo-api to 0.5.3 (home-assistant#167732)
1 parent 40477ff commit d66b9f4

16 files changed

Lines changed: 168 additions & 21 deletions

.strict-typing

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ homeassistant.components.accuweather.*
4646
homeassistant.components.acer_projector.*
4747
homeassistant.components.acmeda.*
4848
homeassistant.components.actiontec.*
49+
homeassistant.components.actron_air.*
4950
homeassistant.components.adax.*
5051
homeassistant.components.adguard.*
5152
homeassistant.components.aftership.*

homeassistant/components/actron_air/climate.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
)
1616
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
1717
from homeassistant.core import HomeAssistant
18+
from homeassistant.exceptions import ServiceValidationError
1819
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
1920

21+
from .const import DOMAIN
2022
from .coordinator import ActronAirConfigEntry, ActronAirSystemCoordinator
2123
from .entity import ActronAirAcEntity, ActronAirZoneEntity, actron_air_command
2224

@@ -139,20 +141,24 @@ def target_temperature(self) -> float:
139141
@actron_air_command
140142
async def async_set_fan_mode(self, fan_mode: str) -> None:
141143
"""Set a new fan mode."""
142-
api_fan_mode = FAN_MODE_MAPPING_HA_TO_ACTRONAIR.get(fan_mode)
144+
api_fan_mode = FAN_MODE_MAPPING_HA_TO_ACTRONAIR[fan_mode]
143145
await self._status.user_aircon_settings.set_fan_mode(api_fan_mode)
144146

145147
@actron_air_command
146148
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
147149
"""Set the HVAC mode."""
148-
ac_mode = HVAC_MODE_MAPPING_HA_TO_ACTRONAIR.get(hvac_mode)
150+
ac_mode = HVAC_MODE_MAPPING_HA_TO_ACTRONAIR[hvac_mode]
149151
await self._status.ac_system.set_system_mode(ac_mode)
150152

151153
@actron_air_command
152154
async def async_set_temperature(self, **kwargs: Any) -> None:
153155
"""Set the temperature."""
154-
temp = kwargs.get(ATTR_TEMPERATURE)
155-
await self._status.user_aircon_settings.set_temperature(temperature=temp)
156+
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
157+
raise ServiceValidationError(
158+
translation_domain=DOMAIN,
159+
translation_key="temperature_missing",
160+
)
161+
await self._status.user_aircon_settings.set_temperature(temperature=temperature)
156162

157163

158164
class ActronZoneClimate(ActronAirZoneEntity, ActronAirClimateEntity):
@@ -221,4 +227,9 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
221227
@actron_air_command
222228
async def async_set_temperature(self, **kwargs: Any) -> None:
223229
"""Set the temperature."""
224-
await self._zone.set_temperature(temperature=kwargs.get(ATTR_TEMPERATURE))
230+
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
231+
raise ServiceValidationError(
232+
translation_domain=DOMAIN,
233+
translation_key="temperature_missing",
234+
)
235+
await self._zone.set_temperature(temperature=temperature)

homeassistant/components/actron_air/config_flow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self) -> None:
2323
self._user_code: str = ""
2424
self._verification_uri: str = ""
2525
self._expires_minutes: str = "30"
26-
self.login_task: asyncio.Task | None = None
26+
self.login_task: asyncio.Task[None] | None = None
2727

2828
async def async_step_user(
2929
self, user_input: dict[str, Any] | None = None
@@ -94,7 +94,7 @@ async def async_step_finish_login(
9494
_LOGGER.error("Error getting user info: %s", err)
9595
return self.async_abort(reason="oauth2_error")
9696

97-
unique_id = str(user_data["id"])
97+
unique_id = user_data.sub
9898
await self.async_set_unique_id(unique_id)
9999

100100
# Check if this is a reauth flow
@@ -107,7 +107,7 @@ async def async_step_finish_login(
107107

108108
self._abort_if_unique_id_configured()
109109
return self.async_create_entry(
110-
title=user_data["email"],
110+
title=user_data.email,
111111
data={CONF_API_TOKEN: self._api.refresh_token_value},
112112
)
113113

homeassistant/components/actron_air/coordinator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@ async def _async_update_data(self) -> ActronAirStatus:
7878
translation_placeholders={"error": repr(err)},
7979
) from err
8080

81-
self.status = self.api.state_manager.get_status(self.serial_number)
81+
status = self.api.state_manager.get_status(self.serial_number)
82+
if status is None:
83+
raise UpdateFailed(
84+
translation_domain=DOMAIN,
85+
translation_key="update_error",
86+
translation_placeholders={"error": "Status not available"},
87+
)
88+
self.status = status
8289
self.last_seen = dt_util.utcnow()
8390
return self.status
8491

homeassistant/components/actron_air/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def actron_air_command[_EntityT: ActronAirEntity, **_P](
2424
"""
2525

2626
@wraps(func)
27-
async def wrapper(self: _EntityT, *args: _P.args, **kwargs: _P.kwargs) -> None:
27+
async def wrapper(self: _EntityT, /, *args: _P.args, **kwargs: _P.kwargs) -> None:
2828
"""Wrap API calls with exception handling."""
2929
try:
3030
await func(self, *args, **kwargs)

homeassistant/components/actron_air/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"integration_type": "hub",
1414
"iot_class": "cloud_polling",
1515
"quality_scale": "silver",
16-
"requirements": ["actron-neo-api==0.5.0"]
16+
"requirements": ["actron-neo-api==0.5.3"]
1717
}

homeassistant/components/actron_air/quality_scale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ rules:
6969
# Platinum
7070
async-dependency: done
7171
inject-websession: todo
72-
strict-typing: todo
72+
strict-typing: done

homeassistant/components/actron_air/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
"setup_connection_error": {
5959
"message": "Failed to connect to the Actron Air API"
6060
},
61+
"temperature_missing": {
62+
"message": "Provide a temperature value when adjusting the climate entity."
63+
},
6164
"update_error": {
6265
"message": "An error occurred while retrieving data from the Actron Air API: {error}"
6366
}

mypy.ini

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)