I managed to get an app working which could execute actions on Homeassistant dynamically based on either a delay or a give date/time.
This app requires the latest REST-API support to be enabled on Appdaemon to work:
DelayScheduler:
import appdaemon.appapi as appapi
import datetime
class Scheduler(appapi.AppDaemon):
def initialize(self):
self.log("Hello from AppDaemon Scheduler")
def api_call(self,data):
self.log("{}".format(data))
def execute(kwargs):
self.log("Executing Dynamic Callback")
serv=kwargs.pop('service',None)
self.call_service(serv,**kwargs)
delay=data.pop("delay",0)
self.run_in(execute,delay,**data)
return {"message":"Success"},200
Payload:
{"service":"homeassistant/toggle","entity_id":"switch.fan","delay":2}
Time Based scheduler:
import appdaemon.appapi as appapi
import datetime
class TimeScheduler(appapi.AppDaemon):
def initialize(self):
self.log("Hello from AppDaemon Time Scheduler")
def api_call(self,data):
self.log("{}".format(data))
def execute(kwargs):
self.log("Executing Dynamic Callback")
serv=kwargs.pop('service',None)
self.log("{}".format(serv))
self.call_service(serv,**kwargs)
time=self.parse_time(data.pop('time'))
if isinstance(time,datetime.time):
runtime=datetime.datetime.combine(datetime.date.today(),time)
self.run_at(execute,runtime,**data)
return {"message":"Success"},200
Payload:
{"service":"homeassistant/toggle","entity_id":"switch.fan","time":"18:45:00"}
This will enable you to execute any domain service using voice commands using alexa/google home:
Imagine saying things like : turn off tv in 5 minutes or open garage in 2 minutes