@@ -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