REST API for appdaemon?

Similar to how we can control devices using the REST API which hass exposes, it would be a good if appdeamon similarly had an API which could possibly allow us to execute apps remotely.

I want to use the scheduling options which appdaemon exposes through a rest API, is there already a way to do it?

I’ve thought about it but never had a reason to do it. What is on the other ne of the rest API?

It’s probably possible to use HASSs API to fire a custom event and have AppDaemon react to that.

You could run a separate instance of appdaemon on the remote machine, rather than talking to one appdaemon instance.

I want to trigger things remotely not run the apps remotely

Based on @aimc’s suggestion, I came up with the following to dynamically schedule callbacks

import requests

class Scheduler(appapi.AppDaemon):
   def initialize(self):
       self.log("Hello from AppDaemon Scheduler")
       self.listen_event(self.add_schedule,"schedule")
       
   def add_schedule(self, event_name, data, kwargs):
       self.log("{}".format(data))
       def execute(*args,**kwargs):
           self.call_service("{}/{}".format(data['domain'],data['service']),entity_id=data['entity_id'])
       self.sched_handle=self.run_in(execute,data['delay'])


The event is schedule and payload looks something like this:
{"domain":"homeassistant","service":"turn_off","entity_id":"switch.fan","delay":2}

2 Likes

Cool! Pretty much exactly what I was thinking :slight_smile:

OK, just to revisit this -Today I decided to add Alexa support to AppDaemon and as a result decided I would add generic REST support rather than making this specific to Amazon, so long story short, I have a reason to add a REST API finally, will be in the next release.

Thats awesome news @aimc … Would look forward to it