Add entity category to Hue (#58011)
This commit is contained in:
parent
d8a354fa8f
commit
4fe4e65e3e
2 changed files with 10 additions and 0 deletions
|
@ -11,6 +11,7 @@ from homeassistant.const import (
|
|||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
|
@ -95,6 +96,7 @@ class HueBattery(GenericHueSensor, SensorEntity):
|
|||
_attr_device_class = DEVICE_CLASS_BATTERY
|
||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
||||
_attr_native_unit_of_measurement = PERCENTAGE
|
||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
|
@ -8,6 +8,8 @@ import pytest
|
|||
from homeassistant.components import hue
|
||||
from homeassistant.components.hue import sensor_base
|
||||
from homeassistant.components.hue.hue_event import CONF_HUE_EVENT
|
||||
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
|
||||
from homeassistant.helpers.entity_registry import async_get
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .conftest import create_mock_bridge, setup_bridge_for_sensors as setup_bridge
|
||||
|
@ -357,6 +359,12 @@ async def test_sensors(hass, mock_bridge):
|
|||
assert battery_remote_1.state == "100"
|
||||
assert battery_remote_1.name == "Hue dimmer switch 1 battery level"
|
||||
|
||||
ent_reg = async_get(hass)
|
||||
assert (
|
||||
ent_reg.async_get("sensor.hue_dimmer_switch_1_battery_level").entity_category
|
||||
== ENTITY_CATEGORY_DIAGNOSTIC
|
||||
)
|
||||
|
||||
|
||||
async def test_unsupported_sensors(hass, mock_bridge):
|
||||
"""Test that unsupported sensors don't get added and don't fail."""
|
||||
|
|
Loading…
Add table
Reference in a new issue