diff --git a/homeassistant/components/meater/diagnostics.py b/homeassistant/components/meater/diagnostics.py new file mode 100644 index 00000000000..247457d0bc8 --- /dev/null +++ b/homeassistant/components/meater/diagnostics.py @@ -0,0 +1,55 @@ +"""Diagnostics support for the Meater integration.""" + +from __future__ import annotations + +from typing import Any + +from homeassistant.core import HomeAssistant + +from . import MeaterConfigEntry + + +async def async_get_config_entry_diagnostics( + hass: HomeAssistant, config_entry: MeaterConfigEntry +) -> dict[str, Any]: + """Return diagnostics for a config entry.""" + coordinator = config_entry.runtime_data + + return { + identifier: { + "id": probe.id, + "internal_temperature": probe.internal_temperature, + "ambient_temperature": probe.ambient_temperature, + "time_updated": probe.time_updated.isoformat(), + "cook": ( + { + "id": probe.cook.id, + "name": probe.cook.name, + "state": probe.cook.state, + "target_temperature": ( + probe.cook.target_temperature + if hasattr(probe.cook, "target_temperature") + else None + ), + "peak_temperature": ( + probe.cook.peak_temperature + if hasattr(probe.cook, "peak_temperature") + else None + ), + "time_remaining": ( + probe.cook.time_remaining + if hasattr(probe.cook, "time_remaining") + else None + ), + "time_elapsed": ( + probe.cook.time_elapsed + if hasattr(probe.cook, "time_elapsed") + else None + ), + } + if probe.cook + else None + ), + } + for identifier, probe in coordinator.data.items() + } diff --git a/tests/components/meater/snapshots/test_diagnostics.ambr b/tests/components/meater/snapshots/test_diagnostics.ambr new file mode 100644 index 00000000000..ced779eb114 --- /dev/null +++ b/tests/components/meater/snapshots/test_diagnostics.ambr @@ -0,0 +1,20 @@ +# serializer version: 1 +# name: test_entry_diagnostics + dict({ + '40a72384fa80349314dfd97c84b73a5c1c9da57b59e26d67b573d618fe0d6e58': dict({ + 'ambient_temperature': 28.0, + 'cook': dict({ + 'id': '123123', + 'name': 'Whole chicken', + 'peak_temperature': 27.0, + 'state': 'Started', + 'target_temperature': 25.0, + 'time_elapsed': 32, + 'time_remaining': 32, + }), + 'id': '40a72384fa80349314dfd97c84b73a5c1c9da57b59e26d67b573d618fe0d6e58', + 'internal_temperature': 26.0, + 'time_updated': '2025-06-16T13:53:51+00:00', + }), + }) +# --- diff --git a/tests/components/meater/test_diagnostics.py b/tests/components/meater/test_diagnostics.py new file mode 100644 index 00000000000..9d78828a92f --- /dev/null +++ b/tests/components/meater/test_diagnostics.py @@ -0,0 +1,28 @@ +"""Test Meater diagnostics.""" + +from unittest.mock import AsyncMock + +from syrupy.assertion import SnapshotAssertion + +from homeassistant.core import HomeAssistant + +from . import setup_integration + +from tests.common import MockConfigEntry +from tests.components.diagnostics import get_diagnostics_for_config_entry +from tests.typing import ClientSessionGenerator + + +async def test_entry_diagnostics( + hass: HomeAssistant, + hass_client: ClientSessionGenerator, + mock_meater_client: AsyncMock, + mock_config_entry: MockConfigEntry, + snapshot: SnapshotAssertion, +) -> None: + """Test config entry diagnostics.""" + await setup_integration(hass, mock_config_entry) + assert ( + await get_diagnostics_for_config_entry(hass, hass_client, mock_config_entry) + == snapshot + )