Skip to content

Commit

Permalink
Fix climate not available #52
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed May 18, 2023
1 parent 29238d3 commit d963086
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 25 deletions.
2 changes: 0 additions & 2 deletions custom_components/hon/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ class HonBinarySensorEntity(HonEntity, BinarySensorEntity):
def __init__(self, hass, coordinator, entry, device, description) -> None:
super().__init__(hass, entry, coordinator, device)

self._coordinator = coordinator

self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}"

Expand Down
10 changes: 4 additions & 6 deletions custom_components/hon/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ def __init__(
) -> None:
super().__init__(hass, entry, coordinator, device)

self._coordinator = coordinator
self._device = device
self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}"

Expand All @@ -77,9 +75,7 @@ def available(self) -> bool:
class HonFeatureRequestButton(HonEntity, ButtonEntity):
def __init__(self, hass, coordinator, entry, device: HonAppliance) -> None:
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_icon = "mdi:information"
self._attr_name = "Show Device Info"
Expand All @@ -88,7 +84,9 @@ def __init__(self, hass, coordinator, entry, device: HonAppliance) -> None:

async def async_press(self) -> None:
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"
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 "))
12 changes: 5 additions & 7 deletions custom_components/hon/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
for description in descriptions:
if description.key not in list(device.commands):
continue
appliances.extend(
[HonClimateEntity(hass, coordinator, entry, device, description)]
appliances.append(
HonClimateEntity(hass, coordinator, entry, device, description)
)
async_add_entities(appliances)

Expand All @@ -67,10 +67,7 @@ def __init__(
self, hass, coordinator, entry, device: HonAppliance, description
) -> None:
super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self._device = device
self.entity_description = description
self._hass = hass
self._attr_unique_id = f"{super().unique_id}climate"

self._attr_temperature_unit = TEMP_CELSIUS
Expand All @@ -96,7 +93,7 @@ def __init__(
| ClimateEntityFeature.SWING_MODE
)

self._handle_coordinator_update()
self._handle_coordinator_update(update=False)

async def async_set_hvac_mode(self, hvac_mode):
if hvac_mode == HVACMode.OFF:
Expand Down Expand Up @@ -161,4 +158,5 @@ def _handle_coordinator_update(self, update=True) -> None:
self._attr_swing_mode = SWING_VERTICAL
else:
self._attr_swing_mode = SWING_OFF
self.async_write_ha_state()
if update:
self.async_write_ha_state()
1 change: 1 addition & 0 deletions custom_components/hon/hon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, hass, entry, coordinator, device: HonAppliance) -> None:

self._hon = hass.data[DOMAIN][entry.unique_id]
self._hass = hass
self._coordinator = coordinator
self._device = device

self._attr_unique_id = self._device.unique_id
Expand Down
4 changes: 2 additions & 2 deletions custom_components/hon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"documentation": "https://github.com/Andre0512/hon/",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Andre0512/hon/issues",
"requirements": ["pyhOn==0.10.7"],
"version": "0.8.0-beta.3"
"requirements": ["pyhOn==0.10.9"],
"version": "0.8.0-beta.4"
}
2 changes: 0 additions & 2 deletions custom_components/hon/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ class HonNumberEntity(HonEntity, NumberEntity):
def __init__(self, hass, coordinator, entry, device, description) -> None:
super().__init__(hass, entry, coordinator, device)

self._coordinator = coordinator
self._device = device
self._data = device.settings[description.key]
self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}"
Expand Down
2 changes: 0 additions & 2 deletions custom_components/hon/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ def __init__(
) -> None:
super().__init__(hass, entry, coordinator, device)

self._coordinator = coordinator
self._device = device
self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}"

Expand Down
2 changes: 0 additions & 2 deletions custom_components/hon/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,6 @@ class HonSensorEntity(HonEntity, SensorEntity):
def __init__(self, hass, coordinator, entry, device, description) -> None:
super().__init__(hass, entry, coordinator, device)

self._coordinator = coordinator

self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}"

Expand Down
3 changes: 1 addition & 2 deletions custom_components/hon/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ def __init__(
description: HonSwitchEntityDescription,
) -> None:
super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self._device = device

self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}"

Expand Down

0 comments on commit d963086

Please sign in to comment.