Do not add outside temperature sensor for FGLair if reading is None (#140298)

* Do not add outside temperature sensor if reading is None

* Fix comments
This commit is contained in:
Antoine Reversat 2025-03-10 18:16:44 -04:00 committed by GitHub
parent bf50ee9b5e
commit 37213503b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -24,6 +24,7 @@ async def async_setup_entry(
async_add_entities(
FGLairOutsideTemperature(entry.runtime_data, device)
for device in entry.runtime_data.data.values()
if device.outdoor_temperature is not None
)

View File

@ -31,3 +31,20 @@ async def test_entities(
assert await integration_setup()
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
async def test_no_outside_temperature(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_ayla_api: AsyncMock,
integration_setup: Callable[[], Awaitable[bool]],
) -> None:
"""Test that the outside sensor doesn't get added if the reading is None."""
mock_ayla_api.async_get_devices.return_value[0].outdoor_temperature = None
assert await integration_setup()
assert (
len(entity_registry.entities)
== len(mock_ayla_api.async_get_devices.return_value) - 1
)