Skip to content

mqtt: polish published state values#353

Merged
MaStr merged 1 commit intoMaStr:mainfrom
filiplajszczak:mqtt-state-polish
Apr 27, 2026
Merged

mqtt: polish published state values#353
MaStr merged 1 commit intoMaStr:mainfrom
filiplajszczak:mqtt-state-polish

Conversation

@filiplajszczak
Copy link
Copy Markdown
Contributor

Publishes SoC with decimal precision, normalizes discharge-blocked state to lowercase booleans, fixes its HA discovery template, and avoids duplicate MQTT subscriptions on reconnect.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR polishes MQTT state publishing to better align with Home Assistant expectations and reconnect behavior in batcontrol’s MQTT integration.

Changes:

  • Publish SOC with decimal precision (2 decimals) instead of zero-padded integers.
  • Normalize discharge_blocked published payloads to lowercase (true/false) and fix its HA discovery value_template.
  • Fix reconnect subscription logic to avoid duplicate subscriptions, and add regression tests for these behaviors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/batcontrol/mqtt_api.py Fixes reconnect subscribe loop, improves SOC formatting, normalizes discharge_blocked payloads, and corrects HA discovery template logic.
tests/batcontrol/test_mqtt_api.py Adds tests covering reconnect subscription behavior and published state payload formatting / discovery template expectations.

Comment thread tests/batcontrol/test_mqtt_api.py
@MaStr MaStr merged commit 8f5960e into MaStr:main Apr 27, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants