Repository navigation
feat(gateway): expose the gateway's enforced read-only flag as an entity and warn on mismatch - #5220
Merged
Merged
Conversation
…and warn on mismatch PredBat mirrors its own read-only setting to the gateway with a set_read_only command, but that mirror has no readback: the ack carries no value, and a gateway that was offline at the transition only catches up on the 30-minute re-send. So PredBat could never confirm what the gateway was actually enforcing. GatewayStatus gains `optional bool read_only = 18` (matching the firmware schema), reporting the flag as enforced: write-class commands rejected and autonomous mode disabled. _inject_entities publishes it as binary_sensor.<prefix>_gateway_read_only and as a read_only attribute on the gateway_online sensor. The field is proto3 optional, so absent means UNKNOWN rather than false. On firmware predating the field no entity is written at all and the attribute is None, rather than claiming the gateway is controllable when nothing has reported either way. When the reported value disagrees with the last state PredBat requested, a warning is logged once per transition into disagreement and the latch clears as soon as the two agree, so a stuck gateway does not fill the log. This path is observe-only and sends no commands. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EMnoLH9ponFsj2kg6agJXm
This was referenced Sep 26, 2026
springfall2008
added a commit
that referenced
this pull request
Sep 27, 2026
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.
The problem
PredBat mirrors its own read-only setting to the gateway with a
set_read_onlycommand, but that mirror has no readback. The ack carries no value, and a gateway that was offline at the moment of the transition only catches up on the 30-minute re-send. PredBat therefore has no way to confirm what the gateway is actually enforcing, and a user has no way to see it.The change
GatewayStatusgainsoptional bool read_only = 18, matching the firmware schema, reporting the flag as it is actually enforced: write-class commands rejected and autonomous mode disabled._inject_entitiesnow publishes it two ways:binary_sensor.<prefix>_gateway_read_only, friendly name "Gateway Read-Only (enforced)"read_onlyattribute on the existinggateway_onlinesensorThe field is proto3 optional, so absent is UNKNOWN rather than false. On firmware predating the field no entity is written at all and the attribute is
None, instead of claiming the gateway is controllable when nothing has reported either way.When the reported value disagrees with the last state PredBat requested, a warning is logged once per transition into disagreement, and the latch clears as soon as the two agree again. A gateway stuck in disagreement therefore does not fill the log. This path is observe-only and sends no commands.
Wire compatibility
Field 18 was free in
GatewayStatus. The regeneratedgateway_status_pb2.pychanges only the serialized descriptor and the offsets that follow from it. The gencode version stamp is unchanged at 7.34.1.Tests
Five new cases in
TestInjectEntitiesinapps/predbat/tests/test_gateway.py:None./run_all --test gatewaypasses: 286 cases, no failures.🤖 Generated with Claude Code
https://claude.ai/code/session_01EMnoLH9ponFsj2kg6agJXm