Skip to content

Commit 26cf2a2

Browse files
committed
Removed the old type check logic
1 parent 365af14 commit 26cf2a2

File tree

1 file changed

+7
-39
lines changed

1 file changed

+7
-39
lines changed

custom_components/lightener/light.py

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from homeassistant.util.color import value_to_brightness
3737

3838
from . import async_migrate_entry
39-
from .const import DOMAIN, TYPE_DIMMABLE, TYPE_ONOFF
39+
from .const import DOMAIN, TYPE_ONOFF
4040
from .util import get_light_type
4141

4242
_LOGGER = logging.getLogger(__name__)
@@ -227,9 +227,10 @@ async def async_turn_on(self, **kwargs: Any) -> None:
227227
)
228228

229229
_LOGGER.debug(
230-
"Service `%s` called for `%s` with `%s`",
230+
"Service `%s` called for `%s` (%s) with `%s`",
231231
service,
232232
entity.entity_id,
233+
entity.type,
233234
entity_data,
234235
)
235236

@@ -466,43 +467,10 @@ def __init__(
466467
def type(self) -> str | None:
467468
"""The entity type."""
468469

469-
# TODO: Remove old_type logic before going out of beta.
470-
471-
if self._type is None:
472-
old_type = None
473-
474-
state = self.hass.states.get(self.entity_id)
475-
476-
# It may take some time between the initialization of this class and the effective availability of the entity.
477-
if state is not None:
478-
supported_color_modes = state.attributes.get("supported_color_modes")
479-
old_type = (
480-
TYPE_ONOFF
481-
if supported_color_modes
482-
and ColorMode.ONOFF in supported_color_modes
483-
and len(supported_color_modes) == 1
484-
else TYPE_DIMMABLE
485-
)
486-
487-
the_type = None
488-
489-
try:
490-
the_type = get_light_type(self.hass, self.entity_id)
491-
except HomeAssistantError:
492-
supported_color_modes = None
493-
_LOGGER.warning("Entity `%s` was not found", self.entity_id)
494-
495-
_LOGGER.debug(
496-
"Entity `%s` type is `%s` (old type: `%s`, supported color modes: `%s`)",
497-
self.entity_id,
498-
the_type,
499-
old_type,
500-
supported_color_modes,
501-
)
502-
503-
self._type = the_type
504-
505-
return self._type
470+
try:
471+
return get_light_type(self.hass, self.entity_id)
472+
except HomeAssistantError:
473+
return None
506474

507475
def translate_brightness(self, brightness: int) -> int:
508476
"""Calculate the entitiy brightness for the give Lightener brightness level."""

0 commit comments

Comments
 (0)