Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non preset fan #126

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading