mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add entity categories. (#63165)
This commit is contained in:
parent
93758e2e6c
commit
0a0ca233c5
@ -9,7 +9,7 @@ from homeassistant.components.select import SelectEntity
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import DEVICE_DEFAULT_NAME
|
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
@ -54,6 +54,8 @@ async def async_setup_entry(
|
|||||||
class PlenticoreDataSelect(CoordinatorEntity, SelectEntity, ABC):
|
class PlenticoreDataSelect(CoordinatorEntity, SelectEntity, ABC):
|
||||||
"""Representation of a Plenticore Select."""
|
"""Representation of a Plenticore Select."""
|
||||||
|
|
||||||
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator,
|
coordinator,
|
||||||
|
@ -10,7 +10,7 @@ from homeassistant.components.sensor import ATTR_STATE_CLASS, SensorEntity
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ICON, ATTR_UNIT_OF_MEASUREMENT
|
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ICON, ATTR_UNIT_OF_MEASUREMENT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -65,6 +65,7 @@ async def async_setup_entry(
|
|||||||
sensor_data,
|
sensor_data,
|
||||||
PlenticoreDataFormatter.get_method(fmt),
|
PlenticoreDataFormatter.get_method(fmt),
|
||||||
plenticore.device_info,
|
plenticore.device_info,
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ async def async_setup_entry(
|
|||||||
sensor_data,
|
sensor_data,
|
||||||
PlenticoreDataFormatter.get_method(fmt),
|
PlenticoreDataFormatter.get_method(fmt),
|
||||||
plenticore.device_info,
|
plenticore.device_info,
|
||||||
|
EntityCategory.DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -116,6 +118,7 @@ class PlenticoreDataSensor(CoordinatorEntity, SensorEntity):
|
|||||||
sensor_data: dict[str, Any],
|
sensor_data: dict[str, Any],
|
||||||
formatter: Callable[[str], Any],
|
formatter: Callable[[str], Any],
|
||||||
device_info: DeviceInfo,
|
device_info: DeviceInfo,
|
||||||
|
entity_category: EntityCategory,
|
||||||
):
|
):
|
||||||
"""Create a new Sensor Entity for Plenticore process data."""
|
"""Create a new Sensor Entity for Plenticore process data."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
@ -130,6 +133,8 @@ class PlenticoreDataSensor(CoordinatorEntity, SensorEntity):
|
|||||||
|
|
||||||
self._device_info = device_info
|
self._device_info = device_info
|
||||||
|
|
||||||
|
self._attr_entity_category = entity_category
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return if entity is available."""
|
"""Return if entity is available."""
|
||||||
|
@ -8,7 +8,7 @@ import logging
|
|||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
@ -70,6 +70,8 @@ async def async_setup_entry(
|
|||||||
class PlenticoreDataSwitch(CoordinatorEntity, SwitchEntity, ABC):
|
class PlenticoreDataSwitch(CoordinatorEntity, SwitchEntity, ABC):
|
||||||
"""Representation of a Plenticore Switch."""
|
"""Representation of a Plenticore Switch."""
|
||||||
|
|
||||||
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator,
|
coordinator,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user