fix: read saving session available_events from configured entity, not rewritten one - #4585
Merged
springfall2008 merged 2 commits intoAug 19, 2026
Merged
Conversation
… rewritten one The binary_sensor -> event entity rewrite used as a fallback for legacy configs rebound entity_id unconditionally whenever joined_events was empty, so the following available_events read used the rewritten name instead of the configured entity. If the rewritten entity didn't exist (e.g. custom entity names with no '_sessions' substring), available_events came back empty and saving-session auto-join silently stopped working with nothing logged. Fixes #4573
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression in Octopus Saving Session auto-join by ensuring available_events is read from the user-configured saving-session entity, and only falling back to the legacy binary_sensor.*_sessions -> event.*_session_events rewrite when the configured entity provides no relevant attributes.
Changes:
- Read both
joined_eventsandavailable_eventsfrom the configuredoctopus_saving_sessionentity before attempting any entity-id rewrite. - Gate the entity-id rewrite so it’s only adopted when the rewritten entity actually returns usable data.
- Add a regression test covering custom entity names that do not match the rewrite pattern.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/predbat/octopus.py | Fixes saving-session attribute reads so available_events isn’t accidentally read from a rewritten/nonexistent entity. |
| apps/predbat/tests/test_saving_session.py | Adds regression coverage for a custom configured entity name where rewrite would not resolve. |
| apps/predbat/unit_test.py | Registers the new saving-session regression test in the test runner. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Distinguish "attribute genuinely missing" from "attribute present but an empty list" using a sentinel, so the binary_sensor -> event fallback no longer misfires when the configured entity is valid but currently has no events (a normal, common state). - Isolate the new regression test's mutation of my_predbat.args behind a save/restore, matching the pattern used by other tests in this suite. Addresses Copilot review comments on PR #4585.
springfall2008
deleted the
fix/octopus-saving-session-entity-rewrite-4573
branch
August 19, 2026 07:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4573.
The
octopus_saving_sessionbinary_sensor -> event entity rewrite (a fallback for legacy configs) reboundentity_idunconditionally wheneverjoined_eventswas empty on the configured entity. The followingavailable_eventsread then used the rewritten entity name instead of the one the user configured. If the rewritten entity didn't exist (e.g. custom entity names with no_sessionssubstring, or the newer flexibility API naming),available_eventscame back empty and saving-session auto-join silently stopped working - with nothing logged, since the "auto-join is disabled" message also requiresavailable_eventsto be truthy.Fix
available_eventsandjoined_eventsare now both read from the configured entity first. The rewrite to theevent.*entity is only attempted - and only adopted - when the configured entity has neither attribute and the rewritten entity actually returns data. This preserves the legacy binary_sensor path (whereentity_idgenuinely needs to be rebound so a later join-service call targets the correct entity) while fixing the case where the configured entity already has the data needed.Test plan
test_saving_session_custom_entity_no_rewrite_match, reproducing the issue's scenario (custom entity name, emptyjoined_events, populatedavailable_events, no matching rewritten entity). Confirmed it fails on the pre-fix code (0 join calls) and passes with the fix.saving_session,saving_session_null,saving_session_notify,saving_session_default_rate,saving_session_axle_conflict,saving_session_auto_join_toggle)../run_all --quicksuite passes.pre-commit(ruff, black, cspell) passes on changed files.🤖 Generated with Claude Code