Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a1b56b2
HomeKit plugin extension with a choice between two integrations
modsmthng Dec 16, 2025
b0bed35
Update Settings.cpp
modsmthng Dec 17, 2025
8567e3a
Update Settings.cpp
modsmthng Dec 17, 2025
9652500
Update index.jsx
modsmthng Dec 17, 2025
97b9fe3
Fix race condition using std::atomic and correct event listener
modsmthng Dec 17, 2025
dee3302
Merge branch 'master' of https://github.com/modsmthng/gaggimate
modsmthng Dec 17, 2025
c1644ea
Update HomekitBridgePlugin.h
modsmthng Dec 17, 2025
45085f9
Update HomekitBridgePlugin.cpp
modsmthng Dec 18, 2025
b0ccd84
Update Settings.cpp
modsmthng Dec 18, 2025
5f1942d
Repaired and thread-safe synchronization of the switch and sensor. Th…
modsmthng Dec 19, 2025
19c931d
Homekit migration note added, troubleshooting section unified in a dr…
modsmthng Dec 19, 2025
2563b2d
Troubleshooting section updated
modsmthng Dec 22, 2025
f5bc382
Formatting error fixed
modsmthng Dec 22, 2025
0654d30
Added settings to toggle devices in Bridge Mode independently, refine…
modsmthng Jan 6, 2026
40b35b9
Merge branch 'master' into master
modsmthng Jan 6, 2026
ab9774a
fix(webui)
modsmthng Jan 11, 2026
e8b36da
Merge branch 'master' of https://github.com/modsmthng/gaggimate
modsmthng Jan 11, 2026
42a8e0f
Merge branch 'master' into master
modsmthng Jan 19, 2026
8038ba9
Merge branch 'master' into master
modsmthng Jan 24, 2026
4d75a44
Fix: double-creating DefaultUI
modsmthng Jan 24, 2026
9c95980
Merge branch 'master' into master
modsmthng Jan 25, 2026
c0916ab
Merge branch 'master' into master
modsmthng Jan 25, 2026
b1fe72e
Merge branch 'master' into master
modsmthng Feb 4, 2026
6c727d7
Merge branch 'master' into master
modsmthng Feb 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/display/core/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <display/plugins/AutoWakeupPlugin.h>
#include <display/plugins/BLEScalePlugin.h>
#include <display/plugins/BoilerFillPlugin.h>
#include <display/plugins/HomekitPlugin.h>
#include <display/plugins/HomekitThermostatPlugin.h>
#include <display/plugins/HomekitBridgePlugin.h>
#include <display/plugins/LedControlPlugin.h>
#include <display/plugins/MQTTPlugin.h>
#include <display/plugins/ShotHistoryPlugin.h>
Expand Down Expand Up @@ -43,7 +44,6 @@ void Controller::setup() {

pluginManager = new PluginManager();
#ifndef GAGGIMATE_HEADLESS
ui = new DefaultUI(this, driver, pluginManager);
if (driver->supportsSDCard() && driver->installSDCard()) {
sdcard = true;
ESP_LOGI(LOG_TAG, "SD Card detected and mounted");
Expand All @@ -56,10 +56,20 @@ void Controller::setup() {
}
profileManager = new ProfileManager(fs, "/p", settings, pluginManager);
profileManager->setup();
if (settings.isHomekit())
pluginManager->registerPlugin(new HomekitPlugin(settings.getWifiSsid(), settings.getWifiPassword()));
else
#ifndef GAGGIMATE_HEADLESS
ui = new DefaultUI(this, driver, pluginManager);
#endif

// HomeKit Mode Selection
if (settings.getHomekitMode() == HOMEKIT_MODE_THERMOSTAT) {
pluginManager->registerPlugin(new HomekitThermostatPlugin(settings.getWifiSsid(), settings.getWifiPassword()));
pluginManager->registerPlugin(new mDNSPlugin());
} else if (settings.getHomekitMode() == HOMEKIT_MODE_BRIDGE) {
pluginManager->registerPlugin(new HomekitBridgePlugin(settings.getWifiSsid(), settings.getWifiPassword()));
} else {
pluginManager->registerPlugin(new mDNSPlugin());
}

if (settings.isBoilerFillActive()) {
pluginManager->registerPlugin(new BoilerFillPlugin());
}
Expand Down Expand Up @@ -778,4 +788,4 @@ void Controller::loopTask(void *arg) {
controller->loopControl();
xTaskDelayUntil(&lastWake, pdMS_TO_TICKS(controller->getMode() == MODE_STANDBY ? 1000 : 100));
}
}
}
68 changes: 63 additions & 5 deletions src/display/core/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,35 @@

#include <algorithm>
#include <utility>
#include <esp32-hal-log.h>

Settings::Settings() {
// Phase 1: HomeKit Migration (Read-Write Mode)
preferences.begin(PREFERENCES_KEY, false);

// Check if the old boolean key "hk" exists
if (preferences.isKey("hk")) {
ESP_LOGW("Settings", "Migrating old HomeKit bool setting 'hk' to new int setting 'hkm'.");
bool old_homekit_bool = preferences.getBool("hk", false);

// Map old boolean to new integer modes
if (old_homekit_bool) {
homekitMode = HOMEKIT_MODE_THERMOSTAT;
} else {
homekitMode = HOMEKIT_MODE_DISABLED;
}

// Save the new mode and remove the obsolete boolean key
preferences.putInt("hkm", homekitMode);
preferences.remove("hk");
ESP_LOGI("Settings", "HomeKit migration complete. New mode: %d", homekitMode);
} else {
// If no old key exists, just load the current mode or default to disabled
homekitMode = preferences.getInt("hkm", HOMEKIT_MODE_DISABLED);
}
preferences.end(); // Close write access

// Phase 2: Standard Initialization (Read-Only Mode)
preferences.begin(PREFERENCES_KEY, true);
startupMode = preferences.getInt("sm", MODE_STANDBY);
targetBrewTemp = preferences.getInt("tb", 90);
Expand All @@ -23,7 +50,11 @@ Settings::Settings() {
wifiSsid = preferences.getString("ws", "");
wifiPassword = preferences.getString("wp", "");
mdnsName = preferences.getString("mn", DEFAULT_MDNS_NAME);
homekit = preferences.getBool("hk", false);
//homekitMode = preferences.getInt("hkm", HOMEKIT_MODE_DISABLED); // homekitMode handled at start
// Load new HomeKit sub-device toggles (default true)
hkPowerEnabled = preferences.getBool("hk_pe", true);
hkSteamEnabled = preferences.getBool("hk_se", true);
hkSensorEnabled = preferences.getBool("hk_he", true);
volumetricTarget = preferences.getBool("vt", false);
otaChannel = preferences.getString("oc", DEFAULT_OTA_CHANNEL);
infusePumpTime = preferences.getInt("ipt", 0);
Expand Down Expand Up @@ -240,8 +271,29 @@ void Settings::setMdnsName(const String &mdnsName) {
save();
}

void Settings::setHomekit(const bool homekit) {
this->homekit = homekit;
// Homekit mode
void Settings::setHomekitMode(const int mode) {
int clampedMode = std::clamp(mode, (int)HOMEKIT_MODE_DISABLED, (int)HOMEKIT_MODE_BRIDGE);
// check save
if (this->homekitMode != clampedMode) {
this->homekitMode = clampedMode;
save();
}
}

// HomeKit Device Setters
void Settings::setHkPowerEnabled(bool enabled) {
hkPowerEnabled = enabled;
save();
}

void Settings::setHkSteamEnabled(bool enabled) {
hkSteamEnabled = enabled;
save();
}

void Settings::setHkSensorEnabled(bool enabled) {
hkSensorEnabled = enabled;
save();
}

Expand Down Expand Up @@ -485,7 +537,13 @@ void Settings::doSave() {
preferences.putString("ws", wifiSsid);
preferences.putString("wp", wifiPassword);
preferences.putString("mn", mdnsName);
preferences.putBool("hk", homekit);
preferences.putInt("hkm", homekitMode);

// Save new HomeKit toggles
preferences.putBool("hk_pe", hkPowerEnabled);
preferences.putBool("hk_se", hkSteamEnabled);
preferences.putBool("hk_he", hkSensorEnabled);

preferences.putBool("vt", volumetricTarget);
preferences.putString("oc", otaChannel);
preferences.putInt("ipt", infusePumpTime);
Expand Down Expand Up @@ -558,4 +616,4 @@ void Settings::loopTask(void *arg) {
settings->doSave();
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}
}
27 changes: 23 additions & 4 deletions src/display/core/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

#define PREFERENCES_KEY "controller"

enum HomeKitMode {
HOMEKIT_MODE_DISABLED = 0, // Default, HomeKit disabled
HOMEKIT_MODE_THERMOSTAT = 1, // Thermostat
HOMEKIT_MODE_BRIDGE = 2 // Bridge
};

struct AutoWakeupSchedule {
String time; // HH:MM format
bool days[7]; // [Mon, Tue, Wed, Thu, Fri, Sat, Sun]
Expand Down Expand Up @@ -76,7 +82,11 @@ class Settings {
String getWifiSsid() const { return wifiSsid; }
String getWifiPassword() const { return wifiPassword; }
String getMdnsName() const { return mdnsName; }
bool isHomekit() const { return homekit; }
// HomeKit Settings
int getHomekitMode() const { return homekitMode; }
bool isHkPowerEnabled() const { return hkPowerEnabled; }
bool isHkSteamEnabled() const { return hkSteamEnabled; }
bool isHkSensorEnabled() const { return hkSensorEnabled; }
bool isVolumetricTarget() const { return volumetricTarget; }
String getOTAChannel() const { return otaChannel; }
String getSavedScale() const { return savedScale; }
Expand Down Expand Up @@ -139,7 +149,12 @@ class Settings {
void setWifiSsid(const String &wifiSsid);
void setWifiPassword(const String &wifiPassword);
void setMdnsName(const String &mdnsName);
void setHomekit(bool homekit);
// HomeKit Setters
void setHomekitMode(int homekitMode);
void setHkPowerEnabled(bool enabled);
void setHkSteamEnabled(bool enabled);
void setHkSensorEnabled(bool enabled);
bool isHomekitEnabled() const { return homekitMode != HOMEKIT_MODE_DISABLED; }
void setVolumetricTarget(bool volumetric_target);
void setOTAChannel(const String &otaChannel);
void setSavedScale(const String &savedScale);
Expand Down Expand Up @@ -208,7 +223,11 @@ class Settings {
String wifiPassword = "";
String mdnsName = DEFAULT_MDNS_NAME;
String savedScale = "";
bool homekit = false;
// HomeKit Variables
int homekitMode = HOMEKIT_MODE_DISABLED;
bool hkPowerEnabled = true;
bool hkSteamEnabled = true;
bool hkSensorEnabled = true;
bool volumetricTarget = false;
bool boilerFillActive = false;
int startupFillTime = 0;
Expand Down Expand Up @@ -263,4 +282,4 @@ class Settings {
static void loopTask(void *arg);
};

#endif // SETTINGS_H
#endif // SETTINGS_H
Loading