Skip to content
Snippets Groups Projects
Unverified Commit 3ffa42e5 authored by Leonardo Figueiro's avatar Leonardo Figueiro Committed by GitHub
Browse files

Update WiLight Cover Fan Light (#46366)

parent 56adc9da
No related branches found
No related tags found
No related merge requests found
"""The WiLight integration."""
import asyncio
from pywilight.const import DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady
......@@ -10,6 +8,8 @@ from homeassistant.helpers.entity import Entity
from .parent_device import WiLightParent
DOMAIN = "wilight"
# List the platforms that you want to support.
PLATFORMS = ["cover", "fan", "light"]
......
......@@ -7,7 +7,7 @@ from homeassistant.components import ssdp
from homeassistant.config_entries import CONN_CLASS_LOCAL_PUSH, ConfigFlow
from homeassistant.const import CONF_HOST
DOMAIN = "wilight"
from . import DOMAIN # pylint: disable=unused-import
CONF_SERIAL_NUMBER = "serial_number"
CONF_MODEL_NAME = "model_name"
......
......@@ -2,7 +2,6 @@
from pywilight.const import (
COVER_V1,
DOMAIN,
ITEM_COVER,
WL_CLOSE,
WL_CLOSING,
......@@ -16,7 +15,7 @@ from homeassistant.components.cover import ATTR_POSITION, CoverEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from . import WiLightDevice
from . import DOMAIN, WiLightDevice
async def async_setup_entry(
......
"""Support for WiLight Fan."""
from pywilight.const import (
DOMAIN,
FAN_V1,
ITEM_FAN,
WL_DIRECTION_FORWARD,
......@@ -25,7 +24,7 @@ from homeassistant.util.percentage import (
percentage_to_ordered_list_item,
)
from . import WiLightDevice
from . import DOMAIN, WiLightDevice
ORDERED_NAMED_FAN_SPEEDS = [WL_SPEED_LOW, WL_SPEED_MEDIUM, WL_SPEED_HIGH]
......@@ -80,6 +79,9 @@ class WiLightFan(WiLightDevice, FanEntity):
@property
def percentage(self) -> str:
"""Return the current speed percentage."""
if "direction" in self._status:
if self._status["direction"] == WL_DIRECTION_OFF:
return 0
wl_speed = self._status.get("speed")
if wl_speed is None:
return None
......@@ -111,6 +113,9 @@ class WiLightFan(WiLightDevice, FanEntity):
if percentage == 0:
await self._client.set_fan_direction(self._index, WL_DIRECTION_OFF)
return
if "direction" in self._status:
if self._status["direction"] == WL_DIRECTION_OFF:
await self._client.set_fan_direction(self._index, self._direction)
wl_speed = percentage_to_ordered_list_item(ORDERED_NAMED_FAN_SPEEDS, percentage)
await self._client.set_fan_speed(self._index, wl_speed)
......
"""Support for WiLight lights."""
from pywilight.const import (
DOMAIN,
ITEM_LIGHT,
LIGHT_COLOR,
LIGHT_DIMMER,
......@@ -19,7 +18,7 @@ from homeassistant.components.light import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from . import WiLightDevice
from . import DOMAIN, WiLightDevice
def entities_from_discovered_wilight(hass, api_device):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment