Disable the CPU temperature sensor entity of lunatone by default (#195503)

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
MoonDevLT
2026-11-30 17:15:06 +00:00
committed by GitHub
co-authored by Copilot Autofix powered by AI
parent 47490ec0e4
commit c3e3cf217f
4 changed files with 32 additions and 3 deletions
@@ -62,7 +62,7 @@ rules:
dynamic-devices: done
entity-category: done
entity-device-class: done
entity-disabled-by-default: todo
entity-disabled-by-default: done
entity-translations: done
exception-translations: done
icon-translations: done
@@ -95,6 +95,8 @@ SPECIAL_SENSOR_TYPES: Final[dict[tuple[str, SensorType], SensorEntityDescription
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
translation_key="cpu_temperature",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
)
}
@@ -255,7 +255,7 @@
'device_id': <DeviceEntry identifiers=[('lunatone', 'be37ca9c47c24498a38bc62c7c711840')]>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.test_cpu_temperature',
'has_entity_name': True,
'hidden_by': None,
+28 -1
View File
@@ -24,7 +24,7 @@ from homeassistant.const import STATE_UNKNOWN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
from . import setup_integration
from . import enable_entities, setup_integration
async def test_setup(
@@ -39,6 +39,9 @@ async def test_setup(
) -> None:
"""Test the Lunatone sensor setup."""
await setup_integration(hass, mock_config_entry)
await enable_entities(
hass, entity_registry, mock_config_entry.entry_id, Platform.SENSOR
)
entities = hass.states.async_all(Platform.SENSOR)
for entity_state in entities:
@@ -65,6 +68,7 @@ async def test_sensor_value_update(
mock_lunatone_sensors: AsyncMock,
mock_lunatone_scan: AsyncMock,
mock_config_entry: MockConfigEntry,
entity_registry: er.EntityRegistry,
freezer: FrozenDateTimeFactory,
sensor_id: int,
entity_id: str,
@@ -72,6 +76,9 @@ async def test_sensor_value_update(
) -> None:
"""Test the Lunatone sensor value update."""
await setup_integration(hass, mock_config_entry)
await enable_entities(
hass, entity_registry, mock_config_entry.entry_id, Platform.SENSOR
)
async def fake_update() -> None:
for sensor_data in mock_lunatone_sensors.data.sensors:
@@ -93,6 +100,26 @@ async def test_sensor_value_update(
assert entity.state == expected_state
async def test_disabled_by_default(
hass: HomeAssistant,
mock_lunatone_info: AsyncMock,
mock_lunatone_devices: AsyncMock,
mock_lunatone_sensors: AsyncMock,
mock_lunatone_scan: AsyncMock,
mock_config_entry: MockConfigEntry,
entity_registry: er.EntityRegistry,
) -> None:
"""Test sensors that are disabled by default."""
entity_id = "sensor.test_cpu_temperature"
await setup_integration(hass, mock_config_entry)
entity_entry = entity_registry.async_get(entity_id)
assert entity_entry
assert entity_entry.disabled
assert entity_entry.disabled_by == er.RegistryEntryDisabler.INTEGRATION
async def test_sensor_added_after_update(
hass: HomeAssistant,
mock_lunatone_info: AsyncMock,