From 31a8250ed4a8a4a2528f9a6a7feb5e1f449fb977 Mon Sep 17 00:00:00 2001 From: Ludeeus Date: Fri, 18 Feb 2022 10:21:57 +0000 Subject: [PATCH] Use source name for version binary sensor --- homeassistant/components/version/binary_sensor.py | 9 +++------ tests/components/version/test_binary_sensor.py | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/version/binary_sensor.py b/homeassistant/components/version/binary_sensor.py index 0e60b1b856c..c55009c18c7 100644 --- a/homeassistant/components/version/binary_sensor.py +++ b/homeassistant/components/version/binary_sensor.py @@ -9,12 +9,12 @@ from homeassistant.components.binary_sensor import ( BinarySensorEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_NAME, __version__ as HA_VERSION +from homeassistant.const import __version__ as HA_VERSION from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback -from .const import CONF_SOURCE, DEFAULT_NAME, DOMAIN +from .const import CONF_SOURCE, DOMAIN from .coordinator import VersionDataUpdateCoordinator from .entity import VersionEntity @@ -31,15 +31,12 @@ async def async_setup_entry( if (source := config_entry.data[CONF_SOURCE]) == "local": return - if (entity_name := config_entry.data[CONF_NAME]) == DEFAULT_NAME: - entity_name = config_entry.title - entities: list[VersionBinarySensor] = [ VersionBinarySensor( coordinator=coordinator, entity_description=BinarySensorEntityDescription( key=str(source), - name=f"{entity_name} Update Available", + name=f"{source} Update Available", device_class=BinarySensorDeviceClass.UPDATE, entity_category=EntityCategory.DIAGNOSTIC, ), diff --git a/tests/components/version/test_binary_sensor.py b/tests/components/version/test_binary_sensor.py index c9551ad4415..faed6cd2a5e 100644 --- a/tests/components/version/test_binary_sensor.py +++ b/tests/components/version/test_binary_sensor.py @@ -11,7 +11,7 @@ async def test_version_binary_sensor_local_source(hass: HomeAssistant): """Test the Version binary sensor with local source.""" await setup_version_integration(hass) - state = hass.states.get("binary_sensor.local_installation_update_available") + state = hass.states.get("binary_sensor.local_update_available") assert not state @@ -19,5 +19,5 @@ async def test_version_binary_sensor(hass: HomeAssistant): """Test the Version binary sensor.""" await setup_version_integration(hass, {**DEFAULT_CONFIGURATION, "source": "pypi"}) - state = hass.states.get("binary_sensor.local_installation_update_available") + state = hass.states.get("binary_sensor.pypi_update_available") assert state