mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Address late Shelly review (#63754)
* Late review * Apply review comments * Revert review original comment * Optimizization: loop exit * Break instead of return * Missing super init
This commit is contained in:
parent
9a312e7a7d
commit
69c8a02e16
@ -23,7 +23,7 @@ from homeassistant.components.climate.const import (
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
from homeassistant.core import HomeAssistant, State, callback
|
||||
from homeassistant.helpers import device_registry, entity, entity_registry
|
||||
from homeassistant.helpers import device_registry, entity_registry, update_coordinator
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
@ -106,12 +106,13 @@ async def async_restore_climate_entities(
|
||||
_LOGGER.debug("Setup sleeping climate device %s", wrapper.name)
|
||||
_LOGGER.debug("Found entry %s [%s]", entry.original_name, entry.domain)
|
||||
async_add_entities([BlockSleepingClimate(wrapper, None, None, entry)])
|
||||
break
|
||||
|
||||
|
||||
class BlockSleepingClimate(
|
||||
update_coordinator.CoordinatorEntity,
|
||||
RestoreEntity,
|
||||
ClimateEntity,
|
||||
entity.Entity,
|
||||
):
|
||||
"""Representation of a Shelly climate device."""
|
||||
|
||||
@ -123,7 +124,6 @@ class BlockSleepingClimate(
|
||||
_attr_target_temperature_step = SHTRV_01_TEMPERATURE_SETTINGS["step"]
|
||||
_attr_temperature_unit = TEMP_CELSIUS
|
||||
|
||||
# pylint: disable=super-init-not-called
|
||||
def __init__(
|
||||
self,
|
||||
wrapper: BlockDeviceWrapper,
|
||||
@ -133,6 +133,8 @@ class BlockSleepingClimate(
|
||||
) -> None:
|
||||
"""Initialize climate."""
|
||||
|
||||
super().__init__(wrapper)
|
||||
|
||||
self.wrapper = wrapper
|
||||
self.block: Block | None = sensor_block
|
||||
self.control_result: dict[str, Any] | None = None
|
||||
@ -164,11 +166,6 @@ class BlockSleepingClimate(
|
||||
"""Name of entity."""
|
||||
return self.wrapper.name
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""If device should be polled."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> float | None:
|
||||
"""Set target temperature."""
|
||||
@ -300,14 +297,10 @@ class BlockSleepingClimate(
|
||||
list, self.last_state.attributes.get("preset_modes")
|
||||
)
|
||||
|
||||
self.async_on_remove(self.wrapper.async_add_listener(self._update_callback))
|
||||
|
||||
async def async_update(self) -> None:
|
||||
"""Update entity with latest info."""
|
||||
await self.wrapper.async_request_refresh()
|
||||
await super().async_added_to_hass()
|
||||
|
||||
@callback
|
||||
def _update_callback(self) -> None:
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
"""Handle device update."""
|
||||
if not self.wrapper.device.initialized:
|
||||
self.async_write_ha_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user