182 files

This commit is contained in:
Home Assistant Version Control
2026-08-17 12:11:35 +00:00
parent 7dddf6bb13
commit ece15a1c1b
183 changed files with 11457 additions and 3092 deletions
@@ -23,7 +23,6 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util import dt as dt_util
from .const import (
CONF_ADVANCED_SCHEDULE_TIME,
CONF_OBJECT,
CONF_TASKS,
DEFAULT_ENTITY_LOGIC,
@@ -33,11 +32,13 @@ from .const import (
SIGNAL_TASK_RESET,
MaintenanceStatus,
slugify_object_name,
task_unique_id,
)
from .coordinator import MaintenanceCoordinator
from .entity.entity_base import MaintenanceEntity
from .entity.summary_coordinator import MaintenanceSummaryCoordinator
from .entity.triggers import BaseTrigger, create_triggers, normalize_entity_ids
from .helpers.global_options import is_schedule_time_enabled
from .helpers.schedule import read_legacy_fields
from .helpers.status import compute_status_from_task_dict
@@ -144,7 +145,7 @@ class MaintenanceSensor(MaintenanceEntity, SensorEntity):
task_data = coordinator.entry.data.get(CONF_TASKS, {}).get(task_id, {})
object_slug = slugify_object_name(obj_data.get("name", "unknown"))
self._attr_unique_id = f"maintenance_supporter_{object_slug}_{task_id}"
self._attr_unique_id = task_unique_id(object_slug, task_id)
# Use custom entity_slug as the friendly name if provided
entity_slug = task_data.get("entity_slug")
@@ -459,7 +460,7 @@ class MaintenanceNextDueSensor(MaintenanceEntity, SensorEntity):
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"))
self._attr_unique_id = f"maintenance_supporter_{object_slug}_{task_id}_next_due"
self._attr_unique_id = task_unique_id(object_slug, task_id, "next_due")
self._attr_translation_placeholders = {"task_name": task_data.get("name", "")}
@property
@@ -490,12 +491,8 @@ class MaintenanceNextDueSensor(MaintenanceEntity, SensorEntity):
return datetime.combine(due, at, tzinfo=dt_util.DEFAULT_TIME_ZONE)
def _schedule_time_enabled(self) -> bool:
"""Global advanced flag — same lookup as the calendar entity."""
for ce in self.coordinator.hass.config_entries.async_entries(DOMAIN):
if ce.unique_id == GLOBAL_UNIQUE_ID:
opts = ce.options or ce.data
return bool(opts.get(CONF_ADVANCED_SCHEDULE_TIME, False))
return False
"""Global advanced flag — same source as the calendar entity."""
return is_schedule_time_enabled(self.coordinator.hass)
class MaintenanceDaysUntilDueSensor(MaintenanceEntity, SensorEntity):
@@ -532,7 +529,7 @@ class MaintenanceDaysUntilDueSensor(MaintenanceEntity, SensorEntity):
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"))
self._attr_unique_id = f"maintenance_supporter_{object_slug}_{task_id}_days_until_due"
self._attr_unique_id = task_unique_id(object_slug, task_id, "days_until_due")
self._attr_translation_placeholders = {"task_name": task_data.get("name", "")}
# Pin the documented, language-independent entity_id. Only NEW entities
# are affected — an already-registered one keeps its registry id.