mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00

* Create a new homeassistan integration for microBees * black --fast homeassistant tests * Switch platform * rename folder * rename folder * Update owners * aiohttp removed in favor of hass * Update config_flow.py * Update __init__.py * Update const.py * Update manifest.json * Update string.json * Update servicesMicrobees.py * Update switch.py * Update __init__.py * Update it.json * Create a new homeassistan integration for microBees * black --fast homeassistant tests * Switch platform * rename folder * rename folder * Update owners * aiohttp removed in favor of hass * Update config_flow.py * Update __init__.py * Update const.py * Update manifest.json * Update string.json * Update servicesMicrobees.py * Update switch.py * Update __init__.py * Update it.json * fixes review * fixes review * fixes review * pyproject.toml * Update package_constraints.txt * fixes review * bug fixes * bug fixes * delete microbees connector * add other productID in switch * added coordinator and enanchments * added coordinator and enanchments * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * add test * add test * add test * add test * requested commit * requested commit * requested commit * requested commit * reverting .strict-typing and added microbees to .coveragerc * remove log * remove log * remove log * remove log * add test for microbeesExeption and Exeption * add test for microbeesExeption and Exeption * add test for microbeesException and Exception * add test for microbeesException and Exception * add test for microbeesException and Exception --------- Co-authored-by: FedDam <noceracity@gmail.com> Co-authored-by: Federico D'Amico <48856240+FedDam@users.noreply.github.com>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""Base entity for microBees."""
|
|
|
|
from microBeesPy.microbees import Actuator, Bee
|
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import MicroBeesUpdateCoordinator
|
|
|
|
|
|
class MicroBeesEntity(CoordinatorEntity[MicroBeesUpdateCoordinator]):
|
|
"""Base class for microBees entities."""
|
|
|
|
_attr_has_entity_name = True
|
|
|
|
def __init__(
|
|
self,
|
|
coordinator: MicroBeesUpdateCoordinator,
|
|
bee_id: int,
|
|
actuator_id: int,
|
|
) -> None:
|
|
"""Initialize the microBees entity."""
|
|
super().__init__(coordinator)
|
|
self.bee_id = bee_id
|
|
self.actuator_id = actuator_id
|
|
self._attr_unique_id = f"{bee_id}_{actuator_id}"
|
|
self._attr_device_info = DeviceInfo(
|
|
identifiers={(DOMAIN, str(bee_id))},
|
|
manufacturer="microBees",
|
|
name=self.bee.name,
|
|
model=self.bee.prototypeName,
|
|
)
|
|
|
|
@property
|
|
def available(self) -> bool:
|
|
"""Status of the bee."""
|
|
return (
|
|
super().available
|
|
and self.bee_id in self.coordinator.data.bees
|
|
and self.bee.active
|
|
)
|
|
|
|
@property
|
|
def bee(self) -> Bee:
|
|
"""Return the bee."""
|
|
return self.coordinator.data.bees[self.bee_id]
|
|
|
|
@property
|
|
def actuator(self) -> Actuator:
|
|
"""Return the actuator."""
|
|
return self.coordinator.data.actuators[self.actuator_id]
|