Skip to content
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

JK BMS Home Assistent Integration #640

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

schlimmchen
Copy link
Member

@schlimmchen schlimmchen commented Feb 5, 2024

This changeset adds the Home Assistent integration for the JK BMS and prepares the previous Pylontech-specific Home Assistent class implementation to handle all the different battery providers.

Sadly, the diff for src/MqttHandlePylontechHass.cpp became so large that GIT did not track that the file was actually renamed and then changed.

A fix is implemented that restores the Home Assistent integration for the Pylontech (and the general Battery Home Assistent integration), which is a regression from the TaskScheduler introduction.

@helgeerbe Please do NOT squash these commits when merging to preserve the intended changelog messages.

image

previously, the Pytlontech Home Assistent class implementation had an
init() method, that was never called, as it did nothing. the class
relied on its loop() method being called from the main loop(). after
switching to the TaskScheduler approach, the Pylontech Home Assistent
class init() method was adjusted to register a task that calls the
loop() method periodically. however, the init() method was still not
called.
* pylontech HA integration: remove unused method/variable

* make MqttHandlePylontechHassClass::publishConfig() private.
  there are no outside users of that method.

* rename to MqttHandleBatteryHass

* battery HA integration: merge methods and bring back forceUpdate().
  even though the forceUpdate() method was not in use before, it makes
  sense to implement it and use it when the battery config changes.
  rather than controlling a separate flag, it now changes the _doPublish
  flag of the class, which also triggers publishing the device config to
  Home Assistant when an MQTT connection problem was detected. since
  both situations are now handled similarly, we can merge the loop() and
  publishConfig() methods.

* battery: provider specific sensors for HA

* move Battery MQTT loop to BatteryStats
  the BatteryStats class should handle the MQTT publishing, including the
  interval. for the calculation of a reasonable Home Assistent expiration
  value this class now also knows the maximum publish interval.

* JK BMS: fix publishing values for Home Assistent
  Home Assistent values expire, because we set them to expire after three
  MQTT publish durations. for that reason, we need to re-publish all
  values after our self-inflicted full publish interval.

* define JK BMS sensors for Home Assistent

closes hoylabs#482.
@schlimmchen schlimmchen force-pushed the jkbms-home-assistent-pr branch from 2f15af4 to 1865113 Compare February 5, 2024 20:22
@schlimmchen
Copy link
Member Author

schlimmchen force-pushed the jkbms-home-assistent-pr branch from 2f15af4 to 1865113

I added closes #482 to the commit message.

@schlimmchen
Copy link
Member Author

From #482:
image

@schlimmchen
Copy link
Member Author

Also closes #633.

@helgeerbe helgeerbe merged commit df5b416 into hoylabs:development Feb 9, 2024
8 checks passed
@schlimmchen schlimmchen deleted the jkbms-home-assistent-pr branch February 10, 2024 19:52
Copy link

github-actions bot commented Apr 4, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants