Skip to content

Commit

Permalink
Update aiolyric to 2.0.1 (#123424)
Browse files Browse the repository at this point in the history
update aiolyric to 2.0.1
  • Loading branch information
dalinicus authored Aug 18, 2024
1 parent 7d326ff commit df58068
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 66 deletions.
22 changes: 12 additions & 10 deletions homeassistant/components/lyric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from aiolyric.exceptions import LyricAuthenticationException, LyricException
from aiolyric.objects.device import LyricDevice
from aiolyric.objects.location import LyricLocation
from aiolyric.objects.priority import LyricAccessories, LyricRoom
from aiolyric.objects.priority import LyricAccessory, LyricRoom

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
Expand Down Expand Up @@ -80,11 +80,13 @@ async def async_update_data(force_refresh_token: bool = False) -> Lyric:
await lyric.get_locations()
await asyncio.gather(
*(
lyric.get_thermostat_rooms(location.locationID, device.deviceID)
lyric.get_thermostat_rooms(
location.location_id, device.device_id
)
for location in lyric.locations
for device in location.devices
if device.deviceClass == "Thermostat"
and device.deviceID.startswith("LCC")
if device.device_class == "Thermostat"
and device.device_id.startswith("LCC")
)
)

Expand Down Expand Up @@ -143,7 +145,7 @@ def __init__(
super().__init__(coordinator)
self._key = key
self._location = location
self._mac_id = device.macID
self._mac_id = device.mac_id
self._update_thermostat = coordinator.data.update_thermostat
self._update_fan = coordinator.data.update_fan

Expand All @@ -155,7 +157,7 @@ def unique_id(self) -> str:
@property
def location(self) -> LyricLocation:
"""Get the Lyric Location."""
return self.coordinator.data.locations_dict[self._location.locationID]
return self.coordinator.data.locations_dict[self._location.location_id]

@property
def device(self) -> LyricDevice:
Expand All @@ -173,7 +175,7 @@ def device_info(self) -> DeviceInfo:
identifiers={(dr.CONNECTION_NETWORK_MAC, self._mac_id)},
connections={(dr.CONNECTION_NETWORK_MAC, self._mac_id)},
manufacturer="Honeywell",
model=self.device.deviceModel,
model=self.device.device_model,
name=f"{self.device.name} Thermostat",
)

Expand All @@ -187,7 +189,7 @@ def __init__(
location: LyricLocation,
device: LyricDevice,
room: LyricRoom,
accessory: LyricAccessories,
accessory: LyricAccessory,
key: str,
) -> None:
"""Initialize the Honeywell Lyric accessory entity."""
Expand All @@ -207,7 +209,7 @@ def device_info(self) -> DeviceInfo:
},
manufacturer="Honeywell",
model="RCHTSENSOR",
name=f"{self.room.roomName} Sensor",
name=f"{self.room.room_name} Sensor",
via_device=(dr.CONNECTION_NETWORK_MAC, self._mac_id),
)

Expand All @@ -217,7 +219,7 @@ def room(self) -> LyricRoom:
return self.coordinator.data.rooms_dict[self._mac_id][self._room_id]

@property
def accessory(self) -> LyricAccessories:
def accessory(self) -> LyricAccessory:
"""Get the Lyric Device."""
return next(
accessory
Expand Down
64 changes: 32 additions & 32 deletions homeassistant/components/lyric/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async def async_setup_entry(
LyricClimate(
coordinator,
ClimateEntityDescription(
key=f"{device.macID}_thermostat",
key=f"{device.mac_id}_thermostat",
name=device.name,
),
location,
Expand Down Expand Up @@ -185,7 +185,7 @@ def __init__(
) -> None:
"""Initialize Honeywell Lyric climate entity."""
# Define thermostat type (TCC - e.g., Lyric round; LCC - e.g., T5,6)
if device.changeableValues.thermostatSetpointStatus:
if device.changeable_values.thermostat_setpoint_status:
self._attr_thermostat_type = LyricThermostatType.LCC
else:
self._attr_thermostat_type = LyricThermostatType.TCC
Expand All @@ -202,15 +202,15 @@ def __init__(
self._attr_hvac_modes = [HVACMode.OFF]

# Add supported lyric thermostat features
if LYRIC_HVAC_MODE_HEAT in device.allowedModes:
if LYRIC_HVAC_MODE_HEAT in device.allowed_modes:
self._attr_hvac_modes.append(HVACMode.HEAT)

if LYRIC_HVAC_MODE_COOL in device.allowedModes:
if LYRIC_HVAC_MODE_COOL in device.allowed_modes:
self._attr_hvac_modes.append(HVACMode.COOL)

if (
LYRIC_HVAC_MODE_HEAT in device.allowedModes
and LYRIC_HVAC_MODE_COOL in device.allowedModes
LYRIC_HVAC_MODE_HEAT in device.allowed_modes
and LYRIC_HVAC_MODE_COOL in device.allowed_modes
):
self._attr_hvac_modes.append(HVACMode.HEAT_COOL)

Expand Down Expand Up @@ -242,83 +242,83 @@ def __init__(
coordinator,
location,
device,
f"{device.macID}_thermostat",
f"{device.mac_id}_thermostat",
)
self.entity_description = description

@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
return self.device.indoorTemperature
return self.device.indoor_temperature

@property
def hvac_action(self) -> HVACAction | None:
"""Return the current hvac action."""
action = HVAC_ACTIONS.get(self.device.operationStatus.mode, None)
action = HVAC_ACTIONS.get(self.device.operation_status.mode, None)
if action == HVACAction.OFF and self.hvac_mode != HVACMode.OFF:
action = HVACAction.IDLE
return action

@property
def hvac_mode(self) -> HVACMode:
"""Return the hvac mode."""
return HVAC_MODES[self.device.changeableValues.mode]
return HVAC_MODES[self.device.changeable_values.mode]

@property
def target_temperature(self) -> float | None:
"""Return the temperature we try to reach."""
device = self.device
if (
device.changeableValues.autoChangeoverActive
or HVAC_MODES[device.changeableValues.mode] == HVACMode.OFF
device.changeable_values.auto_changeover_active
or HVAC_MODES[device.changeable_values.mode] == HVACMode.OFF
):
return None
if self.hvac_mode == HVACMode.COOL:
return device.changeableValues.coolSetpoint
return device.changeableValues.heatSetpoint
return device.changeable_values.cool_setpoint
return device.changeable_values.heat_setpoint

@property
def target_temperature_high(self) -> float | None:
"""Return the highbound target temperature we try to reach."""
device = self.device
if (
not device.changeableValues.autoChangeoverActive
or HVAC_MODES[device.changeableValues.mode] == HVACMode.OFF
not device.changeable_values.auto_changeover_active
or HVAC_MODES[device.changeable_values.mode] == HVACMode.OFF
):
return None
return device.changeableValues.coolSetpoint
return device.changeable_values.cool_setpoint

@property
def target_temperature_low(self) -> float | None:
"""Return the lowbound target temperature we try to reach."""
device = self.device
if (
not device.changeableValues.autoChangeoverActive
or HVAC_MODES[device.changeableValues.mode] == HVACMode.OFF
not device.changeable_values.auto_changeover_active
or HVAC_MODES[device.changeable_values.mode] == HVACMode.OFF
):
return None
return device.changeableValues.heatSetpoint
return device.changeable_values.heat_setpoint

@property
def preset_mode(self) -> str | None:
"""Return current preset mode."""
return self.device.changeableValues.thermostatSetpointStatus
return self.device.changeable_values.thermostat_setpoint_status

@property
def min_temp(self) -> float:
"""Identify min_temp in Lyric API or defaults if not available."""
device = self.device
if LYRIC_HVAC_MODE_COOL in device.allowedModes:
return device.minCoolSetpoint
return device.minHeatSetpoint
if LYRIC_HVAC_MODE_COOL in device.allowed_modes:
return device.min_cool_setpoint
return device.min_heat_setpoint

@property
def max_temp(self) -> float:
"""Identify max_temp in Lyric API or defaults if not available."""
device = self.device
if LYRIC_HVAC_MODE_HEAT in device.allowedModes:
return device.maxHeatSetpoint
return device.maxCoolSetpoint
if LYRIC_HVAC_MODE_HEAT in device.allowed_modes:
return device.max_heat_setpoint
return device.max_cool_setpoint

@property
def fan_mode(self) -> str | None:
Expand All @@ -339,7 +339,7 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
target_temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
target_temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)

if device.changeableValues.mode == LYRIC_HVAC_MODE_HEAT_COOL:
if device.changeable_values.mode == LYRIC_HVAC_MODE_HEAT_COOL:
if target_temp_low is None or target_temp_high is None:
raise HomeAssistantError(
"Could not find target_temp_low and/or target_temp_high in"
Expand All @@ -349,7 +349,7 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
# If TCC device pass the heatCoolMode value, otherwise
# if LCC device can skip the mode altogether
if self._attr_thermostat_type is LyricThermostatType.TCC:
mode = HVAC_MODES[device.changeableValues.heatCoolMode]
mode = HVAC_MODES[device.changeable_values.heat_cool_mode]
else:
mode = None

Expand Down Expand Up @@ -401,7 +401,7 @@ async def _async_set_hvac_mode_tcc(self, hvac_mode: HVACMode) -> None:
# otherwise it turns to Auto briefly and then reverts to Off.
# This is the behavior that happens with the native app as well,
# so likely a bug in the api itself.
if HVAC_MODES[self.device.changeableValues.mode] == HVACMode.OFF:
if HVAC_MODES[self.device.changeable_values.mode] == HVACMode.OFF:
_LOGGER.debug(
"HVAC mode passed to lyric: %s",
HVAC_MODES[LYRIC_HVAC_MODE_COOL],
Expand All @@ -427,7 +427,7 @@ async def _async_set_hvac_mode_tcc(self, hvac_mode: HVACMode) -> None:
else:
_LOGGER.debug(
"HVAC mode passed to lyric: %s",
HVAC_MODES[self.device.changeableValues.mode],
HVAC_MODES[self.device.changeable_values.mode],
)
await self._update_thermostat(
self.location, self.device, autoChangeoverActive=True
Expand All @@ -448,7 +448,7 @@ async def _async_set_hvac_mode_lcc(self, hvac_mode: HVACMode) -> None:
# otherwise leave unchanged.
if (
LYRIC_HVAC_MODES[hvac_mode] == LYRIC_HVAC_MODE_HEAT_COOL
and not self.device.changeableValues.autoChangeoverActive
and not self.device.changeable_values.auto_changeover_active
):
auto_changeover = True
else:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/lyric/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"iot_class": "cloud_polling",
"loggers": ["aiolyric"],
"quality_scale": "silver",
"requirements": ["aiolyric==1.1.0"]
"requirements": ["aiolyric==2.0.1"]
}
Loading

0 comments on commit df58068

Please sign in to comment.