mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-11 02:34:29 +05:00
added DHW flow rate from OT
This commit is contained in:
@@ -940,6 +940,23 @@ public:
|
||||
return publish(getTopic("sensor", "pressure").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishSensorDhwFlowRate(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1024> doc;
|
||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = devicePrefix + F("/status");
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
doc[FPSTR(HA_UNIQUE_ID)] = devicePrefix + F("_dhw_flow_rate");
|
||||
doc[FPSTR(HA_OBJECT_ID)] = devicePrefix + F("_dhw_flow_rate");
|
||||
doc[FPSTR(HA_ENTITY_CATEGORY)] = F("diagnostic");
|
||||
doc[FPSTR(HA_STATE_CLASS)] = F("measurement");
|
||||
doc[FPSTR(HA_UNIT_OF_MEASUREMENT)] = F("L/min");
|
||||
doc[FPSTR(HA_NAME)] = F("DHW flow rate");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:water-pump");
|
||||
doc[FPSTR(HA_STATE_TOPIC)] = devicePrefix + F("/state");
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.sensors.dhwFlowRate|float(0)|round(2) }}");
|
||||
|
||||
return publish(getTopic("sensor", "dhw_flow_rate").c_str(), doc);
|
||||
}
|
||||
|
||||
|
||||
bool publishNumberIndoorTemp(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
@@ -1234,6 +1251,10 @@ public:
|
||||
return publish(getTopic("number", "dhw_target").c_str());
|
||||
}
|
||||
|
||||
bool deleteSensorDhwFlowRate() {
|
||||
return publish(getTopic("sensor", "dhw_flow_rate").c_str());
|
||||
}
|
||||
|
||||
bool deleteClimateDHW() {
|
||||
return publish(getTopic("climate", "dhw", "_").c_str());
|
||||
}
|
||||
|
||||
@@ -467,6 +467,7 @@ protected:
|
||||
haHelper.publishNumberDHWMaxTemp(false);
|
||||
haHelper.publishBinSensorDHW();
|
||||
haHelper.publishSensorDHWTemp();
|
||||
haHelper.publishSensorDhwFlowRate(false);
|
||||
|
||||
} else {
|
||||
haHelper.deleteSwitchDHW();
|
||||
@@ -478,6 +479,7 @@ protected:
|
||||
haHelper.deleteSensorDHWTemp();
|
||||
haHelper.deleteNumberDHWTarget();
|
||||
haHelper.deleteClimateDHW();
|
||||
haHelper.deleteSensorDhwFlowRate();
|
||||
}
|
||||
|
||||
published = true;
|
||||
@@ -601,6 +603,7 @@ protected:
|
||||
|
||||
doc["sensors"]["modulation"] = vars.sensors.modulation;
|
||||
doc["sensors"]["pressure"] = vars.sensors.pressure;
|
||||
doc["sensors"]["dhwFlowRate"] = vars.sensors.dhwFlowRate;
|
||||
|
||||
doc["temperatures"]["indoor"] = vars.temperatures.indoor;
|
||||
doc["temperatures"]["outdoor"] = vars.temperatures.outdoor;
|
||||
|
||||
@@ -57,7 +57,7 @@ protected:
|
||||
bool heatingCh2Enabled = settings.opentherm.heatingCh2Enabled;
|
||||
if (settings.opentherm.heatingCh1ToCh2) {
|
||||
heatingCh2Enabled = heatingEnabled;
|
||||
|
||||
|
||||
} else if (settings.opentherm.dhwToCh2) {
|
||||
heatingCh2Enabled = settings.opentherm.dhwPresent && settings.dhw.enable;
|
||||
}
|
||||
@@ -180,8 +180,10 @@ protected:
|
||||
|
||||
if (settings.opentherm.dhwPresent) {
|
||||
updateDHWTemp();
|
||||
updateDHWFlowRate();
|
||||
} else {
|
||||
vars.temperatures.dhw = 0;
|
||||
vars.sensors.dhwFlowRate = 0.0f;
|
||||
}
|
||||
|
||||
updateHeatingTemp();
|
||||
@@ -509,6 +511,16 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool updateDHWFlowRate() {
|
||||
unsigned long response = ot->sendRequest(ot->buildRequest(OpenThermMessageType::READ, OpenThermMessageID::DHWFlowRate, 0));
|
||||
if (!ot->isValidResponse(response)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vars.sensors.dhwFlowRate = ot->getFloat(response);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool updateFaultCode() {
|
||||
unsigned long response = ot->sendRequest(ot->buildRequest(OpenThermRequestType::READ, OpenThermMessageID::ASFflags, 0));
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ struct Variables {
|
||||
struct {
|
||||
float modulation = 0.0f;
|
||||
float pressure = 0.0f;
|
||||
float dhwFlowRate = 0.0f;
|
||||
} sensors;
|
||||
|
||||
struct {
|
||||
|
||||
Reference in New Issue
Block a user