Hi all,
I have the following code that works (the turn_off_in turns off the light in 5 seconds):
self.turn_on("light.eetkamer_spots_1")
self.turn_off_in("light.eetkamer_spots_1", 5)
The implementation of turn_off_in is as follows:
def turn_off(self, *args):
self.hass.turn_off(*args)
def turn_off_in(self, entity_id, delay):
self.run_in(self.turn_off_handler, delay, entity_id=entity_id)
def turn_off_handler(self, kwargs):
self.turn_off(kwargs["entity_id"])
I have this method:
self.turn_on()
self.turn_off_in(self.get_mosquitto_switch(), 3600)
which fails with the following exception and I don’t understand why:
2019-10-14 23:26:27.153933 INFO room_automation: Antimuggen automation slaapkamer_2 only started for one hour due to window closed.
2019-10-15 00:26:27.164018 WARNING AppDaemon: ------------------------------------------------------------
2019-10-15 00:26:27.164300 WARNING AppDaemon: Unexpected error in worker for App room_automation:
2019-10-15 00:26:27.164506 WARNING AppDaemon: Worker Ags: {'name': 'room_automation', 'id': UUID('8e9f6d8e-25f9-416a-9576-a742f259692f'), 'type': 'timer', 'function': <bound method AbstractModule.turn_off_handler of <room_automation.MosquittoKiller object at 0x7faca806d198>>, 'kwargs': {'entity_id': 'switch.slaapkamer_2_antimuggen'}}
2019-10-15 00:26:27.164687 WARNING AppDaemon: ------------------------------------------------------------
2019-10-15 00:26:27.165295 WARNING AppDaemon: Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 586, in worker
funcref(self.sanitize_timer_kwargs(app, args["kwargs"]))
File "/conf/apps/room_automation.py", line 84, in turn_off_handler
self.turn_off(kwargs["entity_id"])
TypeError: turn_off() takes 1 positional argument but 2 were given
2019-10-15 00:26:27.165548 WARNING AppDaemon: ------------------------------------------------------------
Thanks in advance for your help…