Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Ludeeus
31a8250ed4 Use source name for version binary sensor 2022-02-18 10:21:57 +00:00
2 changed files with 5 additions and 8 deletions

View file

@ -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,
),

View file

@ -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