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
2 changed files with 11 additions and 5 deletions
|
@ -1,7 +1,6 @@
|
|||
"""Constants for the Dynalite component."""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.cover import DEVICE_CLASS_SHUTTER
|
||||
from homeassistant.const import CONF_ROOM
|
||||
|
||||
LOGGER = logging.getLogger(__package__)
|
||||
|
@ -36,7 +35,6 @@ CONF_TILT_TIME = "tilt"
|
|||
CONF_TIME_COVER = "time_cover"
|
||||
|
||||
DEFAULT_CHANNEL_TYPE = "light"
|
||||
DEFAULT_COVER_CLASS = DEVICE_CLASS_SHUTTER
|
||||
DEFAULT_NAME = "dynalite"
|
||||
DEFAULT_PORT = 12345
|
||||
DEFAULT_TEMPLATES = {
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
"""Support for the Dynalite channels as covers."""
|
||||
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.core import HomeAssistant, callback
|
||||
|
||||
from .dynalitebase import DynaliteBase, async_setup_entry_base
|
||||
|
||||
DEFAULT_COVER_CLASS = DEVICE_CLASS_SHUTTER
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable
|
||||
|
@ -31,8 +37,10 @@ class DynaliteCover(DynaliteBase, CoverEntity):
|
|||
def device_class(self) -> str:
|
||||
"""Return the class of the device."""
|
||||
dev_cls = self._device.device_class
|
||||
assert dev_cls in DEVICE_CLASSES
|
||||
return dev_cls
|
||||
ret_val = DEFAULT_COVER_CLASS
|
||||
if dev_cls in DEVICE_CLASSES:
|
||||
ret_val = dev_cls
|
||||
return ret_val
|
||||
|
||||
@property
|
||||
def current_cover_position(self) -> int:
|
||||
|
|
Loading…
Add table
Reference in a new issue