198 files

This commit is contained in:
Home Assistant Version Control
2026-10-11 23:51:59 +00:00
parent 4a64770282
commit 669d229519
198 changed files with 4891 additions and 2815 deletions
@@ -45,6 +45,7 @@ from homeassistant.helpers import intent
from .const import COMPLETION_PROVENANCE_NOTES, CONF_OBJECT, CONF_TASKS, DOMAIN, NOTIFIABLE_STATUSES
from .helpers.aggregate import get_object_entries, iter_live_tasks, priority_rank
from .helpers.aggregate import object_name as aggregate_object_name
from .helpers.assignees import task_user_ids
INTENT_LIST_TASKS = "MaintenanceSupporterListTasks"
INTENT_COMPLETE_TASK = "MaintenanceSupporterCompleteTask"
@@ -120,6 +121,9 @@ def _task_snapshot(hass: HomeAssistant) -> list[dict[str, Any]]:
"name": str(task.get("name") or ""),
# Whose turn it is — for a rotation this is the current duty.
"responsible_user_id": task.get("responsible_user_id") or None,
# Who it is meant for: that person, or everyone it is shared
# with while nobody is responsible ("my tasks" reads this).
"user_ids": task_user_ids(task),
"status": str(task.get("_status", "")),
"days_until_due": task.get("_days_until_due"),
"next_due": task.get("_next_due"),
@@ -379,7 +383,7 @@ class ListTasksIntent(intent.IntentHandler):
_sp("unknown_user", lang),
)
return response
tasks = [t for t in tasks if t.get("responsible_user_id") == user_id]
tasks = [t for t in tasks if user_id in t["user_ids"]]
elif scope == "here":
area = _asking_area(intent_obj)
if not area:
@@ -768,6 +772,9 @@ def _part_snapshot(hass: HomeAssistant) -> list[dict[str, Any]]:
"restock_quantity": part.get("restock_quantity"),
"package_size": part.get("package_size"),
"stock": store.get_part_stock(part_id) if store is not None else None,
# #208: a reusable part's used ones still count as owned.
"reuse": part.get("reuse"),
"restoring": store.get_part_restoring(part_id) if store is not None else 0,
}
)
return rows
@@ -830,12 +837,12 @@ class PartStockIntent(intent.IntentHandler):
response.async_set_speech(_sp("stock_untracked", lang, part=part["name"]))
return response
from .helpers.parts import part_is_low
from .helpers.parts import on_hand, part_is_low
loc = _sp("stock_loc", lang, loc=part["storage_location"]) if part.get("storage_location") else ""
# The shared stock rule: a decimal threshold ("0.5 bags") counts too —
# the int-only check here never warned for one.
low = _sp("stock_low", lang) if part_is_low(part, part["stock"]) else ""
low = _sp("stock_low", lang) if part_is_low(part, on_hand(part, part["stock"], part.get("restoring"))) else ""
response.async_set_speech(
_sp("stock_line", lang, stock=_num(part["stock"]), part=part["name"], loc=loc, low=low)
)