Revert "add deprecation warning for task sensors"

This reverts commit 9e58053f3b.
This commit is contained in:
tr4nt0r
2024-04-27 10:09:49 +00:00
parent bb1b1b52a5
commit c3d23fe7ec
2 changed files with 2 additions and 68 deletions

View File

@@ -17,11 +17,6 @@ from homeassistant.const import CONF_NAME, CONF_URL
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.issue_registry import (
IssueSeverity,
async_create_issue,
async_delete_issue,
)
from .const import DOMAIN, MANUFACTURER, NAME from .const import DOMAIN, MANUFACTURER, NAME
@@ -172,9 +167,8 @@ async def async_setup_entry(
HabitipySensor(sensor_data, description, config_entry) HabitipySensor(sensor_data, description, config_entry)
for description in SENSOR_DESCRIPTIONS.values() for description in SENSOR_DESCRIPTIONS.values()
] ]
# Task sensors are deprecated and will be removed in 2024.12
entities.extend( entities.extend(
HabitipyTaskSensor(hass, name, task_type, sensor_data, config_entry) HabitipyTaskSensor(name, task_type, sensor_data, config_entry)
for task_type in TASKS_TYPES for task_type in TASKS_TYPES
) )
async_add_entities(entities, True) async_add_entities(entities, True)
@@ -216,39 +210,12 @@ class HabitipySensor(SensorEntity):
data = data[element] data = data[element]
self._attr_native_value = data self._attr_native_value = data
async def async_added_to_hass(self) -> None:
"""Raise issue when entity is registered and was not disabled."""
if self.entity_description.key == HabitipySensorEntity.HEALTH_MAX:
if self.enabled:
name = self.name
async_create_issue(
self.hass,
DOMAIN,
f"deprecated_sensor_entity_{self.entity_description.key}",
breaks_in_ha_version="2024.12.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="deprecated_sensor_entity",
translation_placeholders={
"entity_name": str(name),
"entity": self.entity_id,
},
)
else:
async_delete_issue(
self.hass,
DOMAIN,
f"deprecated_sensor_entity_{self.entity_description.key}",
)
# Task sensors are deprecated and will be removed in 2024.12
class HabitipyTaskSensor(SensorEntity): class HabitipyTaskSensor(SensorEntity):
"""A Habitica task sensor.""" """A Habitica task sensor."""
def __init__(self, hass, name, task_name, updater, entry): def __init__(self, name, task_name, updater, entry):
"""Initialize a generic Habitica task.""" """Initialize a generic Habitica task."""
# self.hass = hass
self._name = name self._name = name
self._task_name = task_name self._task_name = task_name
self._task_type = TASKS_TYPES[task_name] self._task_type = TASKS_TYPES[task_name]
@@ -272,29 +239,6 @@ class HabitipyTaskSensor(SensorEntity):
tasks_length = len(all_tasks[element]) tasks_length = len(all_tasks[element])
self._state = tasks_length self._state = tasks_length
async def async_added_to_hass(self) -> None:
"""Raise issue when entity is registered and was not disabled."""
if self.enabled:
async_create_issue(
self.hass,
DOMAIN,
f"deprecated_task_entity_{self._task_name}",
breaks_in_ha_version="2024.12.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="deprecated_task_entity",
translation_placeholders={
"task_name": self._task_name,
"entity": f"sensor.habitica_{self._name}_{self._task_name}",
},
)
else:
async_delete_issue(
self.hass,
DOMAIN,
f"deprecated_task_entity_{self._task_name}",
)
@property @property
def icon(self): def icon(self):
"""Return the icon to use in the frontend, if any.""" """Return the icon to use in the frontend, if any."""

View File

@@ -59,16 +59,6 @@
} }
} }
}, },
"issues": {
"deprecated_task_entity": {
"title": "The Habitica `{task_name}` sensor is deprecated",
"description": "The Habitica entity `{entity}` is deprecated and will be removed in `2024.12`.\nPlease update your automations and scripts to replace the sensor entity with the new todo entity.\nWhen you are done migrating you can disable the entity."
},
"deprecated_sensor_entity": {
"title": "The Habitica `{entity_name}` sensor is deprecated",
"description": "The Habitica entity `{entity}` is deprecated and will be removed in `2024.12`.\nEach player can have a maximum of 50 HP, and this maximum cannot be altered, thus the `{entity_name}` sensor serves no purpose.\nYou can disable the entity."
}
},
"services": { "services": {
"api_call": { "api_call": {
"name": "API name", "name": "API name",