Fix climate not available #52

This commit is contained in:
Andre Basche 2023-05-19 01:27:44 +02:00
parent 29238d3d08
commit d963086dbf
9 changed files with 13 additions and 25 deletions

View File

@ -278,8 +278,6 @@ class HonBinarySensorEntity(HonEntity, BinarySensorEntity):
def __init__(self, hass, coordinator, entry, device, description) -> None: def __init__(self, hass, coordinator, entry, device, description) -> None:
super().__init__(hass, entry, coordinator, device) super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self.entity_description = description self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}" self._attr_unique_id = f"{super().unique_id}{description.key}"

View File

@ -56,8 +56,6 @@ class HonButtonEntity(HonEntity, ButtonEntity):
) -> None: ) -> None:
super().__init__(hass, entry, coordinator, device) super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self._device = device
self.entity_description = description self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}" self._attr_unique_id = f"{super().unique_id}{description.key}"
@ -77,9 +75,7 @@ class HonButtonEntity(HonEntity, ButtonEntity):
class HonFeatureRequestButton(HonEntity, ButtonEntity): class HonFeatureRequestButton(HonEntity, ButtonEntity):
def __init__(self, hass, coordinator, entry, device: HonAppliance) -> None: def __init__(self, hass, coordinator, entry, device: HonAppliance) -> None:
super().__init__(hass, entry, coordinator, device) super().__init__(hass, entry, coordinator, device)
self._hass = hass
self._device = device
self._attr_unique_id = f"{super().unique_id}_log_device_info" self._attr_unique_id = f"{super().unique_id}_log_device_info"
self._attr_icon = "mdi:information" self._attr_icon = "mdi:information"
self._attr_name = "Show Device Info" self._attr_name = "Show Device Info"
@ -88,7 +84,9 @@ class HonFeatureRequestButton(HonEntity, ButtonEntity):
async def async_press(self) -> None: async def async_press(self) -> None:
pyhon_version = pkg_resources.get_distribution("pyhon").version pyhon_version = pkg_resources.get_distribution("pyhon").version
info = f"Device Info:\n{self._device.diagnose()}pyhOnVersion: {pyhon_version}" info = f"{self._device.diagnose()}pyhOnVersion: {pyhon_version}"
title = f"{self._device.nick_name} Device Info" title = f"{self._device.nick_name} Device Info"
persistent_notification.create(self._hass, f"```\n```{info}```\n```", title) persistent_notification.create(
self._hass, f"````\n```\n{info}\n```\n````", title
)
_LOGGER.info(info.replace(" ", "\u200B ")) _LOGGER.info(info.replace(" ", "\u200B "))

View File

@ -56,8 +56,8 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
for description in descriptions: for description in descriptions:
if description.key not in list(device.commands): if description.key not in list(device.commands):
continue continue
appliances.extend( appliances.append(
[HonClimateEntity(hass, coordinator, entry, device, description)] HonClimateEntity(hass, coordinator, entry, device, description)
) )
async_add_entities(appliances) async_add_entities(appliances)
@ -67,10 +67,7 @@ class HonClimateEntity(HonEntity, ClimateEntity):
self, hass, coordinator, entry, device: HonAppliance, description self, hass, coordinator, entry, device: HonAppliance, description
) -> None: ) -> None:
super().__init__(hass, entry, coordinator, device) super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self._device = device
self.entity_description = description self.entity_description = description
self._hass = hass
self._attr_unique_id = f"{super().unique_id}climate" self._attr_unique_id = f"{super().unique_id}climate"
self._attr_temperature_unit = TEMP_CELSIUS self._attr_temperature_unit = TEMP_CELSIUS
@ -96,7 +93,7 @@ class HonClimateEntity(HonEntity, ClimateEntity):
| ClimateEntityFeature.SWING_MODE | ClimateEntityFeature.SWING_MODE
) )
self._handle_coordinator_update() self._handle_coordinator_update(update=False)
async def async_set_hvac_mode(self, hvac_mode): async def async_set_hvac_mode(self, hvac_mode):
if hvac_mode == HVACMode.OFF: if hvac_mode == HVACMode.OFF:
@ -161,4 +158,5 @@ class HonClimateEntity(HonEntity, ClimateEntity):
self._attr_swing_mode = SWING_VERTICAL self._attr_swing_mode = SWING_VERTICAL
else: else:
self._attr_swing_mode = SWING_OFF self._attr_swing_mode = SWING_OFF
self.async_write_ha_state() if update:
self.async_write_ha_state()

View File

@ -19,6 +19,7 @@ class HonEntity(CoordinatorEntity):
self._hon = hass.data[DOMAIN][entry.unique_id] self._hon = hass.data[DOMAIN][entry.unique_id]
self._hass = hass self._hass = hass
self._coordinator = coordinator
self._device = device self._device = device
self._attr_unique_id = self._device.unique_id self._attr_unique_id = self._device.unique_id

View File

@ -6,6 +6,6 @@
"documentation": "https://github.com/Andre0512/hon/", "documentation": "https://github.com/Andre0512/hon/",
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Andre0512/hon/issues", "issue_tracker": "https://github.com/Andre0512/hon/issues",
"requirements": ["pyhOn==0.10.7"], "requirements": ["pyhOn==0.10.9"],
"version": "0.8.0-beta.3" "version": "0.8.0-beta.4"
} }

View File

@ -200,8 +200,6 @@ class HonNumberEntity(HonEntity, NumberEntity):
def __init__(self, hass, coordinator, entry, device, description) -> None: def __init__(self, hass, coordinator, entry, device, description) -> None:
super().__init__(hass, entry, coordinator, device) super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self._device = device
self._data = device.settings[description.key] self._data = device.settings[description.key]
self.entity_description = description self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}" self._attr_unique_id = f"{super().unique_id}{description.key}"

View File

@ -158,8 +158,6 @@ class HonSelectEntity(HonEntity, SelectEntity):
) -> None: ) -> None:
super().__init__(hass, entry, coordinator, device) super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self._device = device
self.entity_description = description self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}" self._attr_unique_id = f"{super().unique_id}{description.key}"

View File

@ -536,8 +536,6 @@ class HonSensorEntity(HonEntity, SensorEntity):
def __init__(self, hass, coordinator, entry, device, description) -> None: def __init__(self, hass, coordinator, entry, device, description) -> None:
super().__init__(hass, entry, coordinator, device) super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self.entity_description = description self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}" self._attr_unique_id = f"{super().unique_id}{description.key}"

View File

@ -387,8 +387,7 @@ class HonSwitchEntity(HonEntity, SwitchEntity):
description: HonSwitchEntityDescription, description: HonSwitchEntityDescription,
) -> None: ) -> None:
super().__init__(hass, entry, coordinator, device) super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self._device = device
self.entity_description = description self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}" self._attr_unique_id = f"{super().unique_id}{description.key}"