Skip to content

Commit

Permalink
No need to keep entity disabled by default as it is already marked as…
Browse files Browse the repository at this point in the history
… diagnostic
  • Loading branch information
Kane610 committed Jul 25, 2023
1 parent 1229945 commit f694304
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
1 change: 0 additions & 1 deletion homeassistant/components/unifi/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class UnifiImageEntityDescription(
key="WLAN QR Code",
entity_category=EntityCategory.DIAGNOSTIC,
has_entity_name=True,
entity_registry_enabled_default=False,
allowed_fn=lambda controller, obj_id: True,
api_handler_fn=lambda api: api.wlans,
available_fn=lambda controller, _: controller.available,
Expand Down
18 changes: 1 addition & 17 deletions tests/components/unifi/test_image.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
"""UniFi Network image platform tests."""

from copy import deepcopy
from datetime import timedelta
from http import HTTPStatus

from aiounifi.models.message import MessageKey
from syrupy.assertion import SnapshotAssertion

from homeassistant.components.image import DOMAIN as IMAGE_DOMAIN
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY
from homeassistant.const import (
EntityCategory,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.entity_registry import RegistryEntryDisabler
from homeassistant.util import dt as dt_util

from .test_controller import (
setup_unifi_integration,
)

from tests.common import async_fire_time_changed
from tests.test_util.aiohttp import AiohttpClientMocker
from tests.typing import ClientSessionGenerator

Expand Down Expand Up @@ -71,24 +66,13 @@ async def test_wlan_qr_code(
) -> None:
"""Test the update_clients function when no clients are found."""
await setup_unifi_integration(hass, aioclient_mock, wlans_response=[WLAN])
assert len(hass.states.async_entity_ids(IMAGE_DOMAIN)) == 0
assert len(hass.states.async_entity_ids(IMAGE_DOMAIN)) == 1

ent_reg = er.async_get(hass)
ent_reg_entry = ent_reg.async_get("image.ssid_1_qr_code")
assert ent_reg_entry.unique_id == "qr_code-012345678910111213141516"
assert ent_reg_entry.disabled_by == RegistryEntryDisabler.INTEGRATION
assert ent_reg_entry.entity_category is EntityCategory.DIAGNOSTIC

# Enable entity
ent_reg.async_update_entity(entity_id="image.ssid_1_qr_code", disabled_by=None)
await hass.async_block_till_done()

async_fire_time_changed(
hass,
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
)
await hass.async_block_till_done()

# Validate state object
image_state_1 = hass.states.get("image.ssid_1_qr_code")
assert image_state_1.name == "SSID 1 QR Code"
Expand Down

0 comments on commit f694304

Please sign in to comment.