@@ -227,7 +227,7 @@ def main(self): # noqa: C901
227227 "-D" ,
228228 "--debug" ,
229229 help = "global debug level" ,
230- default = "INFO" ,
230+ # default="INFO",
231231 choices = ["DEBUG" , "INFO" , "WARNING" , "ERROR" , "CRITICAL" ],
232232 )
233233 parser .add_argument ("-m" , "--moduledebug" , nargs = 2 , action = "append" )
@@ -283,7 +283,7 @@ def main(self): # noqa: C901
283283 config = {
284284 k : v if v is not None else {}
285285 for k , v in config .items ()
286- } # fmt: skip
286+ } # fmt: skip
287287
288288 ad_kwargs = config ["appdaemon" ]
289289
@@ -299,7 +299,13 @@ def main(self): # noqa: C901
299299 ad_kwargs ["endtime" ] = args .endtime
300300
301301 ad_kwargs ["stop_function" ] = self .stop
302- ad_kwargs ["loglevel" ] = args .debug
302+
303+ if args .debug is not None :
304+ ad_kwargs ["loglevel" ] = args .debug
305+ elif "loglevel" in ad_kwargs :
306+ pass
307+ else :
308+ ad_kwargs ["loglevel" ] = "INFO"
303309
304310 if args .moduledebug is not None :
305311 module_debug_cli = {arg [0 ]: arg [1 ] for arg in args .moduledebug }
@@ -319,9 +325,9 @@ def main(self): # noqa: C901
319325
320326 model = MainConfig .model_validate (config )
321327
322- if args . debug . upper () == "DEBUG" :
328+ if ad_kwargs [ "loglevel" ] == "DEBUG" :
323329 # need to dump as python types or serializing the timezone object will fail
324- model_json = model .model_dump (mode = ' python' , by_alias = True )
330+ model_json = model .model_dump (mode = " python" , by_alias = True )
325331 print (json .dumps (model_json , indent = 4 , default = str , sort_keys = True ))
326332 except ValidationError as e :
327333 print (f"Configuration error in: { config_file } " )
@@ -335,7 +341,7 @@ def main(self): # noqa: C901
335341 print (e )
336342 sys .exit (1 )
337343
338- log_cfg = model .model_dump (mode = ' python' , by_alias = True )[' logs' ]
344+ log_cfg = model .model_dump (mode = " python" , by_alias = True )[" logs" ]
339345 self .logging = Logging (log_cfg , args .debug )
340346 self .logger = self .logging .get_logger ()
341347
@@ -365,7 +371,7 @@ def main(self): # noqa: C901
365371 self .logger .debug ("AppDaemon Section: %s" , config .get ("appdaemon" ))
366372 self .logger .debug ("HADashboard Section: %s" , config .get ("hadashboard" ))
367373
368- dump_kwargs = dict (mode = ' json' , by_alias = True , exclude_unset = True )
374+ dump_kwargs = dict (mode = " json" , by_alias = True , exclude_unset = True )
369375
370376 if (hadashboard := model .hadashboard ) is not None :
371377 hadashboard = hadashboard .model_dump (** dump_kwargs )
0 commit comments