Skip to content

Commit

Permalink
feat(fan): allow controlability of airduct and exhaust fan configurat…
Browse files Browse the repository at this point in the history
…ion (#44)
  • Loading branch information
tspopp authored Oct 24, 2024
1 parent ddb4888 commit a696336
Show file tree
Hide file tree
Showing 14 changed files with 377 additions and 148 deletions.
2 changes: 1 addition & 1 deletion AquaMQTT/include/Version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace aquamqtt
{
constexpr char VERSION[] = "v1.4.0";
constexpr char VERSION[] = "v1.4.1";
}
65 changes: 37 additions & 28 deletions AquaMQTT/include/message/HMIMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,71 +20,79 @@ class HMIMessage

void setWaterTempTarget(float targetTemperature);

HMIOperationMode operationMode();
HMIOperationMode operationMode() const;

void setOperationMode(HMIOperationMode operationMode);
void setOperationMode(HMIOperationMode operationMode) const;

HMIOperationType getOperationType();
HMIOperationType getOperationType() const;

void setOperationType(HMIOperationType operationType);
void setOperationType(HMIOperationType operationType) const;

bool isEmergencyModeEnabled();
bool isEmergencyModeEnabled() const;

void setEmergencyMode(bool enabled);
void setEmergencyMode(bool enabled) const;

bool isHeatingElementEnabled();
bool isHeatingElementEnabled() const;

void enableHeatingElement(bool enabled);
void enableHeatingElement(bool enabled) const;

bool isPVInputActivated();
bool isPVInputActivated() const;

HMISetup setupMode();
HMISetup setupMode() const;

uint8_t antiLegionellaModePerMonth();
uint8_t antiLegionellaModePerMonth() const;

void setAntiLegionellaModePerMonth(uint8_t value);

HMIAirDuctConfig airDuctConfig();
HMIAirDuctConfig airDuctConfig() const;

void setAirDuctConfig(HMIAirDuctConfig config) const;

HMIInstallation installationMode();

HMIFanExhaust fanExhaust() const;

void setFanExhaustMode(HMIFanExhaust mode) const;

bool exhaustFanChanged() const;

HMITestMode testMode();

void timerWindowStr(bool firstWindow, char* buffer);

void setTimeWindowByStr(bool firstWindow, char* buffer, uint8_t length);

uint16_t timerWindowAStart();
uint16_t timerWindowAStart() const;

uint16_t timerWindowALength();
uint16_t timerWindowALength() const;

uint16_t timerWindowBStart();
uint16_t timerWindowBStart() const;

uint16_t timerWindowBLength();
uint16_t timerWindowBLength() const;

uint8_t timeHours();
uint8_t timeHours() const;

void setTimeHours(uint8_t hour);
void setTimeHours(uint8_t hour) const;

uint8_t timeMinutes();
uint8_t timeMinutes() const;

void setTimeMinutes(uint8_t minute);
void setTimeMinutes(uint8_t minute) const;

uint8_t timeSeconds();
uint8_t timeSeconds() const;

void setTimeSeconds(uint8_t second);
void setTimeSeconds(uint8_t second) const;

uint16_t dateYear();
uint16_t dateYear() const;

void setDateMonthAndYear(uint8_t month, uint16_t year);
void setDateMonthAndYear(uint8_t month, uint16_t year) const;

uint8_t dateMonth();
uint8_t dateMonth() const;

uint8_t dateDay();
uint8_t dateDay() const;

void setDateDay(uint8_t day);
void setDateDay(uint8_t day) const;

void setInstallationMode(HMIInstallation mode);
void setInstallationMode(HMIInstallation mode) const;

bool waterTempTargetChanged() const;

Expand Down Expand Up @@ -129,6 +137,7 @@ class HMIMessage
bool mDateChanged;
bool mTestModeChanged;
bool mErrorRequestChanged;
bool mExhaustFanChanged;

uint8_t* mData;
};
Expand Down
23 changes: 23 additions & 0 deletions AquaMQTT/include/message/MessageConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,29 @@ static const char* testModeStr(HMITestMode config)
}
}

enum HMIFanExhaust
{
EXHAUST_UNKNOWN = -1,
EXHAUST_STOP = 0,
EXHAUST_LOW_SPEED = 1,
EXHAUST_HIGH_SPEED = 2
};

static const char* exhaustModeStr(HMIFanExhaust mode)
{
switch (mode)
{
case EXHAUST_STOP:
return reinterpret_cast<const char*>(mqtt::ENUM_CONFIG_EXHAUST_FAN_STOP);
case EXHAUST_LOW_SPEED:
return reinterpret_cast<const char*>(mqtt::ENUM_CONFIG_EXHAUST_FAN_LOW_SPEED);
case EXHAUST_HIGH_SPEED:
return reinterpret_cast<const char*>(mqtt::ENUM_CONFIG_EXHAUST_FAN_HIGH_SPEED);
default:
return reinterpret_cast<const char*>(mqtt::ENUM_UNKNOWN);
}
}

enum HMIInstallation
{
INST_HP_UNKNOWN = -1,
Expand Down
8 changes: 8 additions & 0 deletions AquaMQTT/include/mqtt/IMQTTCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace mqtt
class IMQTTCallback
{
public:
virtual ~IMQTTCallback() = default;

// $prefix/aquamqtt/ctrl/operationMode + ENUM_OPERATION_MODE
virtual void onOperationModeChanged(std::unique_ptr<message::HMIOperationMode> value) = 0;

Expand All @@ -28,6 +30,12 @@ class IMQTTCallback
// $prefix/aquamqtt/ctrl/configInstallation + ENUM INSTALLATION
virtual void onInstallationModeChanged(std::unique_ptr<message::HMIInstallation> mode) = 0;

// $prefix/aquamqtt/configFanExhaust + ENUM FAN EXHAUST
virtual void onFanExhaustModeChanged(std::unique_ptr<message::HMIFanExhaust> mode) = 0;

// $prefix/aquamqtt/configAirduct
virtual void onAirductConfigChanged(std::unique_ptr<message::HMIAirDuctConfig> config) = 0;

// $prefic/aquamqtt/ctrl/flagPVModeHeatPump + bool
virtual void onPVModeHeatpumpEnabled(bool enabled) = 0;

Expand Down
5 changes: 5 additions & 0 deletions AquaMQTT/include/mqtt/MQTTDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ constexpr char ENUM_INSTALLATION_BOILER_BACKUP_EXT_OPT[] = { "BOILER BACKUP / B
constexpr char ENUM_INSTALLATION_BOILER_BACKUP_EXT_PRIO[] = { "BOILER BACKUP / BOILER PRIORITY" };
constexpr char ENUM_INSTALLATION_SOLAR_BACKUP[] = { "HEAT PUMP AND SOLAR BACKUP" };

constexpr char ENUM_CONFIG_EXHAUST_FAN_STOP[] = { "STOP" };
constexpr char ENUM_CONFIG_EXHAUST_FAN_LOW_SPEED[] = { "LOW SPEED" };
constexpr char ENUM_CONFIG_EXHAUST_FAN_HIGH_SPEED[] = { "HIGH SPEED" };

constexpr char ENUM_TEST_MODE_OFF[] = { "OFF" };
constexpr char ENUM_TEST_MODE_IDLE[] = { "IDLE" };
constexpr char ENUM_TEST_MODE_ACTIVE_HEAT_PUMP[] = { "TESTING HEAT PUMP" };
Expand Down Expand Up @@ -108,6 +112,7 @@ constexpr char HMI_LEGIONELLA[] = { "antiLegionellaPerMonth" };
constexpr char HMI_TIMER_WINDOW_A[] = { "timerWindowA" };
constexpr char HMI_TIMER_WINDOW_B[] = { "timerWindowB" };
constexpr char HMI_AIR_DUCT_CONFIG[] = { "configAirduct" };
constexpr char HMI_FAN_EXHAUST_CONFIG[] = { "configFanExhaust" };
constexpr char HMI_INSTALLATION_CONFIG[] = { "configInstallation" };
constexpr char HMI_TEST_MODE[] = { "testModeStatus" };
constexpr char HMI_SETUP_STATE[] = { "setupState" };
Expand Down
56 changes: 49 additions & 7 deletions AquaMQTT/include/mqtt/MQTTDiscovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum class MQTT_ITEM_SENSOR
HMI_LEGIONELLA,
HMI_TIMER_WINDOW_A,
HMI_TIMER_WINDOW_B,
HMI_AIR_DUCT_CONFIG,
HMI_AIR_DUCT_CONFIG_DEPRECATED,
HMI_TEST_MODE,
HMI_SETUP_STATE,
HMI_PV_INPUT_ACTIVATED,
Expand Down Expand Up @@ -88,6 +88,8 @@ enum class MQTT_ITEM_BINARY_SENSOR
MAIN_CAPABILITY_PV_INPUT,
MAIN_CAPABILITY_EXT_COMM,
MAIN_CAPABILITY_DRY_HEATING,
STATS_ACTIVE_OVERRIDE_HMI_FAN_EXHAUST_CONFIG,
STATS_ACTIVE_OVERRIDE_HMI_AIRDUCT_CONFIG,
RESERVED_COUNT
};

Expand Down Expand Up @@ -117,6 +119,8 @@ enum class MQTT_ITEM_SELECT
HMI_OPERATION_MODE,
HMI_OPERATION_TYPE,
HMI_INSTALLATION_CONFIG,
HMI_FAN_EXHAUST_CONFIG,
HMI_AIR_DUCT_CONFIG,
RESERVED_COUNT
};

Expand Down Expand Up @@ -482,12 +486,8 @@ static bool buildConfiguration(uint8_t* buffer, uint16_t identifier, MQTT_ITEM_S
doc["uniq_id"] = make_unique(temp, identifier, "hmi_setup");
doc["ic"] = "mdi:tablet-dashboard";
break;
case MQTT_ITEM_SENSOR::HMI_AIR_DUCT_CONFIG:
doc["name"] = "AirDuct Configuration";
doc["stat_t"] = "~/hmi/configAirduct";
doc["uniq_id"] = make_unique(temp, identifier, "hmi_airduct_cfg");
doc["ic"] = "mdi:sign-direction";
break;
case MQTT_ITEM_SENSOR::HMI_AIR_DUCT_CONFIG_DEPRECATED:
return false;
case MQTT_ITEM_SENSOR::STATS_AQUAMQTT_MODE:
doc["name"] = "AquaMQTT Mode";
doc["stat_t"] = "~/stats/aquamqttMode";
Expand Down Expand Up @@ -699,6 +699,26 @@ static bool buildConfiguration(uint8_t* buffer, uint16_t identifier, MQTT_ITEM_B
doc["pl_off"] = "0";
doc["ent_cat"] = "diagnostic";
break;
case MQTT_ITEM_BINARY_SENSOR::STATS_ACTIVE_OVERRIDE_HMI_FAN_EXHAUST_CONFIG:
doc["name"] = "Active Override Configuration Fan Exhaust";
doc["stat_t"] = "~/stats/activeOverrides";
doc["val_tpl"] = "{{ value_json.configFanExhaust }}";
doc["ic"] = "mdi:debug-step-over";
doc["uniq_id"] = make_unique(temp, identifier, "main_state_override_fan_exh_cfg");
doc["pl_on"] = "1";
doc["pl_off"] = "0";
doc["ent_cat"] = "diagnostic";
break;
case MQTT_ITEM_BINARY_SENSOR::STATS_ACTIVE_OVERRIDE_HMI_AIRDUCT_CONFIG:
doc["name"] = "Active Override Configuration Air Duct";
doc["stat_t"] = "~/stats/activeOverrides";
doc["val_tpl"] = "{{ value_json.configAirduct }}";
doc["ic"] = "mdi:debug-step-over";
doc["uniq_id"] = make_unique(temp, identifier, "main_state_override_airduct_cfg");
doc["pl_on"] = "1";
doc["pl_off"] = "0";
doc["ent_cat"] = "diagnostic";
break;
case MQTT_ITEM_BINARY_SENSOR::STATS_ACTIVE_OVERRIDE_HMI_TIME_DATE:
doc["name"] = "Active Override Time/Date";
doc["stat_t"] = "~/stats/activeOverrides";
Expand Down Expand Up @@ -876,6 +896,28 @@ static bool buildConfiguration(uint8_t* buffer, uint16_t identifier, MQTT_ITEM_S
doc["ops"][4] = mqtt::ENUM_INSTALLATION_THERMODYNAMICS_ONLY;
doc["ops"][5] = mqtt::ENUM_INSTALLATION_SOLAR_BACKUP;
break;
case MQTT_ITEM_SELECT::HMI_FAN_EXHAUST_CONFIG:
doc["name"] = "Fan Exhaust Configuration";
doc["ent_cat"] = "config";
doc["uniq_id"] = make_unique(temp, identifier, "hmi_fanExhaustConfig");
doc["stat_t"] = "~/hmi/configFanExhaust";
doc["cmd_t"] = "~/ctrl/configFanExhaust";
doc["ic"] = "mdi:fan";
doc["ops"][0] = mqtt::ENUM_CONFIG_EXHAUST_FAN_STOP;
doc["ops"][1] = mqtt::ENUM_CONFIG_EXHAUST_FAN_LOW_SPEED;
doc["ops"][2] = mqtt::ENUM_CONFIG_EXHAUST_FAN_HIGH_SPEED;
break;
case MQTT_ITEM_SELECT::HMI_AIR_DUCT_CONFIG:
doc["name"] = "AirDuct Configuration";
doc["ent_cat"] = "config";
doc["uniq_id"] = make_unique(temp, identifier, "hmi_airduct_cfg_sel");
doc["stat_t"] = "~/hmi/configAirduct";
doc["cmd_t"] = "~/ctrl/configAirduct";
doc["ic"] = "mdi:sign-direction";
doc["ops"][0] = mqtt::ENUM_AIR_DUCT_IN_IN;
doc["ops"][1] = mqtt::ENUM_AIR_DUCT_INT_EXT;
doc["ops"][2] = mqtt::ENUM_AIR_DUCT_EXT_EXT;
break;
case MQTT_ITEM_SELECT::RESERVED_COUNT:
default:
return false;
Expand Down
10 changes: 9 additions & 1 deletion AquaMQTT/include/state/HMIStateProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct AquaMqttOverrides
bool heatingElementEnabled;
bool emergencyModeEnabled;
bool installationMode;
bool exhaustFanMode;
bool airductConfig;
};

enum AquaMqttOverrideMode
Expand Down Expand Up @@ -54,7 +56,7 @@ class HMIStateProxy : public mqtt::IMQTTCallback
public:
static HMIStateProxy& getInstance();

virtual ~HMIStateProxy() = default;
~HMIStateProxy() override = default;

HMIStateProxy(const HMIStateProxy&) = delete;

Expand Down Expand Up @@ -82,6 +84,10 @@ class HMIStateProxy : public mqtt::IMQTTCallback

void onEmergencyModeEnabledChanged(std::unique_ptr<bool> enabled) override;

void onFanExhaustModeChanged(std::unique_ptr<message::HMIFanExhaust> mode) override;

void onAirductConfigChanged(std::unique_ptr<message::HMIAirDuctConfig> config) override;

void onPVModeHeatpumpEnabled(bool enabled) override;

bool isPVModeHeatPumpEnabled();
Expand Down Expand Up @@ -116,6 +122,8 @@ class HMIStateProxy : public mqtt::IMQTTCallback
std::unique_ptr<message::HMIOperationType> mOperationType;
std::unique_ptr<message::HMIOperationMode> mOperationMode;
std::unique_ptr<message::HMIInstallation> mInstallationMode;
std::unique_ptr<message::HMIFanExhaust> mFanExhaustMode;
std::unique_ptr<message::HMIAirDuctConfig> mAirductConfig;
std::unique_ptr<bool> mEmergencyModeEnabled;
std::unique_ptr<bool> mHeatingElementEnabled;
bool mPVModeHeatPump;
Expand Down
4 changes: 4 additions & 0 deletions AquaMQTT/include/state/MainStateProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class MainStateProxy : public mqtt::IMQTTCallback

void onPVModeHeatElementEnabled(bool enabled) override;

void onFanExhaustModeChanged(std::unique_ptr<message::HMIFanExhaust> mode) override;

void onAirductConfigChanged(std::unique_ptr<message::HMIAirDuctConfig> config) override;

void onResetOverrides() override;

AquaMqttMainOverrides getOverrides();
Expand Down
Loading

0 comments on commit a696336

Please sign in to comment.