mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Fix Dynalite to explicitly check valid device class (#36418)
* changed back to check for class in DEVICE_CLASSES * created a flow that would go through everything as it was blocking the commit and the cv rules prevent an input that would get to that flow * moved DEFAULT_COVER_CLASS from const to cover
This commit is contained in:
parent
99318b7b11
commit
1edbdcb67b
@ -1,7 +1,6 @@
|
|||||||
"""Constants for the Dynalite component."""
|
"""Constants for the Dynalite component."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.cover import DEVICE_CLASS_SHUTTER
|
|
||||||
from homeassistant.const import CONF_ROOM
|
from homeassistant.const import CONF_ROOM
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__package__)
|
LOGGER = logging.getLogger(__package__)
|
||||||
@ -36,7 +35,6 @@ CONF_TILT_TIME = "tilt"
|
|||||||
CONF_TIME_COVER = "time_cover"
|
CONF_TIME_COVER = "time_cover"
|
||||||
|
|
||||||
DEFAULT_CHANNEL_TYPE = "light"
|
DEFAULT_CHANNEL_TYPE = "light"
|
||||||
DEFAULT_COVER_CLASS = DEVICE_CLASS_SHUTTER
|
|
||||||
DEFAULT_NAME = "dynalite"
|
DEFAULT_NAME = "dynalite"
|
||||||
DEFAULT_PORT = 12345
|
DEFAULT_PORT = 12345
|
||||||
DEFAULT_TEMPLATES = {
|
DEFAULT_TEMPLATES = {
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
"""Support for the Dynalite channels as covers."""
|
"""Support for the Dynalite channels as covers."""
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from homeassistant.components.cover import DEVICE_CLASSES, CoverEntity
|
from homeassistant.components.cover import (
|
||||||
|
DEVICE_CLASS_SHUTTER,
|
||||||
|
DEVICE_CLASSES,
|
||||||
|
CoverEntity,
|
||||||
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
|
||||||
from .dynalitebase import DynaliteBase, async_setup_entry_base
|
from .dynalitebase import DynaliteBase, async_setup_entry_base
|
||||||
|
|
||||||
|
DEFAULT_COVER_CLASS = DEVICE_CLASS_SHUTTER
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable
|
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable
|
||||||
@ -31,8 +37,10 @@ class DynaliteCover(DynaliteBase, CoverEntity):
|
|||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of the device."""
|
"""Return the class of the device."""
|
||||||
dev_cls = self._device.device_class
|
dev_cls = self._device.device_class
|
||||||
assert dev_cls in DEVICE_CLASSES
|
ret_val = DEFAULT_COVER_CLASS
|
||||||
return dev_cls
|
if dev_cls in DEVICE_CLASSES:
|
||||||
|
ret_val = dev_cls
|
||||||
|
return ret_val
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_cover_position(self) -> int:
|
def current_cover_position(self) -> int:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user