mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Remove deprecated update binary sensor from Supervisor (#78664)
This commit is contained in:
parent
1f7c90baa0
commit
69c5d910d4
@ -13,14 +13,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import ADDONS_COORDINATOR
|
||||
from .const import (
|
||||
ATTR_STARTED,
|
||||
ATTR_STATE,
|
||||
ATTR_UPDATE_AVAILABLE,
|
||||
DATA_KEY_ADDONS,
|
||||
DATA_KEY_OS,
|
||||
)
|
||||
from .entity import HassioAddonEntity, HassioOSEntity
|
||||
from .const import ATTR_STARTED, ATTR_STATE, DATA_KEY_ADDONS
|
||||
from .entity import HassioAddonEntity
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -30,17 +24,7 @@ class HassioBinarySensorEntityDescription(BinarySensorEntityDescription):
|
||||
target: str | None = None
|
||||
|
||||
|
||||
COMMON_ENTITY_DESCRIPTIONS = (
|
||||
HassioBinarySensorEntityDescription(
|
||||
# Deprecated, scheduled to be removed in 2022.6
|
||||
device_class=BinarySensorDeviceClass.UPDATE,
|
||||
entity_registry_enabled_default=False,
|
||||
key=ATTR_UPDATE_AVAILABLE,
|
||||
name="Update available",
|
||||
),
|
||||
)
|
||||
|
||||
ADDON_ENTITY_DESCRIPTIONS = COMMON_ENTITY_DESCRIPTIONS + (
|
||||
ADDON_ENTITY_DESCRIPTIONS = (
|
||||
HassioBinarySensorEntityDescription(
|
||||
device_class=BinarySensorDeviceClass.RUNNING,
|
||||
entity_registry_enabled_default=False,
|
||||
@ -59,28 +43,15 @@ async def async_setup_entry(
|
||||
"""Binary sensor set up for Hass.io config entry."""
|
||||
coordinator = hass.data[ADDONS_COORDINATOR]
|
||||
|
||||
entities: list[HassioAddonBinarySensor | HassioOSBinarySensor] = []
|
||||
|
||||
for entity_description in ADDON_ENTITY_DESCRIPTIONS:
|
||||
for addon in coordinator.data[DATA_KEY_ADDONS].values():
|
||||
entities.append(
|
||||
HassioAddonBinarySensor(
|
||||
addon=addon,
|
||||
coordinator=coordinator,
|
||||
entity_description=entity_description,
|
||||
)
|
||||
)
|
||||
|
||||
if coordinator.is_hass_os:
|
||||
for entity_description in COMMON_ENTITY_DESCRIPTIONS:
|
||||
entities.append(
|
||||
HassioOSBinarySensor(
|
||||
coordinator=coordinator,
|
||||
entity_description=entity_description,
|
||||
)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
HassioAddonBinarySensor(
|
||||
addon=addon,
|
||||
coordinator=coordinator,
|
||||
entity_description=entity_description,
|
||||
)
|
||||
for addon in coordinator.data[DATA_KEY_ADDONS].values()
|
||||
for entity_description in ADDON_ENTITY_DESCRIPTIONS
|
||||
)
|
||||
|
||||
|
||||
class HassioAddonBinarySensor(HassioAddonEntity, BinarySensorEntity):
|
||||
@ -97,12 +68,3 @@ class HassioAddonBinarySensor(HassioAddonEntity, BinarySensorEntity):
|
||||
if self.entity_description.target is None:
|
||||
return value
|
||||
return value == self.entity_description.target
|
||||
|
||||
|
||||
class HassioOSBinarySensor(HassioOSEntity, BinarySensorEntity):
|
||||
"""Binary sensor to track whether an update is available for Hass.io OS."""
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if the binary sensor is on."""
|
||||
return self.coordinator.data[DATA_KEY_OS][self.entity_description.key]
|
||||
|
@ -42,7 +42,6 @@ EVENT_SUPERVISOR_EVENT = "supervisor_event"
|
||||
ATTR_AUTO_UPDATE = "auto_update"
|
||||
ATTR_VERSION = "version"
|
||||
ATTR_VERSION_LATEST = "version_latest"
|
||||
ATTR_UPDATE_AVAILABLE = "update_available"
|
||||
ATTR_CPU_PERCENT = "cpu_percent"
|
||||
ATTR_CHANGELOG = "changelog"
|
||||
ATTR_MEMORY_PERCENT = "memory_percent"
|
||||
|
@ -137,9 +137,6 @@ def mock_all(aioclient_mock, request):
|
||||
@pytest.mark.parametrize(
|
||||
"entity_id,expected",
|
||||
[
|
||||
("binary_sensor.home_assistant_operating_system_update_available", "off"),
|
||||
("binary_sensor.test_update_available", "on"),
|
||||
("binary_sensor.test2_update_available", "off"),
|
||||
("binary_sensor.test_running", "on"),
|
||||
("binary_sensor.test2_running", "off"),
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user