@@ -25,9 +25,9 @@ ManualOverride manual(evse);
2525
2626long pilot = 32 ; // OpenEVSE Pilot Setting
2727long state = OPENEVSE_STATE_CONNECTED; // OpenEVSE State
28- String mqtt_solar = " " ;
29- String mqtt_grid_ie = " " ;
30- uint32_t flags ;
28+ double voltage = 240 ; // Voltage from OpenEVSE or MQTT
29+
30+ extern double smoothed_available_current ;
3131
3232int date_col = 0 ;
3333int grid_ie_col = -1 ;
@@ -38,15 +38,6 @@ time_t simulated_time = 0;
3838
3939bool kw = false ;
4040
41- extern double smoothed_available_current;
42- double divert_attack_smoothing_factor = 0.4 ;
43- double divert_decay_smoothing_factor = 0.05 ;
44- double divert_PV_ratio = 0.5 ;
45- uint32_t divert_min_charge_time = (10 * 60 );
46- double voltage = 240 ; // Voltage from OpenEVSE or MQTT
47-
48- uint32_t current_shaper_max_pwr = 0 ;
49-
5041time_t parse_date (const char *dateStr)
5142{
5243 int y = 2020 , M = 1 , d = 1 , h = 0 , m = 0 , s = 0 ;
@@ -105,6 +96,7 @@ int main(int argc, char** argv)
10596{
10697 int voltage_arg = -1 ;
10798 std::string sep = " ," ;
99+ std::string config;
108100
109101 cxxopts::Options options (argv[0 ], " - example command line options" );
110102 options
@@ -117,8 +109,7 @@ int main(int argc, char** argv)
117109 (" d,date" , " The date column" , cxxopts::value<int >(date_col), " N" )
118110 (" s,solar" , " The solar column" , cxxopts::value<int >(solar_col), " N" )
119111 (" g,gridie" , " The Grid IE column" , cxxopts::value<int >(grid_ie_col), " N" )
120- (" attack" , " The attack factor for the smoothing" , cxxopts::value<double >(divert_attack_smoothing_factor))
121- (" decay" , " The decay factor for the smoothing" , cxxopts::value<double >(divert_decay_smoothing_factor))
112+ (" c,config" , " Config options, either a file name or JSON" , cxxopts::value<std::string>(config))
122113 (" v,voltage" , " The Voltage column if < 50, else the fixed voltage" , cxxopts::value<int >(voltage_arg), " N" )
123114 (" kw" , " values are KW" )
124115 (" sep" , " Field separator" , cxxopts::value<std::string>(sep));
@@ -131,6 +122,22 @@ int main(int argc, char** argv)
131122 exit (0 );
132123 }
133124
125+ fs::EpoxyFS.begin ();
126+ config_reset ();
127+
128+ // If config is set and not a JSON string, assume it is a file name
129+ if (config.length () > 0 && config[0 ] != ' {' )
130+ {
131+ std::ifstream t (config);
132+ std::stringstream buffer;
133+ buffer << t.rdbuf ();
134+ config = buffer.str ();
135+ }
136+ // If we have some JSON load it
137+ if (config.length () > 0 && config[0 ] == ' {' ) {
138+ config_deserialize (config.c_str ());
139+ }
140+
134141 kw = result.count (" kw" ) > 0 ;
135142
136143 mqtt_solar = grid_ie_col >= 0 ? " " : " yes" ;
@@ -147,7 +154,6 @@ int main(int argc, char** argv)
147154 solar = 0 ;
148155 grid_ie = 0 ;
149156
150- fs::EpoxyFS.begin ();
151157 evse.begin ();
152158 divert.begin ();
153159
0 commit comments