mirror of
https://github.com/elisspace/core.git
synced 2026-08-29 15:43:55 +00:00
Use source name for version binary sensor
This commit is contained in:
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user