mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Create entities directly on setup in Meater (#146953)
* Don't wait an update when adding devices in Meater * Fix
This commit is contained in:
parent
dffaf49eca
commit
9ae0cfc7e5
@ -170,6 +170,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
# Add a subscriber to the coordinator to discover new temperature probes
|
# Add a subscriber to the coordinator to discover new temperature probes
|
||||||
coordinator.async_add_listener(async_update_data)
|
coordinator.async_add_listener(async_update_data)
|
||||||
|
async_update_data()
|
||||||
|
|
||||||
|
|
||||||
class MeaterProbeTemperature(SensorEntity, CoordinatorEntity[MeaterCoordinator]):
|
class MeaterProbeTemperature(SensorEntity, CoordinatorEntity[MeaterCoordinator]):
|
||||||
|
@ -303,7 +303,7 @@
|
|||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': '2023-10-20T23:59:58+00:00',
|
'state': '2023-10-20T23:59:28+00:00',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_entities[sensor.meater_40a72384fa80349314dfd97c84b73a5c1c9da57b59e26d67b573d618fe0d6e58_cook_time_remaining-entry]
|
# name: test_entities[sensor.meater_40a72384fa80349314dfd97c84b73a5c1c9da57b59e26d67b573d618fe0d6e58_cook_time_remaining-entry]
|
||||||
@ -351,7 +351,7 @@
|
|||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': '2023-10-21T00:01:02+00:00',
|
'state': '2023-10-21T00:00:32+00:00',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_entities[sensor.meater_40a72384fa80349314dfd97c84b73a5c1c9da57b59e26d67b573d618fe0d6e58_internal-entry]
|
# name: test_entities[sensor.meater_40a72384fa80349314dfd97c84b73a5c1c9da57b59e26d67b573d618fe0d6e58_internal-entry]
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
"""Tests for the Meater integration."""
|
"""Tests for the Meater integration."""
|
||||||
|
|
||||||
from datetime import timedelta
|
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
from freezegun.api import FrozenDateTimeFactory
|
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.meater.const import DOMAIN
|
from homeassistant.components.meater.const import DOMAIN
|
||||||
@ -13,7 +11,7 @@ from homeassistant.helpers import device_registry as dr
|
|||||||
from . import setup_integration
|
from . import setup_integration
|
||||||
from .const import PROBE_ID
|
from .const import PROBE_ID
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
async def test_device_info(
|
async def test_device_info(
|
||||||
@ -22,13 +20,9 @@ async def test_device_info(
|
|||||||
mock_meater_client: AsyncMock,
|
mock_meater_client: AsyncMock,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
device_registry: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
freezer: FrozenDateTimeFactory,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test device registry integration."""
|
"""Test device registry integration."""
|
||||||
await setup_integration(hass, mock_config_entry)
|
await setup_integration(hass, mock_config_entry)
|
||||||
freezer.tick(timedelta(seconds=30))
|
|
||||||
async_fire_time_changed(hass)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
device_entry = device_registry.async_get_device(identifiers={(DOMAIN, PROBE_ID)})
|
device_entry = device_registry.async_get_device(identifiers={(DOMAIN, PROBE_ID)})
|
||||||
assert device_entry is not None
|
assert device_entry is not None
|
||||||
assert device_entry == snapshot
|
assert device_entry == snapshot
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
"""Tests for the Meater sensors."""
|
"""Tests for the Meater sensors."""
|
||||||
|
|
||||||
from datetime import timedelta
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
from freezegun.api import FrozenDateTimeFactory
|
|
||||||
import pytest
|
import pytest
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
@ -13,7 +11,7 @@ from homeassistant.helpers import entity_registry as er
|
|||||||
|
|
||||||
from . import setup_integration
|
from . import setup_integration
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
from tests.common import MockConfigEntry, snapshot_platform
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.freeze_time("2023-10-21")
|
@pytest.mark.freeze_time("2023-10-21")
|
||||||
@ -23,14 +21,9 @@ async def test_entities(
|
|||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
mock_meater_client: AsyncMock,
|
mock_meater_client: AsyncMock,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
freezer: FrozenDateTimeFactory,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the sensor entities."""
|
"""Test the sensor entities."""
|
||||||
with patch("homeassistant.components.meater.PLATFORMS", [Platform.SENSOR]):
|
with patch("homeassistant.components.meater.PLATFORMS", [Platform.SENSOR]):
|
||||||
await setup_integration(hass, mock_config_entry)
|
await setup_integration(hass, mock_config_entry)
|
||||||
|
|
||||||
freezer.tick(timedelta(seconds=30))
|
|
||||||
async_fire_time_changed(hass)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user