Try2Fly
(Try2 Fly)
April 14, 2018, 6:43pm
1
Hi, I’m having trouble with the run_in function, it does not delay the callback, but turns my light of immediately. I’m using appdaemon 3 on Hassio.
my code:
def bios_on(self, event_name, data, kwargs):
self.turn_off("light.table")
self.turn_off("light.spots")
self.log("lights off")
self.run_in(self.turn_off("light.shelf"), 15)
self.log("shelf off")
Log:
2018-04-14 20:35:30.054364 INFO AppDaemon: Initializing app bios using class BIOS from module bios
2018-04-14 20:35:33.086720 INFO bios: lights off
2018-04-14 20:35:33.463297 INFO bios: shelf off
The shelf light is turned of directly after the spots. Am I doing something wrong?
sj3fk3
(Greg)
April 14, 2018, 7:10pm
2
self.log("shelf off")
Will execute right away.
self.run_in(self.turn_off("light.shelf"), 15)
should execute 15 seconds later? The log does not help, it’s not delayed
Try2Fly
(Try2 Fly)
April 14, 2018, 7:16pm
3
yes, thought so was not sure. But any way, the delay does not work
def bios_on(self, event_name, data, kwargs):
self.turn_off("light.table")
self.turn_off("light.spots")
self.log("lights off")
self.run_in(self.log("shelf off"), 15)
2018-04-14 21:14:13.720362 INFO bios: lights off
2018-04-14 21:14:13.731334 INFO bios: shelf off
eBoon
(Tom K)
April 14, 2018, 7:18pm
4
Try2Fly:
my code:
def bios_on(self, event_name, data, kwargs):
self.turn_off(“light.table”)
self.turn_off(“light.spots”)
self.log(“lights off”)
self.run_in(self.turn_off(“light.shelf”), 15)
self.log(“shelf off”)
You must define a function for the run_in - you can’t call turn_off directly. So something like this:
def bios_on(self, event_name, data, kwargs):
self.turn_off("light.table")
self.turn_off("light.spots")
self.log("lights off")
self.run_in(self.turn_off_shelf, 15)
def turn_off_shelf(self,entity, attribute, old, new, kwargs):
self.turn_off("light.shelf")
self.log("shelf off")
That should be close …
1 Like
Try2Fly
(Try2 Fly)
April 14, 2018, 7:30pm
5
Thanks, this did the trick!
def turn_off_shelf(self, kwargs):
self.turn_off("light.shelf")
1 Like