Help with run_in vs run_minutely in appdaemon [SOLVED]

Hi all,
I have code that runs in run_minutely but not in run_in. Any thoughts appreciated!

This works:
self.run_minutely(self.switchOn, timeOn)

This also works:
self.run_in(self.switchOn, 10)

This does not work:
self.run_in(self.switchOn, timeOn)

Error message:

2018-10-06 10:57:25.616785 WARNING AppDaemon: ------------------------------------------------------------
2018-10-06 10:57:25.617632 WARNING AppDaemon: Unexpected error running initialize() for irr_valve_5
2018-10-06 10:57:25.618345 WARNING AppDaemon: ------------------------------------------------------------
2018-10-06 10:57:25.619820 WARNING AppDaemon: Traceback (most recent call last):
File “/srv/appdaemon/lib/python3.6/site-packages/appdaemon/”, line 1575, in init_object
File “/home/piha/conf/apps/”, line 23, in initialize
self.run_in(self.switchOn, timeOn)
File “/srv/appdaemon/lib/python3.6/site-packages/appdaemon/”, line 322, in run_in
exec_time = self.get_now_ts() + int(seconds)
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘datetime.time’

2018-10-06 10:57:25.620511 WARNING AppDaemon: ------------------------------------------------------------

Full code:

import appdaemon.plugins.hass.hassapi as hass
import datetime

# Garden irrigation App
# Program by: Sean McGrath
# Created: 03-10-2018
# Args: valve

class irrigationValves(hass.Hass):
  def initialize(self):
    self.log("Starting {} with valve {}".format(, self.args["valve"]))
    timeOn = datetime.time(0, 0, 10)
    timeOff = datetime.time(0, 0, 30)
    self.run_in(self.switchOn, 10)
#    self.run_minutely(self.switchOn, timeOn)
#    self.run_in(self.switchOn, timeOn)
    self.run_minutely(self.switchOff, timeOff)
  def terminate(self):
    thisValve = "switch."+self.args["valve"]
    self.log("Terminating {} with valve {}".format(, thisValve))

  def switchOn (self, payload_on):
    thisValve = "switch."+self.args["valve"]
    self.log("We had {} mm of rain today".format(precipitation))
    if precipitation == 0:

  def switchOff (self, payload_off):
    thisValve = "switch."+self.args["valve"]
    self.log("Turning off")

This means the argument must be an int (like 10, or a variable defined as an int), not a datetime object, which is what timeOn is defined as.

Thanks, GP. That part I get. What I don’t understand is that it works for run_minutely. Do the two functions have different requirements? I don’t see that in the documentation.


Oh, I think I get it now. Run is a “defined number of seconds” but run_minutely is “the same time.” I was using the API documentation; maybe Github is a better place for me to understand what inputs are accepted?

The official documentation is here

Yes, as I mentioned, that is what I was using.

Looking closer, all of the “run_” functions describe the duration or start interval as " A Python xxx object" except for run_in. It assumes you know that it requires an integer or a string for seconds.

if you provide an amount its always an int, if you provide a starttime its always a time object.

it could be translated to words but there are also examples provided where the run_in is set with 10 (for 10 seconds) and where the other functions are set with a time object.

but if you got an idea how to improve the docs then i know that Andrew would be glad about a PR.

Thanks, Rene. Yes, I am making notes for myself about where I found the docs not explicit enough. Right now I am trying to teach myself linux to run my Pi, the arduino SDK, HA, MQTT, Python, tinkercad design to 3D print a case for my Pi and appdaemon, none of which I have ever done before – so my head is already exploding :stuck_out_tongue:

Once the dust settles, I’ll try to figure out how best to give documentation feedback and share my notes with Andrew.

1 Like

i know the feeling
i did learn myself all those things around 2, 3 years ago and its really overwhelming.
i didnt learn tinkercad because i still dont own a 3D but i also needed to learn JS and CSS

its still confusing sometimes :wink: