Skip to content

Honeywell Lyric - Entity Descriptions #54956

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

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions homeassistant/components/lyric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,35 +140,19 @@ def __init__(
location: LyricLocation,
device: LyricDevice,
key: str,
name: str,
icon: str | None,
) -> None:
"""Initialize the Honeywell Lyric entity."""
super().__init__(coordinator)
self._key = key
self._name = name
self._icon = icon
self._location = location
self._mac_id = device.macID
self._device_name = device.name
self._device_model = device.deviceModel
self._update_thermostat = coordinator.data.update_thermostat

@property
def unique_id(self) -> str:
"""Return the unique ID for this entity."""
return self._key

@property
def name(self) -> str:
"""Return the name of the entity."""
return self._name

@property
def icon(self) -> str:
"""Return the mdi icon of the entity."""
return self._icon

@property
def location(self) -> LyricLocation:
"""Get the Lyric Location."""
Expand All @@ -189,6 +173,6 @@ def device_info(self) -> DeviceInfo:
return {
"connections": {(dr.CONNECTION_NETWORK_MAC, self._mac_id)},
"manufacturer": "Honeywell",
"model": self._device_model,
"name": self._device_name,
"model": self.device.deviceModel,
Copy link
Member

Choose a reason for hiding this comment

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

I don't see self.device defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's here:

@property
def device(self) -> LyricDevice:
"""Get the Lyric Device."""
return self.location.devices_dict[self._mac_id]

Copy link
Member

Choose a reason for hiding this comment

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

The coordinator holds the location, which again holds the device, there is no need to pass location or device to the class when the coordinator is passed to it.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like there are multipe locations

image

"name": self.device.name,
}
18 changes: 14 additions & 4 deletions homeassistant/components/lyric/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from aiolyric.objects.location import LyricLocation
import voluptuous as vol

from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate import ClimateEntity, ClimateEntityDescription
from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
Expand Down Expand Up @@ -99,7 +99,14 @@ async def async_setup_entry(
for device in location.devices:
entities.append(
LyricClimate(
coordinator, location, device, hass.config.units.temperature_unit
coordinator,
ClimateEntityDescription(
key=f"{device.macID}_thermostat",
name=device.name,
),
location,
device,
hass.config.units.temperature_unit,
)
)

Expand All @@ -117,9 +124,13 @@ async def async_setup_entry(
class LyricClimate(LyricDeviceEntity, ClimateEntity):
"""Defines a Honeywell Lyric climate entity."""

coordinator: DataUpdateCoordinator
entity_description: ClimateEntityDescription

def __init__(
self,
coordinator: DataUpdateCoordinator,
description: ClimateEntityDescription,
location: LyricLocation,
device: LyricDevice,
temperature_unit: str,
Expand Down Expand Up @@ -148,9 +159,8 @@ def __init__(
location,
device,
f"{device.macID}_thermostat",
device.name,
None,
)
self.entity_description = description

@property
def supported_features(self) -> int:
Expand Down
Loading