Skip to content

Commit

Permalink
Fix non preset fan (#126)
Browse files Browse the repository at this point in the history
Fix issue on fan attributes

 * Update aiohubspace to identify BF1112
 * Fix an issue where fans would lookup features it didnt support
 * Fix an issue where actions + fans could cause an UHE

Sem-Ver: bugfix
  • Loading branch information
Expl0dingBanana authored Jan 13, 2025
1 parent 7070478 commit 3b7be4a
Show file tree
Hide file tree
Showing 5 changed files with 1,372 additions and 16 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ are as follows:

## Changelog

* 4.0.1

* Fixed an issue where fans could cause an UHE if they did not support
some functionality

* 4.0.0

* BREAK: Sensors have new names. Old sensors marked as unavailable can be removed.
Expand Down
32 changes: 23 additions & 9 deletions custom_components/hubspace/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ def __init__(
) -> None:
super().__init__(bridge, controller, resource)
self._supported_features: FanEntityFeature = FanEntityFeature(0)
if self.device.supports_on:
if self.resource.supports_on:
self._supported_features |= FanEntityFeature.TURN_ON
self._supported_features |= FanEntityFeature.TURN_OFF
if self.device.supports_direction:
if self.resource.supports_direction:
self._supported_features |= FanEntityFeature.DIRECTION
if self.device.supports_speed:
if self.resource.supports_speed:
self._supported_features |= FanEntityFeature.SET_SPEED
if self.device.supports_presets:
if self.resource.supports_presets:
self._supported_features |= FanEntityFeature.PRESET_MODE

@property
Expand All @@ -44,7 +44,10 @@ def supported_features(self):
@property
def is_on(self) -> bool | None:
"""Return true if fan is spinning"""
return self.resource.is_on
if self._supported_features & FanEntityFeature.TURN_ON:
return self.resource.is_on
else:
return None

@property
def current_direction(self):
Expand All @@ -61,22 +64,33 @@ def oscillating(self):

@property
def percentage(self):
return self.resource.speed.speed
if self.supported_features & FanEntityFeature.SET_SPEED:
return self.resource.speed.speed
return None

@property
def preset_mode(self):
if self.resource.preset.enabled:
if (
self.supported_features & FanEntityFeature.PRESET_MODE
and self.resource.preset
):
return "breeze"
else:
return None

@property
def preset_modes(self):
return list(PRESET_HS_TO_HA.values())
if self.supported_features & FanEntityFeature.PRESET_MODE:
return list(PRESET_HS_TO_HA.values())
else:
return None

@property
def speed_count(self):
return len(self.resource.speed.speeds)
if self.supported_features & FanEntityFeature.SET_SPEED:
return len(self.resource.speed.speeds)
else:
return None

@update_decorator
async def async_turn_on(
Expand Down
4 changes: 2 additions & 2 deletions custom_components/hubspace/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/jdeath/Hubspace-Homeassistant/issues",
"loggers": ["aiohubspace"],
"requirements": ["aiohubspace==0.5.1", "aiofiles==24.1.0"],
"version": "4.0.0"
"requirements": ["aiohubspace==0.6.2", "aiofiles==24.1.0"],
"version": "4.0.1"
}
Loading

0 comments on commit 3b7be4a

Please sign in to comment.