@@ -55,6 +55,62 @@ function variable_name_change(new, old){
5555 value(new, oldvalue(old), 'Variable name changed from \"' + old + '\" to \"' + new + '\"');
5656}
5757
58+ version_upgrade{'2025.9.19'} = define() {
59+
60+ const cfg = config();
61+
62+ if(cfg.tech == 'PVWatts' || cfg.tech == 'PVWatts Battery') {
63+ message('We converted PVWatts to run in the GUI in lifetime mode by default.', 'warning');
64+ old_degradation = value('degradation');
65+
66+ value('dc_degradation', old_degradation, 'Update degradation from AC to DC degradation');
67+ }
68+ if (cfg.tech == 'PVWatts Battery') {
69+ message('Converting simple battery to detailed battery for configurations paired with PVWatts.', 'warning');
70+ old_kw = value('batt_simple_kw');
71+ old_kwh = value('batt_simple_kwh');
72+ old_dispatch = value('batt_simple_dispatch');
73+ old_chem = value('batt_simple_chemistry'); // batt_type
74+
75+ value('batt_bank_power', old_kw);
76+ value('batt_duration_choice', 0);
77+ value('batt_bank_duration', old_kwh);
78+
79+ message("DEBUG: " + old_dispatch + " chem: " + old_chem, 'warning');
80+
81+ // From cmod_battwatts lines 254 - 259
82+ value('batt_dispatch_auto_can_charge', true);
83+ value('batt_dispatch_auto_can_gridcharge', true);
84+ value('batt_dispatch_auto_btm_can_discharge_to_grid', true);
85+ value('batt_dispatch_auto_can_clipcharge', false);
86+ value('batt_dispatch_charge_only_system_exceeds_load', false);
87+ value('batt_dispatch_discharge_only_load_exceeds_system', false);
88+
89+
90+ if (old_dispatch == 0 || old_dispatch == 1) {
91+ value('batt_dispatch_choice_ui', 0);
92+ value('batt_dispatch_choice', 0);
93+ value('peak_shaving_batt_dispatch_choice', old_dispatch);
94+ value('batt_dispatch_load_forecast_choice_peak_shaving', old_dispatch);
95+ }
96+ else {
97+ // Should only be 2 (custom dispatch)
98+ value('batt_dispatch_choice_ui', old_dispatch);
99+ value('batt_dispatch_choice', old_dispatch);
100+
101+ }
102+ if (old_chem == 0) {
103+ // Lead Acid
104+ value('batt_type', 0);
105+
106+ }
107+ else {
108+ // Li-ion NMC
109+ value('batt_type', 8);
110+ }
111+ }
112+ };
113+
58114version_upgrade{'2024.12.12'} = define() {
59115
60116 const cfg = config();
0 commit comments