Skip to content

Commit

Permalink
add marax/pump mqtt subject
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-heimbuch committed Feb 14, 2021
1 parent 074c840 commit 4cccda6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ The time is not recorded unless 12 seconds have passed because MaraX machine sta
If you connect the ESP to the wifi and provide a MQTT bridge the following messages will be broadcasted:

- `/marax/power` with `on` or `off`
- `/marax/pump` with `on` or `off`
- `/marax/hx` with the current temperature of the heat exchanger
- `/marax/steam` with the current temperature of the steam boiler
- `/marax/shot` with the duration of the last shot (if the shot took longer than 15 seconds)
Expand Down
4 changes: 2 additions & 2 deletions main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ char receivedChars[numChars];

void setup() {
Serial.begin(9600);
if (SSID && PSK && MQTT_BROKER) {
if (SSID != "" && PSK != "" && MQTT_BROKER != "") {
setupWifi();
} else {
WiFi.mode(WIFI_OFF);
Expand All @@ -65,7 +65,7 @@ void loop() {
updateTimer();
updateSerial();

if (SSID && PSK && MQTT_BROKER) {
if (SSID != "" && PSK != "" && MQTT_BROKER != "") {
updateWifi();
}
}
14 changes: 14 additions & 0 deletions main/wifi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ String lastMachineState;
int lastHxTemperature = NULL;
int lastSteamTemperature = NULL;
long lastTimerStartMillis = 0;
bool lastTimerStarted = false;

void setupWifi() {
WiFi.begin(SSID, PSK);
Expand Down Expand Up @@ -41,6 +42,11 @@ void updateWifi() {
lastTimerStartMillis = timerStartMillis;
broadcastShot();
}

if (lastTimerStarted != timerStarted) {
lastTimerStarted = timerStarted;
brodcastPump();
}
}

void broadcastMachineState() {
Expand All @@ -62,3 +68,11 @@ void broadcastSteamTemperature() {
void broadcastShot() {
client.publish("/marax/shot", String(timerCount).c_str());
}

void brodcastPump() {
if (timerStarted) {
client.publish("/marax/pump", "on");
} else {
client.publish("/marax/power", "off");
}
}

0 comments on commit 4cccda6

Please sign in to comment.