mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add permobil entity (#111761)
* add permobil entity * small fixes * remove sensor init
This commit is contained in:
parent
e886bc8939
commit
fb10ef9ac0
@ -983,6 +983,7 @@ omit =
|
|||||||
homeassistant/components/pencom/switch.py
|
homeassistant/components/pencom/switch.py
|
||||||
homeassistant/components/permobil/__init__.py
|
homeassistant/components/permobil/__init__.py
|
||||||
homeassistant/components/permobil/coordinator.py
|
homeassistant/components/permobil/coordinator.py
|
||||||
|
homeassistant/components/permobil/entity.py
|
||||||
homeassistant/components/permobil/sensor.py
|
homeassistant/components/permobil/sensor.py
|
||||||
homeassistant/components/philips_js/__init__.py
|
homeassistant/components/philips_js/__init__.py
|
||||||
homeassistant/components/philips_js/light.py
|
homeassistant/components/philips_js/light.py
|
||||||
|
29
homeassistant/components/permobil/entity.py
Normal file
29
homeassistant/components/permobil/entity.py
Normal file
@ -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.const import PERCENTAGE, UnitOfEnergy, UnitOfLength, UnitOfTime
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
||||||
|
|
||||||
from .const import BATTERY_ASSUMED_VOLTAGE, DOMAIN, KM, MILES
|
from .const import BATTERY_ASSUMED_VOLTAGE, DOMAIN, KM, MILES
|
||||||
from .coordinator import MyPermobilCoordinator
|
from .coordinator import MyPermobilCoordinator
|
||||||
|
from .entity import PermobilEntity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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.
|
"""Representation of a Sensor.
|
||||||
|
|
||||||
This implements the common functions of all sensors.
|
This implements the common functions of all sensors.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
|
||||||
_attr_suggested_display_precision = 0
|
_attr_suggested_display_precision = 0
|
||||||
entity_description: PermobilSensorEntityDescription
|
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
|
@property
|
||||||
def native_unit_of_measurement(self) -> str | None:
|
def native_unit_of_measurement(self) -> str | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user