diff --git a/homeassistant/components/version/coordinator.py b/homeassistant/components/version/coordinator.py index 635f0fb3bb2..24e44f9f56c 100644 --- a/homeassistant/components/version/coordinator.py +++ b/homeassistant/components/version/coordinator.py @@ -4,7 +4,7 @@ from __future__ import annotations from typing import Any from awesomeversion import AwesomeVersion -from pyhaversion import HaVersion +from pyhaversion import HaVersion, HaVersionSource from pyhaversion.exceptions import HaVersionException from homeassistant.config_entries import ConfigEntry @@ -41,8 +41,10 @@ class VersionDataUpdateCoordinator(DataUpdateCoordinator): return str(self._version) if self._version else None @property - def version_data(self) -> dict[str, Any]: + def version_data(self) -> dict[str, Any] | None: """Return the version data.""" + if self._api.source == HaVersionSource.LOCAL: + return None return self._version_data or {} async def _async_update_data(self) -> None: diff --git a/homeassistant/components/version/sensor.py b/homeassistant/components/version/sensor.py index 6a6a2b88879..8b09d893afd 100644 --- a/homeassistant/components/version/sensor.py +++ b/homeassistant/components/version/sensor.py @@ -122,6 +122,6 @@ class VersionSensorEntity(CoordinatorEntity, SensorEntity): return self.coordinator.version @property - def extra_state_attributes(self) -> dict[str, Any]: + def extra_state_attributes(self) -> dict[str, Any] | None: """Return extra state attributes of this sensor.""" return self.coordinator.version_data diff --git a/tests/components/version/test_sensor.py b/tests/components/version/test_sensor.py index 1dead6ab40b..72e63820345 100644 --- a/tests/components/version/test_sensor.py +++ b/tests/components/version/test_sensor.py @@ -57,8 +57,8 @@ async def test_version_sensor(hass: HomeAssistant): state = hass.states.get("sensor.local_installation") assert state.state == MOCK_VERSION - assert state.attributes["source"] == "local" - assert state.attributes["channel"] == "stable" + assert "source" not in state.attributes + assert "channel" not in state.attributes async def test_update(hass: HomeAssistant, caplog: pytest.LogCaptureFixture):