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/appdaemon.py”, line 1575, in init_object
init()
File “/home/piha/conf/apps/irrigation.py”, line 23, in initialize
self.run_in(self.switchOn, timeOn)
File “/srv/appdaemon/lib/python3.6/site-packages/appdaemon/appapi.py”, 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.name, 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(self.name, thisValve)) def switchOn (self, payload_on): thisValve = "switch."+self.args["valve"] precipitation=float(self.entities.sensor.buienradar_precipitation.state) self.log("We had {} mm of rain today".format(precipitation)) if precipitation == 0: self.turn_on(thisValve) def switchOff (self, payload_off): thisValve = "switch."+self.args["valve"] self.log("Turning off") self.turn_off(thisValve)