Some minor cleanups in WLED (#117453)
This commit is contained in:
parent
0df9006bf7
commit
faff5f4738
10 changed files with 13 additions and 16 deletions
|
@ -12,7 +12,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
|
||||
from . import WLEDConfigEntry
|
||||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
from .models import WLEDEntity
|
||||
from .entity import WLEDEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
@ -21,10 +21,9 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up a WLED binary sensor based on a config entry."""
|
||||
coordinator = entry.runtime_data
|
||||
async_add_entities(
|
||||
[
|
||||
WLEDUpdateBinarySensor(coordinator),
|
||||
WLEDUpdateBinarySensor(entry.runtime_data),
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
|
||||
from . import WLEDConfigEntry
|
||||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
from .entity import WLEDEntity
|
||||
from .helpers import wled_exception_handler
|
||||
from .models import WLEDEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
@ -19,8 +19,7 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up WLED button based on a config entry."""
|
||||
coordinator = entry.runtime_data
|
||||
async_add_entities([WLEDRestartButton(coordinator)])
|
||||
async_add_entities([WLEDRestartButton(entry.runtime_data)])
|
||||
|
||||
|
||||
class WLEDRestartButton(WLEDEntity, ButtonEntity):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
"""Models for WLED."""
|
||||
"""Base entity for WLED."""
|
||||
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
@ -9,7 +9,7 @@ from wled import WLEDConnectionError, WLEDError
|
|||
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .models import WLEDEntity
|
||||
from .entity import WLEDEntity
|
||||
|
||||
_WLEDEntityT = TypeVar("_WLEDEntityT", bound=WLEDEntity)
|
||||
_P = ParamSpec("_P")
|
||||
|
|
|
@ -21,8 +21,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from . import WLEDConfigEntry
|
||||
from .const import ATTR_COLOR_PRIMARY, ATTR_ON, ATTR_SEGMENT_ID
|
||||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
from .entity import WLEDEntity
|
||||
from .helpers import wled_exception_handler
|
||||
from .models import WLEDEntity
|
||||
|
||||
PARALLEL_UPDATES = 1
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from . import WLEDConfigEntry
|
||||
from .const import ATTR_INTENSITY, ATTR_SPEED
|
||||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
from .entity import WLEDEntity
|
||||
from .helpers import wled_exception_handler
|
||||
from .models import WLEDEntity
|
||||
|
||||
PARALLEL_UPDATES = 1
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
|
||||
from . import WLEDConfigEntry
|
||||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
from .entity import WLEDEntity
|
||||
from .helpers import wled_exception_handler
|
||||
from .models import WLEDEntity
|
||||
|
||||
PARALLEL_UPDATES = 1
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ from homeassistant.util.dt import utcnow
|
|||
|
||||
from . import WLEDConfigEntry
|
||||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
from .models import WLEDEntity
|
||||
from .entity import WLEDEntity
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
|
|
|
@ -13,8 +13,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from . import WLEDConfigEntry
|
||||
from .const import ATTR_DURATION, ATTR_FADE, ATTR_TARGET_BRIGHTNESS, ATTR_UDP_PORT
|
||||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
from .entity import WLEDEntity
|
||||
from .helpers import wled_exception_handler
|
||||
from .models import WLEDEntity
|
||||
|
||||
PARALLEL_UPDATES = 1
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
|
||||
from . import WLEDConfigEntry
|
||||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
from .entity import WLEDEntity
|
||||
from .helpers import wled_exception_handler
|
||||
from .models import WLEDEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
@ -24,8 +24,7 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up WLED update based on a config entry."""
|
||||
coordinator = entry.runtime_data
|
||||
async_add_entities([WLEDUpdateEntity(coordinator)])
|
||||
async_add_entities([WLEDUpdateEntity(entry.runtime_data)])
|
||||
|
||||
|
||||
class WLEDUpdateEntity(WLEDEntity, UpdateEntity):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue