diff --git a/src/MqttHandlePowerLimiterHass.cpp b/src/MqttHandlePowerLimiterHass.cpp index 17b9ad7cb..85eaa9117 100644 --- a/src/MqttHandlePowerLimiterHass.cpp +++ b/src/MqttHandlePowerLimiterHass.cpp @@ -46,7 +46,9 @@ void MqttHandlePowerLimiterHassClass::forceUpdate() void MqttHandlePowerLimiterHassClass::publishConfig() { - if (!Configuration.get().Mqtt.Hass.Enabled) { + auto const& config = Configuration.get(); + + if (!config.Mqtt.Hass.Enabled) { return; } @@ -54,13 +56,19 @@ void MqttHandlePowerLimiterHassClass::publishConfig() return; } - if (!Configuration.get().PowerLimiter.Enabled) { - publishSelect("DPL Mode", "mdi:gauge", "config", "mode", "mode"); + if (!config.PowerLimiter.Enabled) { + return; + } + + publishSelect("DPL Mode", "mdi:gauge", "config", "mode", "mode"); + + if (config.Battery.Enabled && !config.PowerLimiter.IgnoreSoc) { publishNumber("DPL battery SoC start threshold", "mdi:battery-charging", "config", "threshold/soc/start", "threshold/soc/start", "%", 0, 100); publishNumber("DPL battery SoC stop threshold", "mdi:battery-charging", "config", "threshold/soc/stop", "threshold/soc/stop", "%", 0, 100); - } - if (!Configuration.get().Vedirect.Enabled) { - publishNumber("DPL full solar passthrough SoC", "mdi:transmission-tower-import", "config", "threshold/soc/full_solar_passthrough", "threshold/soc/full_solar_passthrough", "%", 0, 100); + + if (config.Vedirect.Enabled) { + publishNumber("DPL full solar passthrough SoC", "mdi:transmission-tower-import", "config", "threshold/soc/full_solar_passthrough", "threshold/soc/full_solar_passthrough", "%", 0, 100); + } } }