Skip to content

Commit

Permalink
Add optional disabling Fan presets #882
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Feb 14, 2024
1 parent fe64e09 commit f59db3e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions custom_components/sonoff/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from .core.const import DOMAIN
from .core.entity import XEntity
from .core.ewelink import SIGNAL_ADD_ENTITIES, XRegistry
from .core.ewelink import SIGNAL_ADD_ENTITIES, XRegistry, XDevice

PARALLEL_UPDATES = 0 # fix entity_platform parallel_updates Semaphore

Expand All @@ -28,9 +28,15 @@ async def async_setup_entry(hass, config_entry, add_entities):
class XFan(XEntity, FanEntity):
params = {"switches", "fan"}
_attr_speed_count = 3
_attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE
_attr_supported_features = FanEntityFeature.SET_SPEED
_attr_preset_modes = [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]

def __init__(self, ewelink: XRegistry, device: XDevice) -> None:
super().__init__(ewelink, device)

if device.get("preset_mode", True):
self._attr_supported_features |= FanEntityFeature.PRESET_MODE

def set_state(self, params: dict):
mode = None
# Cloud sends switches, LAN sends fan/speed
Expand Down

0 comments on commit f59db3e

Please sign in to comment.