Skip to content

Commit

Permalink
DPL thresholds: fix logic in HomeAssistent handler
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen authored Mar 5, 2024
1 parent d607c79 commit 7025ce7
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/MqttHandlePowerLimiterHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,29 @@ void MqttHandlePowerLimiterHassClass::forceUpdate()

void MqttHandlePowerLimiterHassClass::publishConfig()
{
if (!Configuration.get().Mqtt.Hass.Enabled) {
auto const& config = Configuration.get();

if (!config.Mqtt.Hass.Enabled) {
return;
}

if (!MqttSettings.getConnected()) {
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);
}
}
}

Expand Down

0 comments on commit 7025ce7

Please sign in to comment.