mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-11 02:34:29 +05:00
add parameter for max modulation
This commit is contained in:
@@ -257,6 +257,28 @@ public:
|
||||
return publish(getTopic("number", "heating_hysteresis").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishNumberHeatingMaxModulation(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
doc[FPSTR(HA_UNIQUE_ID)] = devicePrefix + F("_heating_max_modulation");
|
||||
doc[FPSTR(HA_OBJECT_ID)] = devicePrefix + F("_heating_max_modulation");
|
||||
doc[FPSTR(HA_ENTITY_CATEGORY)] = F("config");
|
||||
doc[FPSTR(HA_DEVICE_CLASS)] = F("power_factor");
|
||||
doc[FPSTR(HA_UNIT_OF_MEASUREMENT)] = F("%");
|
||||
doc[FPSTR(HA_NAME)] = F("Max modulation");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:speedometer");
|
||||
doc[FPSTR(HA_STATE_TOPIC)] = devicePrefix + F("/settings");
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.maxModulation|int(1) }}");
|
||||
doc[FPSTR(HA_COMMAND_TOPIC)] = devicePrefix + F("/settings/set");
|
||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"heating\": {\"maxModulation\" : {{ value }}}}");
|
||||
doc[FPSTR(HA_MIN)] = 1;
|
||||
doc[FPSTR(HA_MAX)] = 100;
|
||||
doc[FPSTR(HA_STEP)] = 1;
|
||||
doc[FPSTR(HA_MODE)] = "box";
|
||||
|
||||
return publish(getTopic("number", "heating_max_modulation").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishSensorHeatingSetpoint(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = devicePrefix + F("/status");
|
||||
|
||||
@@ -27,6 +27,7 @@ protected:
|
||||
Log.sinfoln("MQTT", "Started");
|
||||
|
||||
client.setCallback(__callback);
|
||||
client.setBufferSize(1024);
|
||||
haHelper.setDevicePrefix(settings.mqtt.prefix);
|
||||
haHelper.setDeviceVersion(PROJECT_VERSION);
|
||||
haHelper.setDeviceModel(PROJECT_NAME);
|
||||
@@ -138,6 +139,13 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
if (!doc["heating"]["maxModulation"].isNull() && doc["heating"]["maxModulation"].is<unsigned char>()) {
|
||||
if (doc["heating"]["maxModulation"].as<unsigned char>() > 0 && doc["heating"]["maxModulation"].as<unsigned char>() <= 100) {
|
||||
settings.heating.maxModulation = doc["heating"]["maxModulation"].as<unsigned char>();
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!doc["heating"]["maxTemp"].isNull() && doc["heating"]["maxTemp"].is<unsigned char>()) {
|
||||
if (doc["heating"]["maxTemp"].as<unsigned char>() > 0 && doc["heating"]["maxTemp"].as<unsigned char>() <= 100 && doc["heating"]["maxTemp"].as<unsigned char>() > settings.heating.minTemp) {
|
||||
settings.heating.maxTemp = doc["heating"]["maxTemp"].as<unsigned char>();
|
||||
@@ -386,6 +394,7 @@ protected:
|
||||
haHelper.publishSwitchHeatingTurbo();
|
||||
//haHelper.publishNumberHeatingTarget(false);
|
||||
haHelper.publishNumberHeatingHysteresis();
|
||||
haHelper.publishNumberHeatingMaxModulation(false);
|
||||
haHelper.publishSensorHeatingSetpoint(false);
|
||||
haHelper.publishSensorCurrentHeatingMinTemp(false);
|
||||
haHelper.publishSensorCurrentHeatingMaxTemp(false);
|
||||
@@ -542,6 +551,7 @@ protected:
|
||||
doc["heating"]["turbo"] = settings.heating.turbo;
|
||||
doc["heating"]["target"] = settings.heating.target;
|
||||
doc["heating"]["hysteresis"] = settings.heating.hysteresis;
|
||||
doc["heating"]["maxModulation"] = settings.heating.maxModulation;
|
||||
doc["heating"]["minTemp"] = settings.heating.minTemp;
|
||||
doc["heating"]["maxTemp"] = settings.heating.maxTemp;
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ protected:
|
||||
vars.states.fault = ot->isFault(localResponse);
|
||||
vars.states.diagnostic = ot->isDiagnostic(localResponse);
|
||||
|
||||
setMaxModulationLevel(heatingEnabled ? 100 : 0);
|
||||
setMaxModulationLevel(heatingEnabled ? settings.heating.maxModulation : 0);
|
||||
yield();
|
||||
|
||||
// Команды чтения данных котла
|
||||
|
||||
@@ -32,6 +32,7 @@ struct Settings {
|
||||
bool turbo = false;
|
||||
float target = 40.0f;
|
||||
float hysteresis = 0.5f;
|
||||
byte maxModulation = 100;
|
||||
byte minTemp = 20.0f;
|
||||
byte maxTemp = 90.0f;
|
||||
} heating;
|
||||
|
||||
Reference in New Issue
Block a user