A number of api calls are native to AppDaemon and will exist in any App as they are inherited through the plugin API. If the get_plugin_api()
style of declarations is used, these functions will become available via an object created by the get_ad_api()
call:
import adbase as ad
import adapi as adapi
class Test(ad.ADBase):
def initialize(self):
adbase = self.get_ad_api()
handle = self.adbase.run_in(callback, 20)
These calls are documented below.
To create apps based on just the AppDaemon base API, use some code like the following:
import adbase as ad
class MyApp(ad.ADBase):
def initialize(self):
appdaemon.adapi.ADAPI.get_state
appdaemon.adapi.ADAPI.set_state
appdaemon.adapi.ADAPI.listen_state
appdaemon.adapi.ADAPI.cancel_listen_state
appdaemon.adapi.ADAPI.info_listen_state
appdaemon.adapi.ADAPI.parse_utc_string
appdaemon.adapi.ADAPI.get_tz_offset
appdaemon.adapi.ADAPI.convert_utc
appdaemon.adapi.ADAPI.sun_up
appdaemon.adapi.ADAPI.sun_down
appdaemon.adapi.ADAPI.parse_time
appdaemon.adapi.ADAPI.parse_datetime
appdaemon.adapi.ADAPI.get_now
appdaemon.adapi.ADAPI.get_now_ts
appdaemon.adapi.ADAPI.now_is_between
appdaemon.adapi.ADAPI.sunrise
appdaemon.adapi.ADAPI.sunset
appdaemon.adapi.ADAPI.time
appdaemon.adapi.ADAPI.datetime
appdaemon.adapi.ADAPI.date
appdaemon.adapi.ADAPI.get_timezone
appdaemon.adapi.ADAPI.cancel_timer
appdaemon.adapi.ADAPI.info_timer
appdaemon.adapi.ADAPI.run_in
appdaemon.adapi.ADAPI.run_once
appdaemon.adapi.ADAPI.run_at
appdaemon.adapi.ADAPI.run_daily
appdaemon.adapi.ADAPI.run_hourly
appdaemon.adapi.ADAPI.run_minutely
appdaemon.adapi.ADAPI.run_every
appdaemon.adapi.ADAPI.run_at_sunset
appdaemon.adapi.ADAPI.run_at_sunrise
appdaemon.adapi.ADAPI.register_service
appdaemon.adapi.ADAPI.list_services
appdaemon.adapi.ADAPI.call_service
appdaemon.adapi.ADAPI.run_sequence
appdaemon.adapi.ADAPI.cancel_sequence
appdaemon.adapi.ADAPI.listen_event
appdaemon.adapi.ADAPI.cancel_listen_event
appdaemon.adapi.ADAPI.info_listen_event
appdaemon.adapi.ADAPI.fire_event
appdaemon.adapi.ADAPI.log
appdaemon.adapi.ADAPI.error
appdaemon.adapi.ADAPI.listen_log
appdaemon.adapi.ADAPI.cancel_listen_log
appdaemon.adapi.ADAPI.get_main_log
appdaemon.adapi.ADAPI.get_error_log
appdaemon.adapi.ADAPI.get_user_log
appdaemon.adapi.ADAPI.set_log_level
appdaemon.adapi.ADAPI.set_error_level
appdaemon.adapi.ADAPI.dash_navigate
appdaemon.adapi.ADAPI.set_namespace
appdaemon.adapi.ADAPI.get_namespace
appdaemon.adapi.ADAPI.list_namespaces
appdaemon.adapi.ADAPI.save_namespace
Note: A service call always uses the app's default namespace. Although namespaces allow a new and easy way to work with multiple namespaces from within a single App, it is essential to understand how they work before using them in service's calls. See the section on namespaces for a detailed description.
AppDaemon has a predefined list of namespaces that can be used only for particular services. Listed below are the services by namespace.
appdaemon
namespace only:
app/start
Starts an app that has been terminated. The app name arg is required.
>>> self.call_service("app/start", app="light_app", namespace="appdaemon")
app/stop
Stops a running app. The app name arg is required.
>>> self.call_service("app/stop", app="light_app", namespace="appdaemon")
app/restart
Restarts a running app. This service basically stops and starts the app. The app name arg is required.
>>> self.call_service("app/restart", app="light_app", namespace="appdaemon")
app/reload
Checks for an app update. Useful if AD is running in production mode, and app changes need to be checked and loaded.
>>> self.call_service("app/reload", namespace="appdaemon")
production_mode/set
Sets the production mode AD is running on. The value of the mode arg has to be `True` or `False`.
>>> self.call_service("production_mode/set", mode=True, namespace="appdaemon")
All namespaces except appdaemon
, global
, and admin
:
state/set
Sets the state of an entity. This service allows any key-worded args to define what entity's values need to be set.
>>> self.call_service("state/set", entity_id="sensor.test", state="on", attributes={"friendly_name" : "Sensor Test"}, namespace="default")
All namespaces except appdaemon
:
event/fire
Fires an event within the specified namespace. The event arg is required.
>>> self.call_service("event/fire", event="test_event", entity_id="appdaemon.test", namespace="hass")
rules
namespace only:
sequence/run
Runs a predefined sequence. The entity_id arg with the sequence full-qualified entity name is required.
>>> self.call_service("sequence/run", entity_id ="sequence.christmas_lights", namespace="rules")
appdaemon.adapi.ADAPI.set_app_pin
appdaemon.adapi.ADAPI.get_app_pin
appdaemon.adapi.ADAPI.set_pin_thread
appdaemon.adapi.ADAPI.get_pin_thread
appdaemon.adapi.ADAPI.create_task
appdaemon.adapi.ADAPI.run_in_executor
appdaemon.adapi.ADAPI.sleep
appdaemon.adapi.ADAPI.get_app
appdaemon.adapi.ADAPI.get_ad_version
appdaemon.adapi.ADAPI.entity_exists
appdaemon.adapi.ADAPI.split_entity
appdaemon.adapi.ADAPI.remove_entity
appdaemon.adapi.ADAPI.split_device_list
appdaemon.adapi.ADAPI.get_plugin_config
appdaemon.adapi.ADAPI.friendly_name
appdaemon.adapi.ADAPI.set_production_mode
appdaemon.adapi.ADAPI.start_app
appdaemon.adapi.ADAPI.stop_app
appdaemon.adapi.ADAPI.restart_app
appdaemon.adapi.ADAPI.reload_apps
Dialogflow ~~~~~
appdaemon.adapi.ADAPI.get_dialogflow_intent
appdaemon.adapi.ADAPI.get_dialogflow_slot_value
appdaemon.adapi.ADAPI.format_dialogflow_response
appdaemon.adapi.ADAPI.get_alexa_intent
appdaemon.adapi.ADAPI.get_alexa_slot_value
appdaemon.adapi.ADAPI.format_alexa_response
appdaemon.adapi.ADAPI.get_alexa_error
appdaemon.adapi.ADAPI.register_endpoint
appdaemon.adapi.ADAPI.unregister_endpoint
appdaemon.adapi.ADAPI.run_in_thread
appdaemon.adapi.ADAPI.get_thread_info
appdaemon.adapi.ADAPI.get_scheduler_entries
appdaemon.adapi.ADAPI.get_callback_entries
appdaemon.adapi.ADAPI.depends_on_module