393 files

This commit is contained in:
Home Assistant Version Control
2026-09-27 17:16:54 +00:00
parent b05b7a897e
commit 39d97ac2db
404 changed files with 54006 additions and 11034 deletions
@@ -18,14 +18,15 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import (
COMPLETION_PROVENANCE_NOTES,
CONF_OBJECT,
CONF_TASK_ENABLED,
CONF_TASKS,
DOMAIN,
GLOBAL_UNIQUE_ID,
slugify_object_name,
task_unique_id,
)
from .coordinator import MaintenanceCoordinator
from .entity.entity_base import MaintenanceEntity
from .helpers.aggregate import object_slug as aggregate_object_slug
from .helpers.pause import is_task_inert
if TYPE_CHECKING:
from . import MaintenanceSupporterConfigEntry
@@ -89,7 +90,7 @@ class MaintenanceActionButton(MaintenanceEntity, ButtonEntity):
obj_data = coordinator.entry.data.get(CONF_OBJECT, {})
task_data = coordinator.entry.data.get(CONF_TASKS, {}).get(task_id, {})
object_slug = slugify_object_name(obj_data.get("name", "unknown"))
object_slug = aggregate_object_slug(obj_data)
self._attr_unique_id = task_unique_id(object_slug, task_id, action)
self._attr_translation_key = f"button_{action}"
@@ -106,16 +107,17 @@ class MaintenanceActionButton(MaintenanceEntity, ButtonEntity):
return False
if not self._task_data:
return False
# Archived task → its complete/skip/reset buttons go unavailable (inert).
if self._task_data.get("archived_at") is not None:
return False
# An inert task — archived, disabled, or its object paused — has
# nothing to press: the coordinator refuses every action on it. The
# pause was missing here, so the buttons of a paused object looked
# usable and only raised on press (bug audit 2026-09-26).
task_cfg = self.coordinator.entry.data.get(CONF_TASKS, {}).get(self._task_id, {})
return bool(task_cfg.get(CONF_TASK_ENABLED, True))
return not is_task_inert({**task_cfg, **self._task_data}, self.coordinator.entry.data.get(CONF_OBJECT, {}))
async def async_press(self) -> None:
"""Run the action via the shared coordinator method (single source)."""
if not self._task_data:
raise HomeAssistantError(f"Task {self._task_id} no longer exists")
raise HomeAssistantError(translation_domain=DOMAIN, translation_key="task_no_longer_exists")
if self._action == "complete":
await self.coordinator.complete_maintenance(
self._task_id,