mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Add entity category to Hue (#58011)
This commit is contained in:
parent
d8a354fa8f
commit
4fe4e65e3e
@ -11,6 +11,7 @@ from homeassistant.const import (
|
|||||||
DEVICE_CLASS_BATTERY,
|
DEVICE_CLASS_BATTERY,
|
||||||
DEVICE_CLASS_ILLUMINANCE,
|
DEVICE_CLASS_ILLUMINANCE,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
@ -95,6 +96,7 @@ class HueBattery(GenericHueSensor, SensorEntity):
|
|||||||
_attr_device_class = DEVICE_CLASS_BATTERY
|
_attr_device_class = DEVICE_CLASS_BATTERY
|
||||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
_attr_state_class = STATE_CLASS_MEASUREMENT
|
||||||
_attr_native_unit_of_measurement = PERCENTAGE
|
_attr_native_unit_of_measurement = PERCENTAGE
|
||||||
|
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
@ -8,6 +8,8 @@ import pytest
|
|||||||
from homeassistant.components import hue
|
from homeassistant.components import hue
|
||||||
from homeassistant.components.hue import sensor_base
|
from homeassistant.components.hue import sensor_base
|
||||||
from homeassistant.components.hue.hue_event import CONF_HUE_EVENT
|
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 homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from .conftest import create_mock_bridge, setup_bridge_for_sensors as setup_bridge
|
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.state == "100"
|
||||||
assert battery_remote_1.name == "Hue dimmer switch 1 battery level"
|
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):
|
async def test_unsupported_sensors(hass, mock_bridge):
|
||||||
"""Test that unsupported sensors don't get added and don't fail."""
|
"""Test that unsupported sensors don't get added and don't fail."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user