mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Move velux imports at top-level (#29085)
This commit is contained in:
parent
12c396fb19
commit
29e2201446
@ -1,12 +1,12 @@
|
|||||||
"""Support for VELUX KLF 200 devices."""
|
"""Support for VELUX KLF 200 devices."""
|
||||||
import logging
|
import logging
|
||||||
import voluptuous as vol
|
|
||||||
from pyvlx import PyVLX
|
|
||||||
from pyvlx import PyVLXException
|
|
||||||
|
|
||||||
|
from pyvlx import PyVLX, PyVLXException
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP
|
|
||||||
|
|
||||||
DOMAIN = "velux"
|
DOMAIN = "velux"
|
||||||
DATA_VELUX = "data_velux"
|
DATA_VELUX = "data_velux"
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
"""Support for Velux covers."""
|
"""Support for Velux covers."""
|
||||||
|
from pyvlx import OpeningDevice, Position
|
||||||
|
from pyvlx.opening_device import Awning, Blind, RollerShutter, Window
|
||||||
|
|
||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
SUPPORT_CLOSE,
|
SUPPORT_CLOSE,
|
||||||
@ -16,7 +19,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
"""Set up cover(s) for Velux platform."""
|
"""Set up cover(s) for Velux platform."""
|
||||||
entities = []
|
entities = []
|
||||||
for node in hass.data[DATA_VELUX].pyvlx.nodes:
|
for node in hass.data[DATA_VELUX].pyvlx.nodes:
|
||||||
from pyvlx import OpeningDevice
|
|
||||||
|
|
||||||
if isinstance(node, OpeningDevice):
|
if isinstance(node, OpeningDevice):
|
||||||
entities.append(VeluxCover(node))
|
entities.append(VeluxCover(node))
|
||||||
@ -67,8 +69,6 @@ class VeluxCover(CoverDevice):
|
|||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Define this cover as either window/blind/awning/shutter."""
|
"""Define this cover as either window/blind/awning/shutter."""
|
||||||
from pyvlx.opening_device import Blind, RollerShutter, Window, Awning
|
|
||||||
|
|
||||||
if isinstance(self.node, Window):
|
if isinstance(self.node, Window):
|
||||||
return "window"
|
return "window"
|
||||||
if isinstance(self.node, Blind):
|
if isinstance(self.node, Blind):
|
||||||
@ -96,7 +96,6 @@ class VeluxCover(CoverDevice):
|
|||||||
"""Move the cover to a specific position."""
|
"""Move the cover to a specific position."""
|
||||||
if ATTR_POSITION in kwargs:
|
if ATTR_POSITION in kwargs:
|
||||||
position_percent = 100 - kwargs[ATTR_POSITION]
|
position_percent = 100 - kwargs[ATTR_POSITION]
|
||||||
from pyvlx import Position
|
|
||||||
|
|
||||||
await self.node.set_position(
|
await self.node.set_position(
|
||||||
Position(position_percent=position_percent), wait_for_completion=False
|
Position(position_percent=position_percent), wait_for_completion=False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user