Skip to content

Commit 59ce796

Browse files
committed
First pass at version upgrade script
1 parent cf823ba commit 59ce796

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

deploy/runtime/versions.lk

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
58114
version_upgrade{'2024.12.12'} = define() {
59115

60116
const cfg = config();

src/main_add.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static SamApp::ver releases[] = {
7474
//intermediate version numbers are required in this list in order for the version upgrade script (versions.lk) to work correctly
7575
//please clarify the reason for the new version in a comment. Examples: public release, variable changes, internal release, public beta release, etc.
7676
//the top version should always be the current working version
77+
{ 2025, 9, 19 }, // Placeholder for PVWatts-Battery upgrade testing (replace with release version number)
7778
{ 2025, 4, 16 }, // 2025.4.16 ssc 302 public release
7879
{ 2025, 4, 7}, // 2025.4.7 ssc 301 release candidate
7980
{ 2024, 12, 12}, // 2024.12.12 ssc 298 public release

0 commit comments

Comments
 (0)