-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
additional kwarg in trigger, strange errors #538
Comments
You compressed all these arguments into @state_trigger(
f"trigger",
f"one more optional trigger", # optional
watch=[], # optional
state_hold_false=None, # optional
state_hold=None, # optional
state_check_now=False, # optional
kwargs=dict( # <- these kwargs →→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→↓↓↓
my_kwarg='my_kwarg_value',
), # ↓↓↓
)
# ↓ are here
def my_func(trigger_type=None, var_name=None, value=None, old_value=None, context=None, **kwargs):
log.debug(kwargs['my_kwarg']) Also, I hope your variable |
Looks like #512, which is fixed but not released. Can you run the latest to confirm? |
Yes my variable 'taak' exists. |
Can I wait for the release? |
Yes, it's a little bit different from what i did. And my version works too. |
Another strange thing
in the logging i see: The last log line here:; the "my kwarg" appears again??? (this is in the same source of course.) My previous problem from above, there was for some reason, a kwargs param added to another trigger routine in another source (by pyscript) |
I have a state trigger like this:
@state_trigger(f"{entity_id}",kwargs={'taak':taak})
def waskot_switch(**kwargs):
log.info(f"kwargs={kwargs}")
....
wich I have created by trigger closure...
It works. BUT, as you see I added kwargs={'taak':taak}
Now I get an error in another script!
run_coro: got exception Traceback (most recent call last): File "/config/custom_components/pyscript/eval.py", line 726, in call raise TypeError(f"{self.name}() called with unexpected keyword arguments: {unexpected}") TypeError: waskot_auto_light_off() called with unexpected keyword arguments: taak
I had to search for waskot_auto_light_off() and it's in a complete other source and the even the word "taak" is not used in that source.
Very strange. To be sure:
So, The "waskot_Auto_light_off()" function is NOT used in the pyscript source where I added the kwargs={'taak':taak}
and the word "taak" is not used in the source where there's a function "waskot_auto_light_off()
any idea?
The text was updated successfully, but these errors were encountered: