Remove deprecated binary sensor battery charging from technove (#134844)
parent
140ff50eaf
commit
3892f6d8f3
|
@ -4,28 +4,19 @@ from __future__ import annotations
|
|||
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from technove import Station as TechnoVEStation
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DOMAIN as BINARY_SENSOR_DOMAIN,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.issue_registry import (
|
||||
IssueSeverity,
|
||||
async_create_issue,
|
||||
async_delete_issue,
|
||||
)
|
||||
|
||||
from . import TechnoVEConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .coordinator import TechnoVEDataUpdateCoordinator
|
||||
from .entity import TechnoVEEntity
|
||||
|
||||
|
@ -34,7 +25,6 @@ from .entity import TechnoVEEntity
|
|||
class TechnoVEBinarySensorDescription(BinarySensorEntityDescription):
|
||||
"""Describes TechnoVE binary sensor entity."""
|
||||
|
||||
deprecated_version: str | None = None
|
||||
value_fn: Callable[[TechnoVEStation], bool | None]
|
||||
|
||||
|
||||
|
@ -57,15 +47,6 @@ BINARY_SENSORS = [
|
|||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
value_fn=lambda station: station.info.is_battery_protected,
|
||||
),
|
||||
TechnoVEBinarySensorDescription(
|
||||
key="is_session_active",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
|
||||
value_fn=lambda station: station.info.is_session_active,
|
||||
deprecated_version="2025.2.0",
|
||||
# Disabled by default, as this entity is deprecated
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
TechnoVEBinarySensorDescription(
|
||||
key="is_static_ip",
|
||||
translation_key="is_static_ip",
|
||||
|
@ -113,34 +94,3 @@ class TechnoVEBinarySensorEntity(TechnoVEEntity, BinarySensorEntity):
|
|||
"""Return the state of the sensor."""
|
||||
|
||||
return self.entity_description.value_fn(self.coordinator.data)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Raise issue when entity is registered and was not disabled."""
|
||||
if TYPE_CHECKING:
|
||||
assert self.unique_id
|
||||
if entity_id := er.async_get(self.hass).async_get_entity_id(
|
||||
BINARY_SENSOR_DOMAIN, DOMAIN, self.unique_id
|
||||
):
|
||||
if self.enabled and self.entity_description.deprecated_version:
|
||||
async_create_issue(
|
||||
self.hass,
|
||||
DOMAIN,
|
||||
f"deprecated_entity_{self.entity_description.key}",
|
||||
breaks_in_ha_version=self.entity_description.deprecated_version,
|
||||
is_fixable=False,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key=f"deprecated_entity_{self.entity_description.key}",
|
||||
translation_placeholders={
|
||||
"sensor_name": self.name
|
||||
if isinstance(self.name, str)
|
||||
else entity_id,
|
||||
"entity": entity_id,
|
||||
},
|
||||
)
|
||||
else:
|
||||
async_delete_issue(
|
||||
self.hass,
|
||||
DOMAIN,
|
||||
f"deprecated_entity_{self.entity_description.key}",
|
||||
)
|
||||
await super().async_added_to_hass()
|
||||
|
|
|
@ -90,11 +90,5 @@
|
|||
"set_charging_enabled_on_auto_charge": {
|
||||
"message": "Cannot enable or disable charging when auto-charge is enabled. Try disabling auto-charge first."
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
"deprecated_entity_is_session_active": {
|
||||
"title": "The TechnoVE {sensor_name} binary sensor is deprecated",
|
||||
"description": "`{entity}` is deprecated.\nPlease update your automations and scripts to replace the binary sensor entity with the newly added switch entity.\nWhen you are done migrating you can disable `{entity}`."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,53 +45,6 @@
|
|||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[binary_sensor.technove_station_charging-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'binary_sensor',
|
||||
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||
'entity_id': 'binary_sensor.technove_station_charging',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.BATTERY_CHARGING: 'battery_charging'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Charging',
|
||||
'platform': 'technove',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': None,
|
||||
'unique_id': 'AA:AA:AA:AA:AA:BB_is_session_active',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[binary_sensor.technove_station_charging-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'battery_charging',
|
||||
'friendly_name': 'TechnoVE Station Charging',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.technove_station_charging',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[binary_sensor.technove_station_conflict_with_power_sharing_mode-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
|
|
@ -45,7 +45,6 @@ async def test_sensors(
|
|||
"entity_id",
|
||||
[
|
||||
"binary_sensor.technove_station_static_ip",
|
||||
"binary_sensor.technove_station_charging",
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("init_integration")
|
||||
|
|
Loading…
Reference in New Issue