Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 2857798
Author: Boris Brock <[email protected]>
Date:   Mon Sep 23 20:50:47 2024 +0200

    Adding control topic

commit a5cd35f
Author: Boris Brock <[email protected]>
Date:   Mon Sep 23 20:35:05 2024 +0200

    Update README.md
  • Loading branch information
BorisBrock committed Sep 24, 2024
1 parent 0b42353 commit a4a026f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ The following topics are published by HeidelBridge:
| heidelbridge/charging_voltage/phase2 | V | Float | Momentary charging voltage on phase 2. |
| heidelbridge/charging_voltage/phase3 | V | Float | Momentary charging voltage on phase 3. |

The following topics are subscribed by HeidelBridge. Use these to control your wallbox:

| Topic | Unit | Data Type | Description |
| -------------------------------------------- | ---- | --------- | ----------------------------------------------------------------------- |
| heidelbridge/control/charging_current_limit | A | Float | Charging current limit in Ampere. |

---

# Contribution
Expand Down
13 changes: 12 additions & 1 deletion src/Components/MQTT/MQTTManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ namespace MQTTManager
IWallbox *gWallbox = nullptr;
uint8_t gCurValueIndex = 0;

// Topics
String ChargingCurrentControl = "heidelbridge/control/charging_current_limit";

constexpr uint16_t NumMqttPublishedValues = 7;
enum MqttPublishedValues
{
Expand Down Expand Up @@ -107,6 +110,9 @@ namespace MQTTManager
{
Serial.println("Connected to MQTT");

// Subscribe to control topics
gMqttClient.subscribe(ChargingCurrentControl.c_str(), 2);

// Publish version information
String versionString = String(Version::Major) + "." + String(Version::Minor) + "." + String(Version::Patch);
gMqttClient.publish("heidelbridge/version", 0, true, versionString.c_str());
Expand All @@ -120,7 +126,12 @@ namespace MQTTManager

void OnMqttMessage(char *topic, char *payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total)
{
// Ignore incoming messages for now
if (ChargingCurrentControl == topic)
{
float current = String(payload, len).toFloat();
Serial.printf("Received MQTT control command: charging current limit = %f\n", current);
gWallbox->SetChargingCurrentLimit(current);
}
}

void OnMqttPublish(uint16_t packetId)
Expand Down

0 comments on commit a4a026f

Please sign in to comment.