Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ecomode addon 3.2 #2697

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/cmdvartab
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ CMDDESC bypass.start "Put the UPS in bypass mode"
CMDDESC bypass.stop "Take the UPS out of bypass mode"
CMDDESC ecomode.enable "Put UPS in High Efficiency (aka ECO) mode"
CMDDESC ecomode.disable "Take the UPS out of High Efficiency (aka ECO) mode"
CMDDESC ecomode.start.auto "Put UPS in Bypass mode then High Efficiency (aka ECO) mode"
CMDDESC essmode.enable "Put UPS in Energy Saver System (aka ESS) mode"
CMDDESC essmode.disable "Take the UPS out of Energy Saver System (aka ESS) mode"
CMDDESC reset.input.minmax "Reset minimum and maximum input voltage status"
Expand Down
1 change: 1 addition & 0 deletions docs/nut-names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ Instant commands
| bypass.stop | Take the UPS out of bypass mode
| ecomode.enable | Put UPS in High Efficiency (aka ECO) mode
| ecomode.disable | Take the UPS out of High Efficiency (aka ECO) mode
| ecomode.start.auto | Put UPS in Bypass mode then High Efficiency (aka ECO) mode
| essmode.enable | Put UPS in Energy Saver System (aka ESS) mode
| essmode.disable | Take the UPS out of Energy Saver System (aka ESS) mode
| reset.input.minmax | Reset minimum and maximum input voltage status
Expand Down
47 changes: 47 additions & 0 deletions drivers/mge-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,51 @@ static info_lkp_t eaton_input_bypass_mode_off_info[] = {
{ 0, NULL, NULL, NULL }
};

/* Function to start ECO(HE) Mode automatically instead of manually starting Bypass and then ECO(HE) Mode */
static const char *eaton_input_eco_mode_auto_on_fun(double value)
{
const char *bypass_switch_off_str = NULL;
const char *bypass_switch_on_str = NULL;
const char *eco_switchable_str = NULL;

NUT_UNUSED_VARIABLE(value);

/* Check if input.bypass.switch.on is disabled and set it to 'on' */
bypass_switch_on_str = dstate_getinfo("input.bypass.switch.on");
if (!strcmp(bypass_switch_on_str, "disabled")) {
setvar("input.bypass.switch.on", "on");
} else {
upsdebugx(1, "Bypass switch on state is: %s , must be disabled before switching on", bypass_switch_on_str);
return NULL;
}

/* Check if input.eco.switchable is normal and set it to 'ECO' */
eco_switchable_str = dstate_getinfo("input.eco.switchable");
if (!strcmp(eco_switchable_str, "normal")) {
setvar("input.eco.switchable", "ECO");
} else {
upsdebugx(1, "ECO switch state is: %s , must be normal before switching to ECO", eco_switchable_str);
return NULL;
}

/* Check if input.bypass.switch.off is disabled and set it to 'off' */
bypass_switch_off_str = dstate_getinfo("input.bypass.switch.off");
if (!strcmp(bypass_switch_off_str, "disabled")) {
setvar("input.bypass.switch.off", "off");
} else {
upsdebugx(1, "Bypass switch off state is: %s , must be disabled before switching off", bypass_switch_off_str);
return NULL;
}
upsdebugx(1, "%s: ECO Mode was enabled after switching to Bypass Mode", __func__);
return NULL;
}

/* High Efficiency (aka ECO) mode for auto start command */
static info_lkp_t eaton_input_eco_mode_auto_on_info[] = {
{ 1, "dummy", eaton_input_eco_mode_auto_on_fun, NULL },
{ 0, NULL, NULL, NULL }
};

/* Determine country using UPS.PowerSummary.Country.
* If not present:
* if PowerConverter.Output.Voltage >= 200 => "Europe"
Expand Down Expand Up @@ -1980,6 +2025,8 @@ static hid_info_t mge_hid2nut[] =
{ "ecomode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "1", HU_TYPE_CMD, eaton_input_mode_info },
{ "essmode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "2", HU_TYPE_CMD, NULL },
{ "essmode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, NULL },
/* Command to switch ECO(HE) Mode with switch to Automatic Bypass Mode on befor */
{ "ecomode.start.auto", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "1", HU_TYPE_CMD, eaton_input_eco_mode_auto_on_info },

/* Command to switch Automatic Bypass Mode On/Off */
{ "bypass.start", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "1", HU_TYPE_CMD, eaton_input_bypass_mode_on_info },
Expand Down