Add permobil entity (#111761)
* add permobil entity * small fixes * remove sensor initpull/111765/head
parent
e886bc8939
commit
fb10ef9ac0
|
@ -983,6 +983,7 @@ omit =
|
|||
homeassistant/components/pencom/switch.py
|
||||
homeassistant/components/permobil/__init__.py
|
||||
homeassistant/components/permobil/coordinator.py
|
||||
homeassistant/components/permobil/entity.py
|
||||
homeassistant/components/permobil/sensor.py
|
||||
homeassistant/components/philips_js/__init__.py
|
||||
homeassistant/components/philips_js/light.py
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
"""PermobilEntity class."""
|
||||
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import MyPermobilCoordinator
|
||||
|
||||
|
||||
class PermobilEntity(CoordinatorEntity[MyPermobilCoordinator]):
|
||||
"""Representation of a permobil Entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: MyPermobilCoordinator,
|
||||
description: EntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the entity."""
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
self._attr_unique_id = f"{coordinator.p_api.email}_{description.key}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, coordinator.p_api.email)},
|
||||
manufacturer="Permobil",
|
||||
name="Permobil Wheelchair",
|
||||
)
|
|
@ -32,10 +32,10 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.const import PERCENTAGE, UnitOfEnergy, UnitOfLength, UnitOfTime
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import BATTERY_ASSUMED_VOLTAGE, DOMAIN, KM, MILES
|
||||
from .coordinator import MyPermobilCoordinator
|
||||
from .entity import PermobilEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -202,28 +202,14 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class PermobilSensor(CoordinatorEntity[MyPermobilCoordinator], SensorEntity):
|
||||
class PermobilSensor(PermobilEntity, SensorEntity):
|
||||
"""Representation of a Sensor.
|
||||
|
||||
This implements the common functions of all sensors.
|
||||
"""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_suggested_display_precision = 0
|
||||
entity_description: PermobilSensorEntityDescription
|
||||
_available = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: MyPermobilCoordinator,
|
||||
description: PermobilSensorEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(coordinator=coordinator)
|
||||
self.entity_description = description
|
||||
self._attr_unique_id = (
|
||||
f"{coordinator.p_api.email}_{self.entity_description.key}"
|
||||
)
|
||||
|
||||
@property
|
||||
def native_unit_of_measurement(self) -> str | None:
|
||||
|
|
Loading…
Reference in New Issue