mirror of
https://github.com/home-assistant/core.git
synced 2025-04-19 14:57:52 +00:00
Add debug logging to homekit when an sensor entity cannot be classified (#142707)
* Add debug logging to homekit when an sensor entity cannot be classified In #132937 many hours were spent investigating an issue which turned out to be that the entity did not have a device class at startup because the group integration does not set the device class if any of the underlying entities state is invalid. closes #132937 * coverage * Update tests/components/homekit/test_get_accessories.py
This commit is contained in:
parent
a340646e1e
commit
1aa996d5f0
@ -245,6 +245,13 @@ def get_accessory( # noqa: C901
|
||||
a_type = "CarbonDioxideSensor"
|
||||
elif device_class == SensorDeviceClass.ILLUMINANCE or unit == LIGHT_LUX:
|
||||
a_type = "LightSensor"
|
||||
else:
|
||||
_LOGGER.debug(
|
||||
"%s: Unsupported sensor type (device_class=%s) (unit=%s)",
|
||||
state.entity_id,
|
||||
device_class,
|
||||
unit,
|
||||
)
|
||||
|
||||
elif state.domain == "switch":
|
||||
if switch_type := config.get(CONF_TYPE):
|
||||
|
@ -53,6 +53,12 @@ def test_not_supported(caplog: pytest.LogCaptureFixture) -> None:
|
||||
assert "invalid aid" in caplog.records[0].msg
|
||||
|
||||
|
||||
def test_not_supported_sensor(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test if none is returned if entity isn't supported."""
|
||||
assert get_accessory(None, None, State("sensor.xyz", "on"), 2, {}) is None
|
||||
assert "Unsupported sensor type (device_class=None)" in caplog.text
|
||||
|
||||
|
||||
def test_not_supported_media_player() -> None:
|
||||
"""Test if mode isn't supported and if no supported modes."""
|
||||
# selected mode for entity not supported
|
||||
|
Loading…
x
Reference in New Issue
Block a user