Hi,
I have couple of zwave plugs that do not always respond on first hit (on or off). so I’ve decided to build a utility function with internal timer to retry till the state changes. Just that the recursive call on the run_in fails with this error:
TypeError: turn_switch() takes 1 positional argument but 2 were given
this is the calling line on a class test:
self.utils.turn_switch(entity_id = "switch.light_kitchen_closet", action = "on")
#or
self.utils.turn_switch(entity_id = "switch.light_kitchen_closet", action = "off")
and this is the utility function on class utility (on a different module):
def turn_switch(self, **kwargs):
state = self.get_state(kwargs["entity_id"])
if kwargs["action"] == "on" and state != kwargs["action"]:
self.turn_on(kwargs["entity_id"])
self.run_in(self.turn_switch, 5, entity_id=kwargs["entity_id"], action=kwargs["action"])
elif kwargs["action"] == "off" and state != kwargs["action"]:
self.turn_off(kwargs["entity_id"])
self.run_in(self.turn_switch, 5, entity_id=kwargs["entity_id"], action=kwargs["action"])
so when AD tries to run the turn_switch after 5 seconds, it fails with the above error.
I have close to none experience with python and I don’t have a clue what am I doing wrong. Any help will be appreciated.
Thanks.
[the edit holds mentioning that the code above is on different classes and also updated the subject to a better one]