mirror of
https://github.com/home-assistant/core.git
synced 2025-07-05 12:27:07 +00:00

* Add probe_plus integration * Changes for quality scale * sentence-casing * Update homeassistant/components/probe_plus/config_flow.py Co-authored-by: Erwin Douna <e.douna@gmail.com> * Update homeassistant/components/probe_plus/config_flow.py Co-authored-by: Erwin Douna <e.douna@gmail.com> * Update tests/components/probe_plus/test_config_flow.py Co-authored-by: Erwin Douna <e.douna@gmail.com> * Update tests/components/probe_plus/test_config_flow.py Co-authored-by: Erwin Douna <e.douna@gmail.com> * remove version from configflow * remove address var from async_step_bluetooth_confirm * move timedelta to SCAN_INTERVAL in coordinator * update tests * updates from review * add voltage device class * remove unused logger * remove names * update tests * Update config flow tests * Update unit tests * Reorder successful tests * Update config entry typing * Remove icons * ruff * Update async_add_entities logic Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * sensor platform formatting --------- Co-authored-by: Erwin Douna <e.douna@gmail.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
"""Probe Plus base entity type."""
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from pyprobeplus import ProbePlusDevice
|
|
|
|
from homeassistant.helpers.device_registry import (
|
|
CONNECTION_BLUETOOTH,
|
|
DeviceInfo,
|
|
format_mac,
|
|
)
|
|
from homeassistant.helpers.entity import EntityDescription
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import ProbePlusDataUpdateCoordinator
|
|
|
|
|
|
@dataclass
|
|
class ProbePlusEntity(CoordinatorEntity[ProbePlusDataUpdateCoordinator]):
|
|
"""Base class for Probe Plus entities."""
|
|
|
|
_attr_has_entity_name = True
|
|
|
|
def __init__(
|
|
self,
|
|
coordinator: ProbePlusDataUpdateCoordinator,
|
|
entity_description: EntityDescription,
|
|
) -> None:
|
|
"""Initialize the entity."""
|
|
super().__init__(coordinator)
|
|
self.entity_description = entity_description
|
|
|
|
# Set the unique ID for the entity
|
|
self._attr_unique_id = (
|
|
f"{format_mac(coordinator.device.mac)}_{entity_description.key}"
|
|
)
|
|
self._attr_device_info = DeviceInfo(
|
|
identifiers={(DOMAIN, format_mac(coordinator.device.mac))},
|
|
name=coordinator.device.name,
|
|
manufacturer="Probe Plus",
|
|
suggested_area="Kitchen",
|
|
connections={(CONNECTION_BLUETOOTH, coordinator.device.mac)},
|
|
)
|
|
|
|
@property
|
|
def available(self) -> bool:
|
|
"""Return True if the entity is available."""
|
|
return super().available and self.coordinator.device.connected
|
|
|
|
@property
|
|
def device(self) -> ProbePlusDevice:
|
|
"""Return the device associated with this entity."""
|
|
return self.coordinator.device
|