|
36 | 36 | from homeassistant.util.color import value_to_brightness
|
37 | 37 |
|
38 | 38 | from . import async_migrate_entry
|
39 |
| -from .const import DOMAIN, TYPE_DIMMABLE, TYPE_ONOFF |
| 39 | +from .const import DOMAIN, TYPE_ONOFF |
40 | 40 | from .util import get_light_type
|
41 | 41 |
|
42 | 42 | _LOGGER = logging.getLogger(__name__)
|
@@ -227,9 +227,10 @@ async def async_turn_on(self, **kwargs: Any) -> None:
|
227 | 227 | )
|
228 | 228 |
|
229 | 229 | _LOGGER.debug(
|
230 |
| - "Service `%s` called for `%s` with `%s`", |
| 230 | + "Service `%s` called for `%s` (%s) with `%s`", |
231 | 231 | service,
|
232 | 232 | entity.entity_id,
|
| 233 | + entity.type, |
233 | 234 | entity_data,
|
234 | 235 | )
|
235 | 236 |
|
@@ -466,43 +467,10 @@ def __init__(
|
466 | 467 | def type(self) -> str | None:
|
467 | 468 | """The entity type."""
|
468 | 469 |
|
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 |
506 | 474 |
|
507 | 475 | def translate_brightness(self, brightness: int) -> int:
|
508 | 476 | """Calculate the entitiy brightness for the give Lightener brightness level."""
|
|
0 commit comments