Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions custom_components/horticulture_assistant/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,26 @@ def profile_unique_id(self, key: str | None = None) -> str:
"""Return a stable unique id for profile entities."""

return super().profile_unique_id(key)

@property
def available(self) -> bool:
"""Report entities as available while awaiting coordinator data.

Coordinator entities default to ``unavailable`` until a successful
refresh completes. For plant profile entities this prevents device
actions from targeting them immediately after setup. We instead mark
them as available (yielding an ``unknown`` state because no value is
set) until the coordinator reports a failure after its first attempt.
"""

if getattr(self, "_attr_available", None) is False:
return False

coordinator = getattr(self, "coordinator", None)
if coordinator is None:
return True

if coordinator.last_update_success:
return True

return coordinator.last_update_success_time is None