1
mirror of https://github.com/home-assistant/core synced 2024-10-04 07:58:43 +02:00

Add entity category to Hue (#58011)

This commit is contained in:
Paulus Schoutsen 2021-10-19 03:29:43 -07:00 committed by GitHub
parent d8a354fa8f
commit 4fe4e65e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -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):

View File

@ -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."""