Move and rename crownstone base entity to separate module (#126034)
This commit is contained in:
parent
8370a55263
commit
e85ab067bd
2 changed files with 6 additions and 6 deletions
|
@ -10,7 +10,7 @@ from homeassistant.helpers.entity import Entity
|
|||
from .const import CROWNSTONE_INCLUDE_TYPES, DOMAIN
|
||||
|
||||
|
||||
class CrownstoneBaseEntity(Entity):
|
||||
class CrownstoneEntity(Entity):
|
||||
"""Base entity class for Crownstone devices."""
|
||||
|
||||
_attr_should_poll = False
|
|
@ -24,7 +24,7 @@ from .const import (
|
|||
SIG_CROWNSTONE_STATE_UPDATE,
|
||||
SIG_UART_STATE_CHANGE,
|
||||
)
|
||||
from .devices import CrownstoneBaseEntity
|
||||
from .entity import CrownstoneEntity
|
||||
from .helpers import map_from_to
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -39,7 +39,7 @@ async def async_setup_entry(
|
|||
"""Set up crownstones from a config entry."""
|
||||
manager: CrownstoneEntryManager = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
entities: list[CrownstoneEntity] = []
|
||||
entities: list[CrownstoneLightEntity] = []
|
||||
|
||||
# Add Crownstone entities that support switching/dimming
|
||||
for sphere in manager.cloud.cloud_data:
|
||||
|
@ -47,10 +47,10 @@ async def async_setup_entry(
|
|||
if crownstone.type in CROWNSTONE_INCLUDE_TYPES:
|
||||
# Crownstone can communicate with Crownstone USB
|
||||
if manager.uart and sphere.cloud_id == manager.usb_sphere_id:
|
||||
entities.append(CrownstoneEntity(crownstone, manager.uart))
|
||||
entities.append(CrownstoneLightEntity(crownstone, manager.uart))
|
||||
# Crownstone can't communicate with Crownstone USB
|
||||
else:
|
||||
entities.append(CrownstoneEntity(crownstone))
|
||||
entities.append(CrownstoneLightEntity(crownstone))
|
||||
|
||||
async_add_entities(entities)
|
||||
|
||||
|
@ -65,7 +65,7 @@ def hass_to_crownstone_state(value: int) -> int:
|
|||
return map_from_to(value, 0, 255, 0, 100)
|
||||
|
||||
|
||||
class CrownstoneEntity(CrownstoneBaseEntity, LightEntity):
|
||||
class CrownstoneLightEntity(CrownstoneEntity, LightEntity):
|
||||
"""Representation of a crownstone.
|
||||
|
||||
Light platform is used to support dimming.
|
||||
|
|
Loading…
Add table
Reference in a new issue