1212from croniter import croniter
1313
1414from homeassistant .core import Context
15- import homeassistant .helpers . sun as sun
15+ from homeassistant .helpers import sun
1616
1717from .const import LOGGER_PATH
1818from .eval import AstEval , EvalFunc , EvalFuncVar
@@ -308,7 +308,9 @@ async def wait_until(
308308 return {"trigger_type" : "state" }
309309
310310 _LOGGER .debug (
311- "trigger %s wait_until: watching vars %s" , ast_ctx .name , state_trig_ident ,
311+ "trigger %s wait_until: watching vars %s" ,
312+ ast_ctx .name ,
313+ state_trig_ident ,
312314 )
313315 if len (state_trig_ident ) > 0 :
314316 await State .notify_add (state_trig_ident , notify_q )
@@ -368,7 +370,10 @@ async def wait_until(
368370 if time_trigger is not None :
369371 time_next = cls .timer_trigger_next (time_trigger , now , startup_time )
370372 _LOGGER .debug (
371- "trigger %s wait_until time_next = %s, now = %s" , ast_ctx .name , time_next , now ,
373+ "trigger %s wait_until time_next = %s, now = %s" ,
374+ ast_ctx .name ,
375+ time_next ,
376+ now ,
372377 )
373378 if time_next is not None :
374379 this_timeout = (time_next - now ).total_seconds ()
@@ -390,7 +395,8 @@ async def wait_until(
390395 if this_timeout is None :
391396 if state_trigger is None and event_trigger is None and mqtt_trigger is None :
392397 _LOGGER .debug (
393- "trigger %s wait_until no next time - returning with none" , ast_ctx .name ,
398+ "trigger %s wait_until no next time - returning with none" ,
399+ ast_ctx .name ,
394400 )
395401 ret = {"trigger_type" : "none" }
396402 break
@@ -522,7 +528,9 @@ async def wait_until(
522528 break
523529 else :
524530 _LOGGER .error (
525- "trigger %s wait_until got unexpected queue message %s" , ast_ctx .name , notify_type ,
531+ "trigger %s wait_until got unexpected queue message %s" ,
532+ ast_ctx .name ,
533+ notify_type ,
526534 )
527535
528536 if len (state_trig_ident ) > 0 :
@@ -771,7 +779,10 @@ class TrigInfo:
771779 """Class for all trigger-decorated functions."""
772780
773781 def __init__ (
774- self , name , trig_cfg , global_ctx = None ,
782+ self ,
783+ name ,
784+ trig_cfg ,
785+ global_ctx = None ,
775786 ):
776787 """Create a new TrigInfo."""
777788 self .name = name
@@ -870,7 +881,9 @@ def __init__(
870881 if self .event_trigger is not None :
871882 if len (self .event_trigger ) == 2 :
872883 self .event_trig_expr = AstEval (
873- f"{ self .name } @event_trigger()" , self .global_ctx , logger_name = self .name ,
884+ f"{ self .name } @event_trigger()" ,
885+ self .global_ctx ,
886+ logger_name = self .name ,
874887 )
875888 Function .install_ast_funcs (self .event_trig_expr )
876889 self .event_trig_expr .parse (self .event_trigger [1 ], mode = "eval" )
@@ -883,7 +896,9 @@ def __init__(
883896 if self .mqtt_trigger is not None :
884897 if len (self .mqtt_trigger ) == 2 :
885898 self .mqtt_trig_expr = AstEval (
886- f"{ self .name } @mqtt_trigger()" , self .global_ctx , logger_name = self .name ,
899+ f"{ self .name } @mqtt_trigger()" ,
900+ self .global_ctx ,
901+ logger_name = self .name ,
887902 )
888903 Function .install_ast_funcs (self .mqtt_trig_expr )
889904 self .mqtt_trig_expr .parse (self .mqtt_trigger [1 ], mode = "eval" )
@@ -994,7 +1009,10 @@ async def trigger_watch(self):
9941009 if self .time_trigger :
9951010 time_next = TrigTime .timer_trigger_next (self .time_trigger , now , startup_time )
9961011 _LOGGER .debug (
997- "trigger %s time_next = %s, now = %s" , self .name , time_next , now ,
1012+ "trigger %s time_next = %s, now = %s" ,
1013+ self .name ,
1014+ time_next ,
1015+ now ,
9981016 )
9991017 if time_next is not None :
10001018 timeout = (time_next - now ).total_seconds ()
@@ -1157,7 +1175,9 @@ async def trigger_watch(self):
11571175
11581176 if not trig_ok :
11591177 _LOGGER .debug (
1160- "trigger %s got %s trigger, but not active" , self .name , notify_type ,
1178+ "trigger %s got %s trigger, but not active" ,
1179+ self .name ,
1180+ notify_type ,
11611181 )
11621182 continue
11631183
@@ -1231,7 +1251,10 @@ def call_action(self, notify_type, func_args, run_task=True):
12311251 Function .hass .bus .async_fire ("pyscript_running" , event_data , context = hass_context )
12321252
12331253 _LOGGER .debug (
1234- "trigger %s got %s trigger, running action (kwargs = %s)" , self .name , notify_type , func_args ,
1254+ "trigger %s got %s trigger, running action (kwargs = %s)" ,
1255+ self .name ,
1256+ notify_type ,
1257+ func_args ,
12351258 )
12361259
12371260 async def do_func_call (func , ast_ctx , task_unique , task_unique_func , hass_context , ** kwargs ):
@@ -1245,7 +1268,12 @@ async def do_func_call(func, ast_ctx, task_unique, task_unique_func, hass_contex
12451268 ast_ctx .get_logger ().error (ast_ctx .get_exception_long ())
12461269
12471270 func = do_func_call (
1248- self .action , action_ast_ctx , self .task_unique , task_unique_func , hass_context , ** func_args ,
1271+ self .action ,
1272+ action_ast_ctx ,
1273+ self .task_unique ,
1274+ task_unique_func ,
1275+ hass_context ,
1276+ ** func_args ,
12491277 )
12501278 if run_task :
12511279 task = Function .create_task (func , ast_ctx = action_ast_ctx )
0 commit comments