mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-12 19:24:27 +05:00
feat: optimizing with different unit systems
This commit is contained in:
@@ -51,6 +51,7 @@ protected:
|
||||
MqttClient* client = nullptr;
|
||||
HaHelper* haHelper = nullptr;
|
||||
MqttWriter* writer = nullptr;
|
||||
UnitSystem currentUnitSystem = UnitSystem::METRIC;
|
||||
unsigned short readyForSendTime = 15000;
|
||||
unsigned long lastReconnectTime = 0;
|
||||
unsigned long connectedTime = 0;
|
||||
@@ -213,10 +214,11 @@ protected:
|
||||
}
|
||||
|
||||
// publish ha entities if not published
|
||||
if (this->newConnection) {
|
||||
if (this->newConnection || this->currentUnitSystem != settings.system.unitSystem) {
|
||||
this->publishHaEntities();
|
||||
this->publishNonStaticHaEntities(true);
|
||||
this->newConnection = false;
|
||||
this->currentUnitSystem = settings.system.unitSystem;
|
||||
|
||||
} else {
|
||||
// publish non static ha entities
|
||||
@@ -318,14 +320,14 @@ protected:
|
||||
void publishHaEntities() {
|
||||
// emergency
|
||||
this->haHelper->publishSwitchEmergency();
|
||||
this->haHelper->publishNumberEmergencyTarget();
|
||||
this->haHelper->publishNumberEmergencyTarget(settings.system.unitSystem);
|
||||
this->haHelper->publishSwitchEmergencyUseEquitherm();
|
||||
this->haHelper->publishSwitchEmergencyUsePid();
|
||||
|
||||
// heating
|
||||
this->haHelper->publishSwitchHeating(false);
|
||||
this->haHelper->publishSwitchHeatingTurbo();
|
||||
this->haHelper->publishNumberHeatingHysteresis();
|
||||
this->haHelper->publishNumberHeatingHysteresis(settings.system.unitSystem);
|
||||
this->haHelper->publishSensorHeatingSetpoint(settings.system.unitSystem, false);
|
||||
this->haHelper->publishSensorBoilerHeatingMinTemp(settings.system.unitSystem, false);
|
||||
this->haHelper->publishSensorBoilerHeatingMaxTemp(settings.system.unitSystem, false);
|
||||
@@ -368,8 +370,8 @@ protected:
|
||||
this->haHelper->publishSensorUptime(false);
|
||||
|
||||
// temperatures
|
||||
this->haHelper->publishNumberIndoorTemp();
|
||||
this->haHelper->publishSensorHeatingTemp();
|
||||
this->haHelper->publishNumberIndoorTemp(settings.system.unitSystem);
|
||||
this->haHelper->publishSensorHeatingTemp(settings.system.unitSystem);
|
||||
this->haHelper->publishSensorHeatingReturnTemp(settings.system.unitSystem, false);
|
||||
this->haHelper->publishSensorExhaustTemp(settings.system.unitSystem, false);
|
||||
|
||||
@@ -385,8 +387,7 @@ protected:
|
||||
|
||||
bool published = false;
|
||||
bool isStupidMode = !settings.pid.enable && !settings.equitherm.enable;
|
||||
byte heatingMinTemp = 0;
|
||||
byte heatingMaxTemp = 90;
|
||||
byte heatingMinTemp, heatingMaxTemp = 0;
|
||||
bool editableOutdoorTemp = settings.sensors.outdoor.type == SensorType::MANUAL;
|
||||
bool editableIndoorTemp = settings.sensors.indoor.type == SensorType::MANUAL;
|
||||
|
||||
@@ -413,7 +414,7 @@ protected:
|
||||
this->haHelper->publishNumberDhwMinTemp(settings.system.unitSystem, false);
|
||||
this->haHelper->publishNumberDhwMaxTemp(settings.system.unitSystem, false);
|
||||
this->haHelper->publishBinSensorDhw();
|
||||
this->haHelper->publishSensorDhwTemp();
|
||||
this->haHelper->publishSensorDhwTemp(settings.system.unitSystem);
|
||||
this->haHelper->publishSensorDhwFlowRate(false);
|
||||
|
||||
} else {
|
||||
@@ -443,6 +444,7 @@ protected:
|
||||
|
||||
this->haHelper->publishNumberHeatingTarget(settings.system.unitSystem, heatingMinTemp, heatingMaxTemp, false);
|
||||
this->haHelper->publishClimateHeating(
|
||||
settings.system.unitSystem,
|
||||
heatingMinTemp,
|
||||
heatingMaxTemp,
|
||||
isStupidMode ? HaHelper::TEMP_SOURCE_HEATING : HaHelper::TEMP_SOURCE_INDOOR
|
||||
@@ -453,6 +455,7 @@ protected:
|
||||
} else if (_isStupidMode != isStupidMode) {
|
||||
_isStupidMode = isStupidMode;
|
||||
this->haHelper->publishClimateHeating(
|
||||
settings.system.unitSystem,
|
||||
heatingMinTemp,
|
||||
heatingMaxTemp,
|
||||
isStupidMode ? HaHelper::TEMP_SOURCE_HEATING : HaHelper::TEMP_SOURCE_INDOOR
|
||||
@@ -466,7 +469,7 @@ protected:
|
||||
_dhwMaxTemp = settings.dhw.maxTemp;
|
||||
|
||||
this->haHelper->publishNumberDhwTarget(settings.system.unitSystem, settings.dhw.minTemp, settings.dhw.maxTemp, false);
|
||||
this->haHelper->publishClimateDhw(settings.dhw.minTemp, settings.dhw.maxTemp);
|
||||
this->haHelper->publishClimateDhw(settings.system.unitSystem, settings.dhw.minTemp, settings.dhw.maxTemp);
|
||||
|
||||
published = true;
|
||||
}
|
||||
@@ -476,10 +479,10 @@ protected:
|
||||
|
||||
if (editableOutdoorTemp) {
|
||||
this->haHelper->deleteSensorOutdoorTemp();
|
||||
this->haHelper->publishNumberOutdoorTemp();
|
||||
this->haHelper->publishNumberOutdoorTemp(settings.system.unitSystem);
|
||||
} else {
|
||||
this->haHelper->deleteNumberOutdoorTemp();
|
||||
this->haHelper->publishSensorOutdoorTemp();
|
||||
this->haHelper->publishSensorOutdoorTemp(settings.system.unitSystem);
|
||||
}
|
||||
|
||||
published = true;
|
||||
@@ -490,10 +493,10 @@ protected:
|
||||
|
||||
if (editableIndoorTemp) {
|
||||
this->haHelper->deleteSensorIndoorTemp();
|
||||
this->haHelper->publishNumberIndoorTemp();
|
||||
this->haHelper->publishNumberIndoorTemp(settings.system.unitSystem);
|
||||
} else {
|
||||
this->haHelper->deleteNumberIndoorTemp();
|
||||
this->haHelper->publishSensorIndoorTemp();
|
||||
this->haHelper->publishSensorIndoorTemp(settings.system.unitSystem);
|
||||
}
|
||||
|
||||
published = true;
|
||||
|
||||
Reference in New Issue
Block a user