Skip to content

Commit

Permalink
power_manager: Enable PM if automated blocking is used
Browse files Browse the repository at this point in the history
Allows using external signals to block charging even if
PV excess charging and dynamic load management are disabled.
  • Loading branch information
MattiasTF committed Jan 17, 2025
1 parent a94ea21 commit 19f3e8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion software/src/modules/power_manager/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Optional = Automation
EM V1
Meters

After = Charge Manager
After = Automation
Charge Manager
EM V1
Meters
7 changes: 6 additions & 1 deletion software/src/modules/power_manager/power_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,14 @@ void PowerManager::setup()
api.restorePersistentConfig("power_manager/config", &config);
api.restorePersistentConfig("power_manager/dynamic_load_config", &dynamic_load_config);

bool automation_has_action = false;
#if MODULE_AUTOMATION_AVAILABLE()
automation_has_action = automation.has_task_with_action(AutomationActionID::PMBlockCharge);
#endif

// Force-enable PM if either PV excess charging or dynamic load management are enabled.
// Force-disable otherwise.
if (config.get("excess_charging_enable")->asBool() || dynamic_load_config.get("enabled")->asBool()) {
if (config.get("excess_charging_enable")->asBool() || dynamic_load_config.get("enabled")->asBool() || automation_has_action) {
config.get("enabled")->updateBool(true);
} else {
config.get("enabled")->updateBool(false);
Expand Down

0 comments on commit 19f3e8d

Please sign in to comment.