Hi everybody, this is my first post so, please, understand my poor knowledge.
I wrote a python script. My automation passes parameters to it. What I wonder is if this script creates several instances upon concurrent calls or if the calls have to be sequential.
My target is to set and get the position of some shades via a slider input_number + STOP button.
Iād like not to replicate the script for each shade so I tried the following.
Trigger sequence is the following:
input_number + button state --> timers start/stop --> switches on/off
Iām having troubles in getting the timer.remaining attribute because I have to wait for it to appear after timer is paused; Iām waiting for it comparing remaining with duration inside a while cycle but I donāt think itās the best solution (suggestions are appreciated )
I think you should move this to appdeamon. You know python and this is complicated enough to warrant the move. Your whole automation will be in appdeamon, including your timer and you wonāt rely on home assistantās timer entities. Youāll be able to use the time class or the threading.Timer class.
Ok, letās go for another programming tool.
I started from COBOL and LISP a few days ago (decades, not days ) and after passing through FORTRAN, ASSEMBLER, C, Pascal, BASIC, Java, Python and YAML I think I can try this one too,
Thanks again for your help.
Ciao
so if i remember correctly, run_in only passes all keywargs. So in your case, a dictionary of keword arguments is getting passed to switch_off as the variable name chiave.
chiave will look like this when passed to switch_off
And just to clarify the distinction between args and kwargs:
if I make a function func(*args), anything I pass into said function will be added to a list named args. Each item passed is placed in the order that they are passed (ignore typo in middle):
kwargs are the same way, but it makes a dictionary and you HAVE to specify a kwarg.
So, the run_in function takes 2 attributes a method to run and the duration to run it in, all other attributes get plopped into kwargs. This is pretty standard practice in python apiās btw.
Ok, Iām so stupid Thatās obvious, you have a dictionary so you need to get the item through the key. Thank you very much, i was using Pascal notation for value parameters instead of Python one.