mirror of
https://github.com/home-assistant/core.git
synced 2025-08-08 07:05:07 +02:00
Apply PR Feedback
This commit is contained in:
@@ -84,7 +84,7 @@ class CCM15Coordinator(DataUpdateCoordinator[CCM15DeviceState]):
|
|||||||
if await self._ccm15.async_set_state(ac_index, state, value):
|
if await self._ccm15.async_set_state(ac_index, state, value):
|
||||||
await self.async_request_refresh()
|
await self.async_request_refresh()
|
||||||
|
|
||||||
def get_ac_data(self, ac_index: int) -> Optional[CCM15SlaveDevice]:
|
def get_ac_data(self, ac_index: int) -> CCM15SlaveDevice | None:
|
||||||
"""Get ac data from the ac_index."""
|
"""Get ac data from the ac_index."""
|
||||||
if ac_index < 0 or ac_index >= len(self.data.devices):
|
if ac_index < 0 or ac_index >= len(self.data.devices):
|
||||||
# Index is out of bounds or not an integer
|
# Index is out of bounds or not an integer
|
||||||
@@ -143,23 +143,20 @@ class CCM15Climate(CoordinatorEntity[CCM15Coordinator], ClimateEntity):
|
|||||||
return UnitOfTemperature.CELSIUS
|
return UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self) -> Optional[int]:
|
def current_temperature(self) -> int | None:
|
||||||
"""Return current temperature."""
|
"""Return current temperature."""
|
||||||
if data := self.coordinator.get_ac_data(self._ac_index):
|
if data := self.coordinator.get_ac_data(self._ac_index):
|
||||||
_LOGGER.debug("temp[%s]=%s", self._ac_index, data.temperature)
|
_LOGGER.debug("temp[%s]=%s", self._ac_index, data.temperature)
|
||||||
return data.temperature
|
return data.temperature
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self) -> Optional[int]:
|
def target_temperature(self) -> int | None:
|
||||||
"""Return target temperature."""
|
"""Return target temperature."""
|
||||||
data: Optional[CCM15SlaveDevice] = self.coordinator.get_ac_data(self._ac_index)
|
if data := self.coordinator.get_ac_data(self._ac_index):
|
||||||
if data is None:
|
_LOGGER.debug("set_temp[%s]=%s", self._ac_index, data.temperature_setpoint)
|
||||||
return None
|
return data.temperature_setpoint
|
||||||
|
return None
|
||||||
_LOGGER.debug("set_temp[%s]=%s", self._ac_index, data.temperature_setpoint)
|
|
||||||
return data.temperature_setpoint
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_step(self) -> int:
|
def target_temperature_step(self) -> int:
|
||||||
@@ -167,15 +164,13 @@ class CCM15Climate(CoordinatorEntity[CCM15Coordinator], ClimateEntity):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> Optional[HVACMode]:
|
def hvac_mode(self) -> HVACMode | None:
|
||||||
"""Return hvac mode."""
|
"""Return hvac mode."""
|
||||||
data: Optional[CCM15SlaveDevice] = self.coordinator.get_ac_data(self._ac_index)
|
if data := self.coordinator.get_ac_data(self._ac_index):
|
||||||
if data is None:
|
mode = data.ac_mode
|
||||||
return None
|
_LOGGER.debug("hvac_mode[%s]=%s", self._ac_index, mode)
|
||||||
|
return CONST_CMD_STATE_MAP[mode]
|
||||||
mode = data.ac_mode
|
return None
|
||||||
_LOGGER.debug("hvac_mode[%s]=%s", self._ac_index, mode)
|
|
||||||
return CONST_CMD_STATE_MAP[mode]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_modes(self) -> list[HVACMode]:
|
def hvac_modes(self) -> list[HVACMode]:
|
||||||
@@ -183,14 +178,13 @@ class CCM15Climate(CoordinatorEntity[CCM15Coordinator], ClimateEntity):
|
|||||||
return [HVACMode.OFF, HVACMode.HEAT, HVACMode.COOL, HVACMode.DRY, HVACMode.AUTO]
|
return [HVACMode.OFF, HVACMode.HEAT, HVACMode.COOL, HVACMode.DRY, HVACMode.AUTO]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_mode(self) -> Optional[str]:
|
def fan_mode(self) -> str | None:
|
||||||
"""Return fan mode."""
|
"""Return fan mode."""
|
||||||
data: Optional[CCM15SlaveDevice] = self.coordinator.get_ac_data(self._ac_index)
|
if data := self.coordinator.get_ac_data(self._ac_index):
|
||||||
if data is None:
|
mode = data.fan_mode
|
||||||
return None
|
_LOGGER.debug("fan_mode[%s]=%s", self._ac_index, mode)
|
||||||
mode = data.fan_mode
|
return CONST_CMD_FAN_MAP[mode]
|
||||||
_LOGGER.debug("fan_mode[%s]=%s", self._ac_index, mode)
|
return None
|
||||||
return CONST_CMD_FAN_MAP[mode]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_modes(self) -> list[str]:
|
def fan_modes(self) -> list[str]:
|
||||||
@@ -198,13 +192,12 @@ class CCM15Climate(CoordinatorEntity[CCM15Coordinator], ClimateEntity):
|
|||||||
return [FAN_AUTO, FAN_LOW, FAN_MEDIUM, FAN_HIGH]
|
return [FAN_AUTO, FAN_LOW, FAN_MEDIUM, FAN_HIGH]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def swing_mode(self) -> Optional[str]:
|
def swing_mode(self) -> str | None:
|
||||||
"""Return swing mode."""
|
"""Return swing mode."""
|
||||||
data: Optional[CCM15SlaveDevice] = self.coordinator.get_ac_data(self._ac_index)
|
if data := self.coordinator.get_ac_data(self._ac_index):
|
||||||
if data is None:
|
_LOGGER.debug("is_swing_on[%s]=%s", self._ac_index, data.is_swing_on)
|
||||||
return None
|
return SWING_ON if data.is_swing_on else SWING_OFF
|
||||||
_LOGGER.debug("is_swing_on[%s]=%s", self._ac_index, data.is_swing_on)
|
return None
|
||||||
return SWING_ON if data.is_swing_on else SWING_OFF
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def swing_modes(self) -> list[str]:
|
def swing_modes(self) -> list[str]:
|
||||||
|
Reference in New Issue
Block a user