diff --git a/homeassistant/components/wilight/__init__.py b/homeassistant/components/wilight/__init__.py index 0e08fec2c31..67433772551 100644 --- a/homeassistant/components/wilight/__init__.py +++ b/homeassistant/components/wilight/__init__.py @@ -1,8 +1,6 @@ """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"] diff --git a/homeassistant/components/wilight/config_flow.py b/homeassistant/components/wilight/config_flow.py index c3148a4d045..40643b4372f 100644 --- a/homeassistant/components/wilight/config_flow.py +++ b/homeassistant/components/wilight/config_flow.py @@ -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" diff --git a/homeassistant/components/wilight/cover.py b/homeassistant/components/wilight/cover.py index bbe723b413a..93c9a8c4503 100644 --- a/homeassistant/components/wilight/cover.py +++ b/homeassistant/components/wilight/cover.py @@ -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( diff --git a/homeassistant/components/wilight/fan.py b/homeassistant/components/wilight/fan.py index 948d99ac81d..ece79874ccf 100644 --- a/homeassistant/components/wilight/fan.py +++ b/homeassistant/components/wilight/fan.py @@ -1,7 +1,6 @@ """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) diff --git a/homeassistant/components/wilight/light.py b/homeassistant/components/wilight/light.py index 2f3c9e3c5f2..0c7206be00c 100644 --- a/homeassistant/components/wilight/light.py +++ b/homeassistant/components/wilight/light.py @@ -1,7 +1,6 @@ """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):