fix HA 2025.1 compatibility; cleanup

This commit is contained in:
d.dmitriev
2025-02-16 14:17:34 +05:00
parent 40ae6041ae
commit 3856088e79
9 changed files with 47 additions and 42 deletions

View File

@@ -3,7 +3,6 @@ from __future__ import annotations
import asyncio
import logging
import typing
from datetime import timedelta, datetime
from functools import partial
@@ -13,13 +12,9 @@ import time
from homeassistant.components.light import (
PLATFORM_SCHEMA as LIGHT_SCHEMA,
SUPPORT_BRIGHTNESS,
LightEntity,
SUPPORT_TRANSITION,
SUPPORT_COLOR,
ColorMode,
LightEntityFeature,
# SUPPORT_WHITE_VALUE
LightEntityFeature
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
@@ -124,10 +119,21 @@ async def async_setup_entry(
class MegaLight(MegaOutPort, LightEntity):
@property
def supported_features(self):
return (SUPPORT_BRIGHTNESS if self.dimmer else 0) | (
SUPPORT_TRANSITION if self.dimmer else 0
)
return LightEntityFeature.TRANSITION if self.dimmer else LightEntityFeature(0)
@property
def supported_color_modes(self):
if self.dimmer:
return {ColorMode.BRIGHTNESS}
else:
return {ColorMode.ONOFF}
@property
def color_mode(self):
if self.dimmer:
return ColorMode.BRIGHTNESS
else:
return ColorMode.ONOFF
class MegaRGBW(LightEntity, BaseMegaEntity):
def __init__(self, *args, **kwargs):