mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-28 11:03:36 +05:00
Compare commits
3 Commits
b91266063b
...
640935a2b7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
640935a2b7 | ||
|
|
c0c631aab4 | ||
|
|
861db33765 |
@@ -223,6 +223,7 @@ public:
|
|||||||
|
|
||||||
} else if (sSensor.type == Sensors::Type::MANUAL) {
|
} else if (sSensor.type == Sensors::Type::MANUAL) {
|
||||||
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
|
doc[FPSTR(HA_ENTITY_CATEGORY)] = FPSTR(HA_ENTITY_CATEGORY_CONFIG);
|
||||||
|
doc[FPSTR(HA_STEP)] = 0.01f;
|
||||||
doc[FPSTR(HA_MODE)] = FPSTR(HA_MODE_BOX);
|
doc[FPSTR(HA_MODE)] = FPSTR(HA_MODE_BOX);
|
||||||
|
|
||||||
doc[FPSTR(HA_COMMAND_TOPIC)] = this->getDeviceTopic(
|
doc[FPSTR(HA_COMMAND_TOPIC)] = this->getDeviceTopic(
|
||||||
|
|||||||
@@ -454,20 +454,16 @@ protected:
|
|||||||
Sensors::getAmountByType(Sensors::Type::OT_MODULATION_LEVEL) ||
|
Sensors::getAmountByType(Sensors::Type::OT_MODULATION_LEVEL) ||
|
||||||
Sensors::getAmountByType(Sensors::Type::OT_CURRENT_POWER)
|
Sensors::getAmountByType(Sensors::Type::OT_CURRENT_POWER)
|
||||||
) {
|
) {
|
||||||
float power = 0.0f;
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
if (vars.slave.flame) {
|
if (vars.slave.flame) {
|
||||||
result = this->updateModulationLevel();
|
if (this->updateModulationLevel()) {
|
||||||
|
float power = 0.0f;
|
||||||
if (result) {
|
if (vars.slave.modulation.current > 0 && settings.opentherm.maxPower > 0.1f) {
|
||||||
if (settings.opentherm.maxPower > 0.1f) {
|
|
||||||
float modulatedPower = settings.opentherm.maxPower - settings.opentherm.minPower;
|
float modulatedPower = settings.opentherm.maxPower - settings.opentherm.minPower;
|
||||||
power = settings.opentherm.minPower + (modulatedPower / 100.0f * vars.slave.modulation.current);
|
power = settings.opentherm.minPower + (modulatedPower / 100.0f * vars.slave.modulation.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.snoticeln(
|
Log.snoticeln(
|
||||||
FPSTR(L_OT), F("Received modulation level: %.2f%%, power: %.2f of %.2f kW (min: %.2f kW)"),
|
FPSTR(L_OT), F("Received modulation level: %hhu%%, power: %.2f of %.2f kW (min: %.2f kW)"),
|
||||||
vars.slave.modulation.current, power, settings.opentherm.maxPower, settings.opentherm.minPower
|
vars.slave.modulation.current, power, settings.opentherm.maxPower, settings.opentherm.minPower
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -487,123 +483,101 @@ protected:
|
|||||||
Log.swarningln(FPSTR(L_OT), F("Failed receive modulation level"));
|
Log.swarningln(FPSTR(L_OT), F("Failed receive modulation level"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (vars.slave.modulation.current > 0) {
|
} else {
|
||||||
vars.slave.modulation.current = 0;
|
vars.slave.modulation.current = 0;
|
||||||
|
|
||||||
// Modulation level sensors
|
// Modulation level sensors
|
||||||
Sensors::setValueByType(
|
Sensors::setValueByType(
|
||||||
Sensors::Type::OT_MODULATION_LEVEL, vars.slave.modulation.current,
|
Sensors::Type::OT_MODULATION_LEVEL, 0.0f,
|
||||||
Sensors::ValueType::PRIMARY, true, true
|
Sensors::ValueType::PRIMARY, true, true
|
||||||
);
|
);
|
||||||
|
|
||||||
// Power sensors
|
// Power sensors
|
||||||
Sensors::setValueByType(
|
Sensors::setValueByType(
|
||||||
Sensors::Type::OT_CURRENT_POWER, power,
|
Sensors::Type::OT_CURRENT_POWER, 0.0f,
|
||||||
Sensors::ValueType::PRIMARY, true, true
|
Sensors::ValueType::PRIMARY, true, true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update DHW temp
|
// Update DHW temp
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_DHW_TEMP)) {
|
if (settings.opentherm.dhwPresent && Sensors::getAmountByType(Sensors::Type::OT_DHW_TEMP)) {
|
||||||
float convertedDhwTemp = 0.0f;
|
bool result = this->updateDhwTemp();
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
if (settings.opentherm.dhwPresent) {
|
if (result) {
|
||||||
result = this->updateDhwTemp();
|
float convertedDhwTemp = convertTemp(
|
||||||
|
vars.slave.dhw.currentTemp,
|
||||||
|
settings.opentherm.unitSystem,
|
||||||
|
settings.system.unitSystem
|
||||||
|
);
|
||||||
|
|
||||||
if (result) {
|
Log.snoticeln(
|
||||||
convertedDhwTemp = convertTemp(
|
FPSTR(L_OT_DHW), F("Received temp: %.2f (converted: %.2f)"),
|
||||||
vars.slave.dhw.currentTemp,
|
vars.slave.dhw.currentTemp, convertedDhwTemp
|
||||||
settings.opentherm.unitSystem,
|
);
|
||||||
settings.system.unitSystem
|
|
||||||
);
|
|
||||||
|
|
||||||
Log.snoticeln(
|
Sensors::setValueByType(
|
||||||
FPSTR(L_OT_DHW), F("Received temp: %.2f (converted: %.2f)"),
|
Sensors::Type::OT_DHW_TEMP, convertedDhwTemp,
|
||||||
vars.slave.dhw.currentTemp, convertedDhwTemp
|
Sensors::ValueType::PRIMARY, true, true
|
||||||
);
|
);
|
||||||
|
|
||||||
Sensors::setValueByType(
|
} else {
|
||||||
Sensors::Type::OT_DHW_TEMP, convertedDhwTemp,
|
Log.swarningln(FPSTR(L_OT_DHW), F("Failed receive temp"));
|
||||||
Sensors::ValueType::PRIMARY, true, true
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Log.swarningln(FPSTR(L_OT_DHW), F("Failed receive temp"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update DHW temp 2
|
// Update DHW temp 2
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_DHW_TEMP2)) {
|
if (settings.opentherm.dhwPresent && Sensors::getAmountByType(Sensors::Type::OT_DHW_TEMP2)) {
|
||||||
float convertedDhwTemp2 = 0.0f;
|
if (this->updateDhwTemp2()) {
|
||||||
bool result = false;
|
float convertedDhwTemp2 = convertTemp(
|
||||||
|
vars.slave.dhw.currentTemp2,
|
||||||
|
settings.opentherm.unitSystem,
|
||||||
|
settings.system.unitSystem
|
||||||
|
);
|
||||||
|
|
||||||
if (settings.opentherm.dhwPresent) {
|
Log.snoticeln(
|
||||||
result = this->updateDhwTemp2();
|
FPSTR(L_OT_DHW), F("Received temp 2: %.2f (converted: %.2f)"),
|
||||||
|
vars.slave.dhw.currentTemp2, convertedDhwTemp2
|
||||||
|
);
|
||||||
|
|
||||||
if (result) {
|
Sensors::setValueByType(
|
||||||
convertedDhwTemp2 = convertTemp(
|
Sensors::Type::OT_DHW_TEMP2, convertedDhwTemp2,
|
||||||
vars.slave.dhw.currentTemp2,
|
Sensors::ValueType::PRIMARY, true, true
|
||||||
settings.opentherm.unitSystem,
|
);
|
||||||
settings.system.unitSystem
|
|
||||||
);
|
|
||||||
|
|
||||||
Log.snoticeln(
|
} else {
|
||||||
FPSTR(L_OT_DHW), F("Received temp 2: %.2f (converted: %.2f)"),
|
Log.swarningln(FPSTR(L_OT_DHW), F("Failed receive temp 2"));
|
||||||
vars.slave.dhw.currentTemp2, convertedDhwTemp2
|
|
||||||
);
|
|
||||||
|
|
||||||
Sensors::setValueByType(
|
|
||||||
Sensors::Type::OT_DHW_TEMP2, convertedDhwTemp2,
|
|
||||||
Sensors::ValueType::PRIMARY, true, true
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Log.swarningln(FPSTR(L_OT_DHW), F("Failed receive temp 2"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update DHW flow rate
|
// Update DHW flow rate
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_DHW_FLOW_RATE)) {
|
if (settings.opentherm.dhwPresent && Sensors::getAmountByType(Sensors::Type::OT_DHW_FLOW_RATE)) {
|
||||||
float convertedDhwFlowRate = 0.0f;
|
if (this->updateDhwFlowRate()) {
|
||||||
bool result = false;
|
float convertedDhwFlowRate = convertVolume(
|
||||||
|
vars.slave.dhw.flowRate,
|
||||||
if (settings.opentherm.dhwPresent) {
|
settings.opentherm.unitSystem,
|
||||||
result = this->updateDhwFlowRate();
|
settings.system.unitSystem
|
||||||
|
);
|
||||||
|
|
||||||
if (result) {
|
Log.snoticeln(
|
||||||
convertedDhwFlowRate = convertVolume(
|
FPSTR(L_OT_DHW), F("Received flow rate: %.2f (converted: %.2f)"),
|
||||||
vars.slave.dhw.flowRate,
|
vars.slave.dhw.flowRate, convertedDhwFlowRate
|
||||||
settings.opentherm.unitSystem,
|
);
|
||||||
settings.system.unitSystem
|
|
||||||
);
|
|
||||||
|
|
||||||
Log.snoticeln(
|
Sensors::setValueByType(
|
||||||
FPSTR(L_OT_DHW), F("Received flow rate: %.2f (converted: %.2f)"),
|
Sensors::Type::OT_DHW_FLOW_RATE, convertedDhwFlowRate,
|
||||||
vars.slave.dhw.flowRate, convertedDhwFlowRate
|
Sensors::ValueType::PRIMARY, true, true
|
||||||
);
|
);
|
||||||
|
|
||||||
Sensors::setValueByType(
|
} else {
|
||||||
Sensors::Type::OT_DHW_FLOW_RATE, convertedDhwFlowRate,
|
Log.swarningln(FPSTR(L_OT_DHW), F("Failed receive flow rate"));
|
||||||
Sensors::ValueType::PRIMARY, true, true
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Log.swarningln(FPSTR(L_OT_DHW), F("Failed receive flow rate"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update heating temp
|
// Update heating temp
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_TEMP)) {
|
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_TEMP)) {
|
||||||
float convertedHeatingTemp = 0.0f;
|
if (this->updateHeatingTemp()) {
|
||||||
bool result = this->updateHeatingTemp();
|
float convertedHeatingTemp = convertTemp(
|
||||||
|
|
||||||
if (result) {
|
|
||||||
convertedHeatingTemp = convertTemp(
|
|
||||||
vars.slave.heating.currentTemp,
|
vars.slave.heating.currentTemp,
|
||||||
settings.opentherm.unitSystem,
|
settings.opentherm.unitSystem,
|
||||||
settings.system.unitSystem
|
settings.system.unitSystem
|
||||||
@@ -626,11 +600,8 @@ protected:
|
|||||||
|
|
||||||
// Update heating return temp
|
// Update heating return temp
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_RETURN_TEMP)) {
|
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_RETURN_TEMP)) {
|
||||||
float convertedHeatingReturnTemp = 0.0f;
|
if (this->updateHeatingReturnTemp()) {
|
||||||
bool result = this->updateHeatingReturnTemp();
|
float convertedHeatingReturnTemp = convertTemp(
|
||||||
|
|
||||||
if (result) {
|
|
||||||
convertedHeatingReturnTemp = convertTemp(
|
|
||||||
vars.slave.heating.returnTemp,
|
vars.slave.heating.returnTemp,
|
||||||
settings.opentherm.unitSystem,
|
settings.opentherm.unitSystem,
|
||||||
settings.system.unitSystem
|
settings.system.unitSystem
|
||||||
@@ -653,14 +624,9 @@ protected:
|
|||||||
|
|
||||||
// Update CH2 temp
|
// Update CH2 temp
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_CH2_TEMP)) {
|
if (Sensors::getAmountByType(Sensors::Type::OT_CH2_TEMP)) {
|
||||||
float convertedCh2Temp = 0.0f;
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
if (vars.master.ch2.enabled && !settings.opentherm.nativeHeatingControl) {
|
if (vars.master.ch2.enabled && !settings.opentherm.nativeHeatingControl) {
|
||||||
result = this->updateCh2Temp();
|
if (this->updateCh2Temp()) {
|
||||||
|
float convertedCh2Temp = convertTemp(
|
||||||
if (result) {
|
|
||||||
convertedCh2Temp = convertTemp(
|
|
||||||
vars.slave.ch2.currentTemp,
|
vars.slave.ch2.currentTemp,
|
||||||
settings.opentherm.unitSystem,
|
settings.opentherm.unitSystem,
|
||||||
settings.system.unitSystem
|
settings.system.unitSystem
|
||||||
@@ -684,11 +650,8 @@ protected:
|
|||||||
|
|
||||||
// Update exhaust temp
|
// Update exhaust temp
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_EXHAUST_TEMP)) {
|
if (Sensors::getAmountByType(Sensors::Type::OT_EXHAUST_TEMP)) {
|
||||||
float convertedExhaustTemp = 0.0f;
|
if (this->updateExhaustTemp()) {
|
||||||
bool result = this->updateExhaustTemp();
|
float convertedExhaustTemp = convertTemp(
|
||||||
|
|
||||||
if (result) {
|
|
||||||
convertedExhaustTemp = convertTemp(
|
|
||||||
vars.slave.exhaustTemp,
|
vars.slave.exhaustTemp,
|
||||||
settings.opentherm.unitSystem,
|
settings.opentherm.unitSystem,
|
||||||
settings.system.unitSystem
|
settings.system.unitSystem
|
||||||
@@ -711,11 +674,8 @@ protected:
|
|||||||
|
|
||||||
// Update heat exchanger temp
|
// Update heat exchanger temp
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_HEAT_EXCHANGER_TEMP)) {
|
if (Sensors::getAmountByType(Sensors::Type::OT_HEAT_EXCHANGER_TEMP)) {
|
||||||
float convertedHeatExchTemp = 0.0f;
|
if (this->updateHeatExchangerTemp()) {
|
||||||
bool result = this->updateHeatExchangerTemp();
|
float convertedHeatExchTemp = convertTemp(
|
||||||
|
|
||||||
if (result) {
|
|
||||||
convertedHeatExchTemp = convertTemp(
|
|
||||||
vars.slave.heatExchangerTemp,
|
vars.slave.heatExchangerTemp,
|
||||||
settings.opentherm.unitSystem,
|
settings.opentherm.unitSystem,
|
||||||
settings.system.unitSystem
|
settings.system.unitSystem
|
||||||
@@ -738,11 +698,8 @@ protected:
|
|||||||
|
|
||||||
// Update outdoor temp
|
// Update outdoor temp
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_OUTDOOR_TEMP)) {
|
if (Sensors::getAmountByType(Sensors::Type::OT_OUTDOOR_TEMP)) {
|
||||||
bool result = this->updateOutdoorTemp();
|
if (this->updateOutdoorTemp()) {
|
||||||
float convertedOutdoorTemp = 0.0f;
|
float convertedOutdoorTemp = convertTemp(
|
||||||
|
|
||||||
if (result) {
|
|
||||||
convertedOutdoorTemp = convertTemp(
|
|
||||||
vars.slave.heating.outdoorTemp,
|
vars.slave.heating.outdoorTemp,
|
||||||
settings.opentherm.unitSystem,
|
settings.opentherm.unitSystem,
|
||||||
settings.system.unitSystem
|
settings.system.unitSystem
|
||||||
@@ -765,11 +722,8 @@ protected:
|
|||||||
|
|
||||||
// Update pressure
|
// Update pressure
|
||||||
if (Sensors::getAmountByType(Sensors::Type::OT_PRESSURE)) {
|
if (Sensors::getAmountByType(Sensors::Type::OT_PRESSURE)) {
|
||||||
float convertedPressure = 0.0f;
|
if (this->updatePressure()) {
|
||||||
bool result = this->updatePressure();
|
float convertedPressure = convertPressure(
|
||||||
|
|
||||||
if (result) {
|
|
||||||
convertedPressure = convertPressure(
|
|
||||||
vars.slave.pressure,
|
vars.slave.pressure,
|
||||||
settings.opentherm.unitSystem,
|
settings.opentherm.unitSystem,
|
||||||
settings.system.unitSystem
|
settings.system.unitSystem
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
unsigned long activityTime = 0;
|
unsigned long activityTime = 0;
|
||||||
uint8_t signalQuality = 0;
|
uint8_t signalQuality = 100;
|
||||||
//float raw[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
//float raw[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
float values[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
float values[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
} Result;
|
} Result;
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ protected:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& rSensor = Sensors::results[sensorId];
|
||||||
float value = instance.getTempC(sSensor.address);
|
float value = instance.getTempC(sSensor.address);
|
||||||
if (value == DEVICE_DISCONNECTED_C) {
|
if (value == DEVICE_DISCONNECTED_C) {
|
||||||
Log.swarningln(
|
Log.swarningln(
|
||||||
@@ -309,6 +310,10 @@ protected:
|
|||||||
sSensor.gpio, sensorId, sSensor.name
|
sSensor.gpio, sensorId, sSensor.name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (rSensor.signalQuality > 0) {
|
||||||
|
rSensor.signalQuality--;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,6 +322,10 @@ protected:
|
|||||||
sSensor.gpio, sensorId, sSensor.name, value
|
sSensor.gpio, sensorId, sSensor.name, value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (rSensor.signalQuality < 100) {
|
||||||
|
rSensor.signalQuality++;
|
||||||
|
}
|
||||||
|
|
||||||
// set sensor value
|
// set sensor value
|
||||||
Sensors::setValueById(sensorId, value, Sensors::ValueType::TEMPERATURE, true, true);
|
Sensors::setValueById(sensorId, value, Sensors::ValueType::TEMPERATURE, true, true);
|
||||||
}
|
}
|
||||||
@@ -334,6 +343,23 @@ protected:
|
|||||||
|
|
||||||
// check sensors on bus
|
// check sensors on bus
|
||||||
if (!instance.getDeviceCount()) {
|
if (!instance.getDeviceCount()) {
|
||||||
|
for (uint8_t sensorId = 0; sensorId <= Sensors::getMaxSensorId(); sensorId++) {
|
||||||
|
auto& sSensor = Sensors::settings[sensorId];
|
||||||
|
|
||||||
|
// only target & valid sensors
|
||||||
|
if (!sSensor.enabled || sSensor.type != Sensors::Type::DALLAS_TEMP || sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
|
||||||
|
continue;
|
||||||
|
|
||||||
|
} else if (sSensor.gpio != gpio || isEmptyAddress(sSensor.address)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& rSensor = Sensors::results[sensorId];
|
||||||
|
if (rSensor.signalQuality > 0) {
|
||||||
|
rSensor.signalQuality--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user