Add support for entity category for necessary KNX platforms (#58357)

This commit is contained in:
Marvin Wichmann 2021-10-25 05:12:26 +02:00 committed by GitHub
parent f3a1c81e22
commit e9ca511327
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 84 additions and 10 deletions

View file

@ -11,7 +11,7 @@ from homeassistant.components.sensor import (
DEVICE_CLASSES,
SensorEntity,
)
from homeassistant.const import CONF_NAME, CONF_TYPE
from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, CONF_TYPE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
@ -65,6 +65,7 @@ class KNXSensor(KnxEntity, SensorEntity):
else None
)
self._attr_force_update = self._device.always_callback
self._attr_entity_category = config.get(CONF_ENTITY_CATEGORY)
self._attr_unique_id = str(self._device.sensor_value.group_address_state)
self._attr_native_unit_of_measurement = self._device.unit_of_measurement()
self._attr_state_class = config.get(CONF_STATE_CLASS)