-
Notifications
You must be signed in to change notification settings - Fork 13
mqtt: expose limit-battery-charge mode in Home Assistant discovery #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MaStr
merged 1 commit into
MaStr:main
from
filiplajszczak:mqtt-mode-discovery-limit-charge
Apr 16, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,33 @@ def test_str_convert_with_plain_string(self): | |
| assert received == ['true'] | ||
|
|
||
|
|
||
| class TestModeDiscovery: | ||
| """Mode discovery should expose the full externally supported mode model.""" | ||
|
|
||
|
Comment on lines
+92
to
+94
|
||
| def test_mode_discovery_includes_limit_battery_charge_mode(self): | ||
| api = MagicMock(spec=MqttApi) | ||
| api.base_topic = 'batcontrol' | ||
| api.publish_mqtt_discovery_message = MagicMock() | ||
| api.send_mqtt_discovery_for_mode = ( | ||
| MqttApi.send_mqtt_discovery_for_mode.__get__(api, MqttApi) | ||
| ) | ||
|
|
||
| api.send_mqtt_discovery_for_mode() | ||
|
|
||
| options = api.publish_mqtt_discovery_message.call_args.kwargs['options'] | ||
| value_template = api.publish_mqtt_discovery_message.call_args.kwargs['value_template'] | ||
| command_template = api.publish_mqtt_discovery_message.call_args.kwargs['command_template'] | ||
|
|
||
| assert options == [ | ||
| 'Charge from Grid', | ||
| 'Avoid Discharge', | ||
| 'Limit Battery Charge', | ||
| 'Discharge Allowed', | ||
| ] | ||
| assert "{% elif value == '8' %}Limit Battery Charge" in value_template | ||
| assert "{% elif value == 'Limit Battery Charge' %}8" in command_template | ||
|
|
||
|
|
||
| class TestPeakShavingEnabledApi: | ||
| """Regression test: peak_shaving/enabled must correctly parse the bytes payload.""" | ||
|
|
||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
send_mqtt_discovery_for_mode passes a list for
options, butpublish_mqtt_discovery_messagecurrently annotatesoptionsasstr(and treats it generically). To avoid confusion and improve static analysis, update theoptionsparameter type to a sequence/list of strings (orNone) and keep the formatting consistent (e.g., trailing comma / closing bracket on its own line).