Fix battery %, battery voltage and signal strength not being diagnostic entities in xiaomi_ble (#81960)

This commit is contained in:
Jc2k 2022-11-11 15:37:57 +00:00 committed by GitHub
parent 89959e7cda
commit b5dfe8c6b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,7 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN from .const import DOMAIN
@ -64,12 +65,14 @@ SENSOR_DESCRIPTIONS = {
device_class=SensorDeviceClass.BATTERY, device_class=SensorDeviceClass.BATTERY,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
), ),
(DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription( (DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription(
key=str(Units.ELECTRIC_POTENTIAL_VOLT), key=str(Units.ELECTRIC_POTENTIAL_VOLT),
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
), ),
( (
DeviceClass.SIGNAL_STRENGTH, DeviceClass.SIGNAL_STRENGTH,
@ -80,6 +83,7 @@ SENSOR_DESCRIPTIONS = {
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT, native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
entity_category=EntityCategory.DIAGNOSTIC,
), ),
# Used for e.g. moisture sensor on HHCCJCY01 # Used for e.g. moisture sensor on HHCCJCY01
(None, Units.PERCENTAGE): SensorEntityDescription( (None, Units.PERCENTAGE): SensorEntityDescription(