diff --git a/data/cmdvartab b/data/cmdvartab index ba915cd114..1e75288603 100644 --- a/data/cmdvartab +++ b/data/cmdvartab @@ -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" diff --git a/docs/nut-names.txt b/docs/nut-names.txt index 07a62bbcc0..16f50a4927 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -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 diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index da1524bd8e..ee96aba806 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -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" @@ -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 },