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

Feature/mqtt on main #152

Merged
merged 25 commits into from
Feb 4, 2024
Merged

Feature/mqtt on main #152

merged 25 commits into from
Feb 4, 2024

Conversation

Cabooman
Copy link
Collaborator

@Cabooman Cabooman commented Feb 2, 2024

What

Addition of MQTT subscribe/publish functionality, using the popular Pubsub library, with general data publishing and other examples

Why

Because we're all Home Assistant junkies whether we admit it (to ourselves) or not ❤️
On a more serious note, this allows the publication of data in a common format that can be stored/supervised/visualized or used for various home automation purposes. It also allows control of battery emulator functionality from various home automation frameworks if implemented.

How

  • The PubSub library is added to the library stack.
  • Settings for MQTT are added
  • MQTT connection/initialization/loop/functions added

Global variables for data communication between inverter and battery are published every 5 s to the 'battery/info' topic (topic name can be changed to something better): SOC, SOH, MaxTemp, MinTemp, MaxCell, MinCell in JSON format, for example:

{
  "SOC": 68.500,
  "StateOfHealth": 92.000,
  "temperature_min": 5.600,
  "temperature_max": 7.200,
  "cell_max_voltage": 3812,
  "cell_min_voltage": 3782
}

Specific modules can publish whatever they want whenever they want to whatever topic they want. An example is included in
NISSAN-LEAF-BATTERY.cpp in the publish_data() function where 96 cell voltages are published every 5 seconds.

MQTT discovery for Home Assistant is available using the approach in NISSAN-LEAF-BATTERY.cpp. It's a bit more involved and is not necessary for Home Assistant integration, but it's really neat if done right

@Cabooman Cabooman requested a review from dalathegreat February 2, 2024 17:17
@Cabooman Cabooman self-assigned this Feb 2, 2024
@Cabooman Cabooman marked this pull request as ready for review February 2, 2024 17:39
@dalathegreat dalathegreat merged commit 1cfbed6 into main Feb 4, 2024
34 checks passed
@dalathegreat dalathegreat deleted the feature/mqtt-on-main branch February 21, 2024 20:28
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