Migrate iZone to has entity name (#98234)

This commit is contained in:
Joost Lekkerkerker
2023-08-11 13:53:11 +02:00
committed by GitHub
parent fe794e2be3
commit 27876b929b

View File

@@ -133,6 +133,8 @@ class ControllerDevice(ClimateEntity):
_attr_precision = PRECISION_TENTHS
_attr_should_poll = False
_attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_has_entity_name = True
_attr_name = None
def __init__(self, controller: Controller) -> None:
"""Initialise ControllerDevice."""
@@ -169,7 +171,7 @@ class ControllerDevice(ClimateEntity):
identifiers={(IZONE, self.unique_id)},
manufacturer="IZone",
model=self._controller.sys_type,
name=self.name,
name=f"iZone Controller {self._controller.device_uid}",
)
# Create the zones
@@ -256,11 +258,6 @@ class ControllerDevice(ClimateEntity):
"""Return the ID of the controller device."""
return self._controller.device_uid
@property
def name(self) -> str:
"""Return the name of the entity."""
return f"iZone Controller {self._controller.device_uid}"
@property
def extra_state_attributes(self) -> Mapping[str, Any]:
"""Return the optional state attributes."""
@@ -444,13 +441,14 @@ class ZoneDevice(ClimateEntity):
_attr_precision = PRECISION_TENTHS
_attr_should_poll = False
_attr_has_entity_name = True
_attr_name = None
_attr_temperature_unit = UnitOfTemperature.CELSIUS
def __init__(self, controller: ControllerDevice, zone: Zone) -> None:
"""Initialise ZoneDevice."""
self._controller = controller
self._zone = zone
self._name = zone.name.title()
if zone.type != Zone.Type.AUTO:
self._state_to_pizone = {
@@ -471,7 +469,7 @@ class ZoneDevice(ClimateEntity):
},
manufacturer="IZone",
model=zone.type.name.title(),
name=self.name,
name=zone.name.title(),
via_device=(IZONE, controller.unique_id),
)
@@ -500,7 +498,6 @@ class ZoneDevice(ClimateEntity):
return
if not self.available:
return
self._name = zone.name.title()
self.async_write_ha_state()
self.async_on_remove(
@@ -517,11 +514,6 @@ class ZoneDevice(ClimateEntity):
"""Return the ID of the controller device."""
return f"{self._controller.unique_id}_z{self._zone.index + 1}"
@property
def name(self) -> str:
"""Return the name of the entity."""
return self._name
@property
@_return_on_connection_error(0)
def supported_features(self) -> ClimateEntityFeature: