I would expect to see my difficult_off function run 60 seconds after the hvac_mode stuff but in the logs it happens immediately after, no pause at all. Why?
2018-12-16 10:06:19.776011 INFO modes: Received mode change request from HA: Night
2018-12-16 10:06:19.812473 INFO modes: Turning lights off
2018-12-16 10:06:20.909365 INFO modes: Turning hold switches off
2018-12-16 10:06:21.419795 INFO modes: Spam Rheem Mode: off
2018-12-16 10:06:21.464426 INFO modes: Spam Rheem Mode: off
2018-12-16 10:06:21.497216 INFO modes: Spam Rheem Mode: off
2018-12-16 10:06:21.814941 INFO modes: Turning difficult lights off
As I said, if you use parentheses, the function gets called, and the result of the function is used as the parameter to the run_in function.
You want the parameter to the run_in function to be the name of the difficult_off function, so that run_in will call that function at the appropriate time.
So it’s just a convention that you should create your functions as:
def my_func(self, kwargs):
do something, maybe using muh kwargs
because this is what appDaemon functions like run_in expect?
From the larger python perspective, I’m still unclear why/when you pass things to a function using a parameter or using a kwargs dictionary. Why are things like entity, attribute, old, and new explicitly parameterized and not just kwargs?
OK cool thx. I’m just trying to get the structure here organized in my head. Since I’m new to both AppDaemon and Python, I can’t quite tell what’s a required part of python, what’s a typical python convention, and what’s an AppDaemon convention.
You’re explanation makes sense as a line of demarcation between params and kwargs. It seems like a reasonable choice to me.