mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
prep work for boiler MQTT HA Discovery
This commit is contained in:
@@ -64,6 +64,14 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
|
||||
register_mqtt_cmd(F("boilhystoff"), [&](const char * value, const int8_t id) { set_hyst_off(value, id); });
|
||||
register_mqtt_cmd(F("burnperiod"), [&](const char * value, const int8_t id) { set_burn_period(value, id); });
|
||||
register_mqtt_cmd(F("pumpdelay"), [&](const char * value, const int8_t id) { set_pump_delay(value, id); });
|
||||
|
||||
EMSESP::esp8266React.getMqttSettingsService()->read([&](MqttSettings & settings) {
|
||||
mqtt_format_ = settings.mqtt_format; // single, nested or ha
|
||||
|
||||
if (mqtt_format_ == MQTT_format::HA) {
|
||||
register_mqtt_ha_config();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// add submenu context
|
||||
@@ -77,6 +85,23 @@ void Boiler::add_context_menu() {
|
||||
});
|
||||
}
|
||||
|
||||
// create the config topic for Home Assistant MQTT Discovery
|
||||
// homeassistant/sensor/ems-esp/boiler
|
||||
// state is /state
|
||||
// config is /config
|
||||
void Boiler::register_mqtt_ha_config() {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
|
||||
|
||||
/*
|
||||
* not finished yet - see https://github.com/proddy/EMS-ESP/issues/288
|
||||
doc["name"] = "boiler";
|
||||
doc["uniq_id"] = "boiler";
|
||||
|
||||
// Mqtt::publish(topic); // empty payload, this remove any previous config sent to HA
|
||||
Mqtt::publish("homeassistant/sensor/ems-esp/boiler/config", doc, true); // publish the config payload with retain flag
|
||||
*/
|
||||
}
|
||||
|
||||
void Boiler::device_info(JsonArray & root) {
|
||||
JsonObject dataElement;
|
||||
|
||||
|
||||
@@ -48,8 +48,11 @@ class Boiler : public EMSdevice {
|
||||
static uuid::log::Logger logger_;
|
||||
|
||||
void console_commands(Shell & shell, unsigned int context);
|
||||
void register_mqtt_ha_config();
|
||||
void check_active();
|
||||
|
||||
uint8_t last_boilerState = 0xFF; // remember last state of heating and warm water on/off
|
||||
uint8_t mqtt_format_; // single, nested or ha
|
||||
|
||||
static constexpr uint8_t EMS_TYPE_UBAParameterWW = 0x33;
|
||||
static constexpr uint8_t EMS_TYPE_UBAFunctionTest = 0x1D;
|
||||
@@ -147,7 +150,6 @@ class Boiler : public EMSdevice {
|
||||
void process_UBAMonitorSlow(std::shared_ptr<const Telegram> telegram);
|
||||
void process_UBAMonitorSlowPlus(std::shared_ptr<const Telegram> telegram);
|
||||
void process_UBAMonitorSlowPlus2(std::shared_ptr<const Telegram> telegram);
|
||||
|
||||
void process_UBAOutdoorTemp(std::shared_ptr<const Telegram> telegram);
|
||||
void process_UBASetPoints(std::shared_ptr<const Telegram> telegram);
|
||||
void process_UBAFlags(std::shared_ptr<const Telegram> telegram);
|
||||
@@ -155,11 +157,8 @@ class Boiler : public EMSdevice {
|
||||
void process_UBAMaintenanceStatus(std::shared_ptr<const Telegram> telegram);
|
||||
void process_UBAMaintenanceData(std::shared_ptr<const Telegram> telegram);
|
||||
void process_UBAErrorMessage(std::shared_ptr<const Telegram> telegram);
|
||||
|
||||
void process_UBADHWStatus(std::shared_ptr<const Telegram> telegram);
|
||||
|
||||
void check_active();
|
||||
|
||||
// commands - none of these use the additional id parameter
|
||||
void set_warmwater_mode(const char * value, const int8_t id);
|
||||
void set_warmwater_activated(const char * value, const int8_t id);
|
||||
|
||||
Reference in New Issue
Block a user