@@ -750,6 +750,45 @@ def func10d(var_name=None, value=None, trigger_type=None, context=None, old_valu
750750 )
751751
752752
753+ @pytest .mark .asyncio
754+ async def test_trigger_kwargs_none (hass ):
755+ """Test that explicit None kwargs are accepted for trigger decorators."""
756+ notify_q = asyncio .Queue (0 )
757+
758+ await setup_script (
759+ hass ,
760+ notify_q ,
761+ None ,
762+ [dt (2020 , 7 , 1 , 10 , 59 , 59 , 999998 )],
763+ """
764+ seq_num = 0
765+
766+ @state_trigger("True", watch={"pyscript.var1"})
767+ @time_active(hold_off=None)
768+ def func1(var_name=None, value=None):
769+ global seq_num
770+
771+ seq_num += 1
772+ pyscript.done = ["hold_off", seq_num, var_name, value]
773+
774+ @state_trigger("pyscript.var2 == '2'", watch=None)
775+ def func2(var_name=None, value=None):
776+ pyscript.done = ["watch_none", var_name, value]
777+ """ ,
778+ )
779+
780+ hass .bus .async_fire (EVENT_HOMEASSISTANT_STARTED )
781+ await hass .async_block_till_done ()
782+ hass .states .async_set ("pyscript.var1" , 2 )
783+ assert literal_eval (await wait_until_done (notify_q )) == ["hold_off" , 1 , "pyscript.var1" , "2" ]
784+
785+ hass .states .async_set ("pyscript.var1" , 0 )
786+ assert literal_eval (await wait_until_done (notify_q )) == ["hold_off" , 2 , "pyscript.var1" , "0" ]
787+
788+ hass .states .async_set ("pyscript.var2" , 2 )
789+ assert literal_eval (await wait_until_done (notify_q )) == ["watch_none" , "pyscript.var2" , "2" ]
790+
791+
753792@pytest .mark .asyncio
754793async def test_state_trigger_time (hass , caplog ):
755794 """Test state trigger."""
0 commit comments