Skip to content
Merged
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
2 changes: 2 additions & 0 deletions data/cmdvartab
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ CMDDESC bypass.start "Put the UPS in Bypass mode"
CMDDESC bypass.stop "Take the UPS out of Bypass mode"
CMDDESC experimental.ecomode.enable "Put UPS in High Efficiency (aka ECO) mode"
CMDDESC experimental.ecomode.disable "Take the UPS out of High Efficiency (aka ECO) mode"
CMDDESC experimental.ecomode.start.auto "Put UPS in Bypass mode then High Efficiency (aka ECO) mode"
CMDDESC experimental.ecomode.stop.auto "Take the UPS out of High Efficiency (aka ECO) mode after exiting Bypass mode"
CMDDESC experimental.essmode.enable "Put UPS in Energy Saver System (aka ESS) mode"
CMDDESC experimental.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
4 changes: 4 additions & 0 deletions docs/nut-names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,10 @@ to last as part of NUT standard protocol in the long run.
| Put UPS in High Efficiency (aka ECO) mode
| experimental.ecomode.disable | usbhid-ups => mge-hid (Eaton/MGE)
| Take the UPS out of High Efficiency (aka ECO) mode
| experimental.ecomode.start.auto | usbhid-ups => mge-hid (Eaton/MGE)
| Put UPS in Bypass mode then High Efficiency (aka ECO) mode
| experimental.ecomode.stop.auto | usbhid-ups => mge-hid (Eaton/MGE)
| Take the UPS out of High Efficiency (aka ECO) mode after exiting Bypass mode
| experimental.essmode.enable | usbhid-ups => mge-hid (Eaton/MGE)
| Put UPS in Energy Saver System (aka ESS) mode
| experimental.essmode.disable | usbhid-ups => mge-hid (Eaton/MGE)
Expand Down
72 changes: 71 additions & 1 deletion drivers/mge-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ static const char *eaton_input_ess_mode_report(double value)
/* High Efficiency (aka ECO) mode, Energy Saver System (aka ESS) mode makes sense for UPS like (93PM G2, 9395P) */
static info_lkp_t eaton_input_eco_mode_on_off_info[] = {
{ 0, "normal", NULL, NULL },
{ 1, "ECO", eaton_input_eco_mode_check_range, NULL }, /* NOTE: "ECO" = tested on 9E model and working fine */
{ 1, "ECO", eaton_input_eco_mode_check_range, NULL }, /* NOTE: "ECO" = tested on 9SX model and working fine, 9E model can stuck in ECO mode https://github.com/networkupstools/nut/issues/2719 */
{ 2, "ESS", eaton_input_ess_mode_report, NULL },
{ 0, NULL, NULL, NULL }
};
Expand Down Expand Up @@ -1151,6 +1151,72 @@ 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_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;
}

upsdebugx(1, "%s: ECO Mode was enabled after switching to Bypass Mode", __func__);
return NULL;
}

/* Function to stop ECO(HE) Mode automatically instead of manually stoping Bypass and then Online Mode */
static const char *eaton_input_eco_mode_auto_off_fun(double value)
{
const char *bypass_switch_off_str = NULL;
const char *eco_switchable_str = NULL;

NUT_UNUSED_VARIABLE(value);

/* 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;
}

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

upsdebugx(1, "%s: ECO Mode was disabled after switching from Bypass Mode", __func__);
return NULL;
}

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

/* Determine country using UPS.PowerSummary.Country.
* If not present:
* if PowerConverter.Output.Voltage >= 200 => "Europe"
Expand Down Expand Up @@ -2092,6 +2158,10 @@ static hid_info_t mge_hid2nut[] =
{ "experimental.ecomode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "1", HU_TYPE_CMD, eaton_input_eco_mode_on_off_info },
{ "experimental.essmode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "2", HU_TYPE_CMD, NULL },
{ "experimental.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 before */
{ "experimental.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 from ECO(HE) Mode with switch from Automatic Bypass Mode on before */
{ "experimental.ecomode.stop.auto", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", 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