From 5597cc7956777a25729e050e54ec6bd9d43f3ba9 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Thu, 8 May 2025 21:22:42 +0300 Subject: [PATCH 1/6] experimental.ecomode.[start/stop].auto move to uprw + set NULL to last argument for bypass and ecomode cmds Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 1c66d850d0..f739b9ce25 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -2043,6 +2043,11 @@ static hid_info_t mge_hid2nut[] = /* ECO(HE), ESS Mode switch, to use when 'input.bypass.switch.on' is on */ { "input.eco.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_on_off_info }, + /* Command to switch ECO(HE) Mode with switch to Automatic Bypass Mode on before */ + { "experimental.ecomode.start.auto", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_auto_on_off_info }, + /* Command to switch from ECO(HE) Mode with switch from Automatic Bypass Mode on before */ + { "experimental.ecomode.stop.auto", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_auto_on_off_info }, + /* Auto Bypass Mode on/off, to use when 'input.transfer.bypass.forced' is enabled */ { "input.bypass.switch.on", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_on_info }, { "input.bypass.switch.off", ST_FLAG_RW | ST_FLAG_STRING, 12, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_off_info }, @@ -2155,18 +2160,14 @@ static hid_info_t mge_hid2nut[] = { "outlet.2.load.on", 0, 0, "UPS.OutletSystem.Outlet.[3].DelayBeforeStartup", NULL, "0", HU_TYPE_CMD, NULL }, /* Command to switch ECO(HE), ESS Mode */ - { "experimental.ecomode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, eaton_input_eco_mode_on_off_info }, - { "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, eaton_input_eco_mode_on_off_info }, - { "experimental.essmode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, eaton_input_eco_mode_on_off_info }, - /* 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_off_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_off_info }, + { "experimental.ecomode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, NULL }, + { "experimental.ecomode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "1", HU_TYPE_CMD, NULL }, + { "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 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 }, - { "bypass.stop", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "1", HU_TYPE_CMD, eaton_input_bypass_mode_off_info }, + { "bypass.start", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "1", HU_TYPE_CMD, NULL }, + { "bypass.stop", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "1", HU_TYPE_CMD, NULL }, /* end of structure. */ { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } From 6e5f92e373dfcfcd79166107e8e60d3e0cb41991 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Fri, 9 May 2025 15:41:17 +0300 Subject: [PATCH 2/6] experimental.ecomode.[start/stop] to experimental.ecomode.auto Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- data/cmdvartab | 3 +-- docs/nut-names.txt | 2 +- drivers/mge-hid.c | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/data/cmdvartab b/data/cmdvartab index 6bdf5c107f..376c94cd67 100644 --- a/data/cmdvartab +++ b/data/cmdvartab @@ -260,8 +260,7 @@ 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.ecomode.auto "Put UPS in Bypass mode then High Efficiency (aka ECO) 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" diff --git a/docs/nut-names.txt b/docs/nut-names.txt index 45ee3d6920..93e344af81 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -1059,7 +1059,7 @@ 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) +| experimental.ecomode.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 diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index f739b9ce25..308daaa7de 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -2043,10 +2043,9 @@ static hid_info_t mge_hid2nut[] = /* ECO(HE), ESS Mode switch, to use when 'input.bypass.switch.on' is on */ { "input.eco.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_on_off_info }, - /* Command to switch ECO(HE) Mode with switch to Automatic Bypass Mode on before */ - { "experimental.ecomode.start.auto", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_auto_on_off_info }, - /* Command to switch from ECO(HE) Mode with switch from Automatic Bypass Mode on before */ - { "experimental.ecomode.stop.auto", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_auto_on_off_info }, + /* Needs to be Tested */ + /* Command to switch ECO(HE) Mode on/off with switch to Automatic Bypass Mode on/off before */ + { "experimental.ecomode.auto", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_auto_on_off_info }, /* Auto Bypass Mode on/off, to use when 'input.transfer.bypass.forced' is enabled */ { "input.bypass.switch.on", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_on_info }, From 1777d8ecae0540c5025ad99b04e8814299759166 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Fri, 9 May 2025 16:54:22 +0300 Subject: [PATCH 3/6] change place of 0-1 in eaton_input_eco_mode_auto_on_off_info() Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 308daaa7de..c243bb620e 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1213,8 +1213,8 @@ static const char *eaton_input_eco_mode_auto_off_fun(double value) /* High Efficiency (aka ECO) mode for auto start/stop commands */ static info_lkp_t eaton_input_eco_mode_auto_on_off_info[] = { - { 1, "dummy", eaton_input_eco_mode_auto_on_fun, NULL }, { 0, "dummy", eaton_input_eco_mode_auto_off_fun, NULL }, + { 1, "dummy", eaton_input_eco_mode_auto_on_fun, NULL }, { 0, NULL, NULL, NULL } }; From c402c2cb0832d950677f80db5b69c9d8d8038d03 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Sat, 10 May 2025 11:19:39 +0300 Subject: [PATCH 4/6] input.bypass.switch.on", "disabled (useless, onlly on,off can be runned) to "input.bypass.switch.off", "off" ,aded function of eaton_input_bypass_check_range(value); , eaton_input_eco_mode_check_range(value); Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index c243bb620e..dba9198b19 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1062,7 +1062,7 @@ static const char *eaton_input_bypass_check_range(double value) NUT_STRARG(out_frequency_nominal_str)); /* Disable Bypass mode switching, do not enter Bypass mode */ - dstate_setinfo("input.bypass.switch.on", "disabled"); + dstate_setinfo("input.bypass.switch.off", "off"); upsdebugx(1, "%s: Disable Bypass mode due to missing input/output variables.", __func__); return NULL; } @@ -1131,7 +1131,7 @@ static const char *eaton_input_bypass_check_range(double value) upsdebugx(1, "Input Bypass frequency is outside Bypass transfer limits: %.1f Hz", bypass_frequency); } /* Disable Bypass mode switching, do not enter Bypass mode */ - dstate_setinfo("input.bypass.switch.on", "disabled"); + dstate_setinfo("input.bypass.switch.off", "off"); upsdebugx(1, "%s: Disable Bypass mode due to input conditions being outside the transfer limits.", __func__); return NULL; } @@ -1156,13 +1156,13 @@ 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); + const char *bypass_result = NULL; + const char *ecomode_result = NULL; /* 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"); + bypass_result = eaton_input_bypass_check_range(value); } else { upsdebugx(1, "Bypass switch on state is: %s , must be disabled before switching on", bypass_switch_on_str); return NULL; @@ -1171,14 +1171,14 @@ static const char *eaton_input_eco_mode_auto_on_fun(double value) /* 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"); + ecomode_result = eaton_input_eco_mode_check_range(value); } 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; + return ecomode_result; } /* Function to stop ECO(HE) Mode automatically instead of manually stoping Bypass and then Online Mode */ @@ -1186,6 +1186,8 @@ 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; + const char *bypass_result = NULL; + const char *ecomode_result = NULL; NUT_UNUSED_VARIABLE(value); @@ -1213,8 +1215,9 @@ static const char *eaton_input_eco_mode_auto_off_fun(double value) /* High Efficiency (aka ECO) mode for auto start/stop commands */ static info_lkp_t eaton_input_eco_mode_auto_on_off_info[] = { - { 0, "dummy", eaton_input_eco_mode_auto_off_fun, NULL }, - { 1, "dummy", eaton_input_eco_mode_auto_on_fun, NULL }, + { 0, "normal", eaton_input_eco_mode_auto_off_fun, NULL }, + { 1, "ECO", eaton_input_eco_mode_auto_on_fun, NULL }, + { 2, "ESS", NULL, NULL }, { 0, NULL, NULL, NULL } }; From b61c7844fa58fe83cfe8f5c70a9c82e4606748e4 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Sat, 10 May 2025 11:28:00 +0300 Subject: [PATCH 5/6] experimental.ecomode.stop/start.auto added as commands for test after compiled Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index dba9198b19..cd68f2c84e 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -2167,6 +2167,11 @@ static hid_info_t mge_hid2nut[] = { "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_off_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_off_info }, + /* Command to switch Automatic Bypass Mode on/off */ { "bypass.start", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "1", HU_TYPE_CMD, NULL }, { "bypass.stop", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "1", HU_TYPE_CMD, NULL }, From 4fd9856e95d915c596d77c8dbb1ba49d92f0c7cc Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Sat, 10 May 2025 12:33:13 +0300 Subject: [PATCH 6/6] removed unused vars Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index cd68f2c84e..5929470820 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1156,13 +1156,11 @@ 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; - const char *bypass_result = NULL; - const char *ecomode_result = NULL; /* 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")) { - bypass_result = eaton_input_bypass_check_range(value); + bypass_switch_on_str = eaton_input_bypass_check_range(value); } else { upsdebugx(1, "Bypass switch on state is: %s , must be disabled before switching on", bypass_switch_on_str); return NULL; @@ -1171,14 +1169,14 @@ static const char *eaton_input_eco_mode_auto_on_fun(double value) /* 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")) { - ecomode_result = eaton_input_eco_mode_check_range(value); + eco_switchable_str = eaton_input_eco_mode_check_range(value); } 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 ecomode_result; + return eco_switchable_str; } /* Function to stop ECO(HE) Mode automatically instead of manually stoping Bypass and then Online Mode */ @@ -1186,8 +1184,6 @@ 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; - const char *bypass_result = NULL; - const char *ecomode_result = NULL; NUT_UNUSED_VARIABLE(value); @@ -1204,6 +1200,7 @@ static const char *eaton_input_eco_mode_auto_off_fun(double value) eco_switchable_str = dstate_getinfo("input.eco.switchable"); if (!strcmp(eco_switchable_str, "ECO")) { setvar("input.eco.switchable", "normal"); + buzzmode_set("vendor:mge-hid:normal"); } else { upsdebugx(1, "ECO switch state is: %s , must be ECO before switching to normal", eco_switchable_str); return NULL;