@@ -209,14 +209,16 @@ def glob_files(load_paths, config):
209209 rel_import_path = f"{ path } /mod_name"
210210 if path == "" :
211211 global_ctx_name = f"file.{ mod_name } "
212+ fq_mod_name = mod_name
212213 else :
213214 global_ctx_name = f"{ path } .{ mod_name } "
215+ fq_mod_name = global_ctx_name
214216 if check_config :
215217 _LOGGER .debug ("load_scripts: checking %s in %s" , mod_name , apps_config )
216218 if not isinstance (apps_config , dict ) or mod_name not in apps_config :
217219 _LOGGER .debug ("load_scripts: skipping %s because config not present" , this_path )
218220 continue
219- source_files .append ([global_ctx_name , this_path , rel_import_path ])
221+ source_files .append ([global_ctx_name , this_path , rel_import_path , fq_mod_name ])
220222 return source_files
221223
222224 load_paths = [
@@ -226,8 +228,11 @@ def glob_files(load_paths, config):
226228 ]
227229
228230 source_files = await hass .async_add_executor_job (glob_files , load_paths , config )
229- for global_ctx_name , source_file , rel_import_path in source_files :
231+ for global_ctx_name , source_file , rel_import_path , fq_mod_name in source_files :
230232 global_ctx = GlobalContext (
231- global_ctx_name , global_sym_table = {}, manager = GlobalContextMgr , rel_import_path = rel_import_path
233+ global_ctx_name ,
234+ global_sym_table = {"__name__" : fq_mod_name },
235+ manager = GlobalContextMgr ,
236+ rel_import_path = rel_import_path ,
232237 )
233238 await GlobalContextMgr .load_file (source_file , global_ctx )
0 commit comments