Skip to content

Commit b7d6731

Browse files
authored
Merge 5dbd082 into 8f4340a
2 parents 8f4340a + 5dbd082 commit b7d6731

File tree

3 files changed

+85
-4
lines changed

3 files changed

+85
-4
lines changed

data/cmdvartab

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ CMDDESC bypass.start "Put the UPS in Bypass mode"
260260
CMDDESC bypass.stop "Take the UPS out of Bypass mode"
261261
CMDDESC experimental.ecomode.enable "Put UPS in High Efficiency (aka ECO) mode"
262262
CMDDESC experimental.ecomode.disable "Take the UPS out of High Efficiency (aka ECO) mode"
263+
CMDDESC experimental.bypass.ecomode.start "Put UPS in Bypass mode then High Efficiency (aka ECO) mode"
264+
CMDDESC experimental.bypass.ecomode.stop "Take the UPS out of High Efficiency (aka ECO) mode after exiting Bypass mode"
263265
CMDDESC experimental.essmode.enable "Put UPS in Energy Saver System (aka ESS) mode"
264266
CMDDESC experimental.essmode.disable "Take the UPS out of Energy Saver System (aka ESS) mode"
265267
CMDDESC experimental.test.beeper.start "Start testing the UPS beeper"

docs/nut-names.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,10 @@ to last as part of NUT standard protocol in the long run.
10591059
| Put UPS in High Efficiency (aka ECO) mode
10601060
| experimental.ecomode.disable | usbhid-ups => mge-hid (Eaton/MGE)
10611061
| Take the UPS out of High Efficiency (aka ECO) mode
1062+
| experimental.bypass.ecomode.start | usbhid-ups => mge-hid (Eaton/MGE)
1063+
| Put UPS in Bypass mode then High Efficiency (aka ECO) mode
1064+
| experimental.bypass.ecomode.stop | usbhid-ups => mge-hid (Eaton/MGE)
1065+
| Take the UPS out of High Efficiency (aka ECO) mode after exiting Bypass mode
10621066
| experimental.essmode.enable | usbhid-ups => mge-hid (Eaton/MGE)
10631067
| Put UPS in Energy Saver System (aka ESS) mode
10641068
| experimental.essmode.disable | usbhid-ups => mge-hid (Eaton/MGE)

drivers/mge-hid.c

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,10 +991,10 @@ static const char *eaton_input_eco_mode_check_range(double value)
991991
} else {
992992
/* Condensed debug messages for out of range voltage and frequency */
993993
if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) {
994-
upsdebugx(1, "Input Bypass voltage is outside ECO transfer limits: %.1f V", bypass_voltage);
994+
upsdebugx(1, "%s: Input Bypass voltage is outside ECO transfer limits: %.1f V", __func__, bypass_voltage);
995995
}
996996
if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) {
997-
upsdebugx(1, "Input Bypass frequency is outside ECO transfer limits: %.1f Hz", bypass_frequency);
997+
upsdebugx(1, "%s: Input Bypass frequency is outside ECO transfer limits: %.1f Hz", __func__, bypass_frequency);
998998
}
999999
/* Disable ECO mode switching, do not enter ECO mode */
10001000
dstate_setinfo("input.eco.switchable", "normal");
@@ -1125,10 +1125,10 @@ static const char *eaton_input_bypass_check_range(double value)
11251125
} else {
11261126
/* Condensed debug messages for out of range voltage and frequency */
11271127
if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) {
1128-
upsdebugx(1, "Input Bypass voltage is outside Bypass transfer limits: %.1f V", bypass_voltage);
1128+
upsdebugx(1, "%s: Input Bypass voltage is outside Bypass transfer limits: %.1f V", __func__, bypass_voltage);
11291129
}
11301130
if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) {
1131-
upsdebugx(1, "Input Bypass frequency is outside Bypass transfer limits: %.1f Hz", bypass_frequency);
1131+
upsdebugx(1, "%s: Input Bypass frequency is outside Bypass transfer limits: %.1f Hz", __func__, bypass_frequency);
11321132
}
11331133
/* Disable Bypass mode switching, do not enter Bypass mode */
11341134
dstate_setinfo("input.bypass.switch.off", "off");
@@ -1151,6 +1151,76 @@ static info_lkp_t eaton_input_bypass_mode_off_info[] = {
11511151
{ 0, NULL, NULL, NULL }
11521152
};
11531153

1154+
1155+
/* Function to start ECO(HE) Mode automatically instead of manually starting Bypass and then ECO(HE) Mode */
1156+
static const char *eaton_input_eco_mode_auto_on_fun(double value)
1157+
{
1158+
const char *bypass_switch_on_str = NULL;
1159+
const char *eco_switchable_str = NULL;
1160+
1161+
/* Check if input.bypass.switch.on is disabled and set it to 'on' */
1162+
bypass_switch_on_str = dstate_getinfo("input.bypass.switch.on");
1163+
if (!strcmp(bypass_switch_on_str, "disabled")) {
1164+
bypass_switch_on_str = eaton_input_bypass_check_range(value);
1165+
} else {
1166+
upsdebugx(1, "%s: Bypass switch on state is: %s , must be disabled before switching on", __func__, bypass_switch_on_str);
1167+
return NULL;
1168+
}
1169+
1170+
/* Check if input.eco.switchable is normal and set it to 'ECO' */
1171+
eco_switchable_str = dstate_getinfo("input.eco.switchable");
1172+
if (!strcmp(eco_switchable_str, "normal")) {
1173+
eco_switchable_str = eaton_input_eco_mode_check_range(value);
1174+
} else {
1175+
upsdebugx(1, "%s: ECO switch state is: %s , must be normal before switching to ECO", __func__, eco_switchable_str);
1176+
return NULL;
1177+
}
1178+
1179+
upsdebugx(1, "%s: ECO Mode was enabled after switching to Bypass Mode", __func__);
1180+
return eco_switchable_str;
1181+
}
1182+
1183+
/* Function to stop ECO(HE) Mode automatically instead of manually stoping Bypass and then Online Mode */
1184+
static const char *eaton_input_eco_mode_auto_off_fun(double value)
1185+
{
1186+
const char *bypass_switch_off_str = NULL;
1187+
const char *eco_switchable_str = NULL;
1188+
1189+
NUT_UNUSED_VARIABLE(value);
1190+
1191+
/* Check if input.bypass.switch.off is disabled and set it to 'off' */
1192+
bypass_switch_off_str = dstate_getinfo("input.bypass.switch.off");
1193+
if (!strcmp(bypass_switch_off_str, "disabled")) {
1194+
setvar("input.bypass.switch.off", "off");
1195+
} else {
1196+
upsdebugx(1, "%s: Bypass switch off state is: %s , must be disabled before switching off", __func__, bypass_switch_off_str);
1197+
return NULL;
1198+
}
1199+
1200+
/* Check if input.eco.switchable is 'ECO' and set it to normal */
1201+
eco_switchable_str = dstate_getinfo("input.eco.switchable");
1202+
if (!strcmp(eco_switchable_str, "ECO")) {
1203+
setvar("input.eco.switchable", "normal");
1204+
buzzmode_set("vendor:mge-hid:normal");
1205+
/* Get the updated value of input.eco.switchable after setting it to "normal */
1206+
eco_switchable_str = dstate_getinfo("input.eco.switchable");
1207+
} else {
1208+
upsdebugx(1, "%s: ECO switch state is: %s , must be ECO before switching to normal", __func__, eco_switchable_str);
1209+
return NULL;
1210+
}
1211+
1212+
upsdebugx(1, "%s: ECO Mode was disabled after switching from Bypass Mode", __func__);
1213+
return eco_switchable_str;
1214+
}
1215+
1216+
/* High Efficiency (aka ECO) mode for auto start/stop commands */
1217+
static info_lkp_t eaton_input_eco_mode_auto_on_off_info[] = {
1218+
{ 0, "normal", eaton_input_eco_mode_auto_off_fun, NULL },
1219+
{ 1, "ECO", eaton_input_eco_mode_auto_on_fun, NULL },
1220+
{ 2, "ESS", NULL, NULL },
1221+
{ 0, NULL, NULL, NULL }
1222+
};
1223+
11541224
/* Determine country using UPS.PowerSummary.Country.
11551225
* If not present:
11561226
* if PowerConverter.Output.Voltage >= 200 => "Europe"
@@ -2093,6 +2163,11 @@ static hid_info_t mge_hid2nut[] =
20932163
{ "experimental.essmode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "2", HU_TYPE_CMD, NULL },
20942164
{ "experimental.essmode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, NULL },
20952165

2166+
/* Command to switch ECO(HE) Mode with switch to Automatic Bypass Mode on before */
2167+
{ "experimental.bypass.ecomode.start", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "1", HU_TYPE_CMD, eaton_input_eco_mode_auto_on_off_info },
2168+
/* Command to switch from ECO(HE) Mode with switch from Automatic Bypass Mode on before */
2169+
{ "experimental.bypass.ecomode.stop", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, eaton_input_eco_mode_auto_on_off_info },
2170+
20962171
/* Command to switch Automatic Bypass Mode on/off */
20972172
{ "bypass.start", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "1", HU_TYPE_CMD, NULL },
20982173
{ "bypass.stop", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "1", HU_TYPE_CMD, NULL },

0 commit comments

Comments
 (0)