Commit 30766aa
fix(entities): refetch entity state after exposure so the response reflects new should_expose (#1697)
* fix(entities): refetch entity state after exposure so the response reflects new should_expose
When a phase before exposure already populated entity_entry (a registry
field update, an options update, or a device rename), the post-exposure
refetch in _apply_expose_to was gated on `if not entity_entry` and was
therefore skipped, so ha_set_entity returned the pre-exposure snapshot --
its options[...].should_expose did not reflect the exposure just applied.
The exposure was always applied correctly; only the returned entity was
stale.
Refetch now also fires when exposure was applied (exposure_result is not
None). Pure expose_to-only calls are unchanged. Regression from #1692.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(entities): don't fail ha_set_entity when the cosmetic post-exposure refetch fails
PR review of the refetch surfaced three issues, all fixed here:
- A failed post-exposure refetch could turn a fully-committed combined call
(registry/options/device-rename + expose) into a reported ENTITY_NOT_FOUND.
When a prior phase already produced a snapshot, warn and return it instead.
- The failure swallowed the real WebSocket error and hard-coded "not found";
now surfaces _extract_ws_error + has_registry_updates/options_succeeded.
- Removed the dead `or not entity_entry` clause.
Tests added for the fallback and the options-only / new_device_name combos.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(entities): make post-exposure refetch unconditional
The `if exposure_result is not None` guard is always True at that point
(empty expose_to returns early; any exposure failure raises above), so the
refetch is now unconditional, per Gemini review feedback on #1697. Adds
test_expose_hide_only_still_refetches to pin that a hide-only expose
(should_expose=False, a truthy {assistant: False} result) still refetches.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: kingpanther13 <kingpanther13@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 1193579 commit 30766aa
2 files changed
Lines changed: 319 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
771 | 785 | | |
| 786 | + | |
772 | 787 | | |
773 | 788 | | |
774 | 789 | | |
| |||
0 commit comments