|
|
(One intermediate revision by one other user not shown) |
Line 1: |
Line 1: |
− | ==Provided Methods==
| + | |
− | ===<code>createAccessToken</code>===
| + | <big>'''We're moving!''' Please visit http://docs2.hubitat.com for the latest documentation.</big> |
− | :Creates an OAuth access token that can be used as part of the OAuth functionality of a properly configured app. The function will return the token, but will also automatically set the state variable <code>state.accessToken</code> to the return value. This value can then be passed to any API Endpoint (for example those defined in the <code>mappings</code> section of an app) using a query string parameter called <code>access_token</code>.
| |
| | | |
− | :;Signature
| + | <big>This document is available at: http://docs2.hubitat.com/en/developer/app/app-object</big> |
− | :: <code>String createAccessToken()</code>
| |
− | | |
− | :;Parameters
| |
− | ::None
| |
− | | |
− | :;Returns
| |
− | ::The OAuth access token.
| |
− | | |
− | ===<code>getApiServerUrl</code>===
| |
− | :Returns the base URL of the Hubitat cloud API.
| |
− | | |
− | :;Signature
| |
− | :: <code>String getApiServerUrl()</code>
| |
− | | |
− | :;Parameters
| |
− | ::None
| |
− | | |
− | :;Returns
| |
− | ::The base URL of the Hubitat cloud API, generally https<span>://</span>cloud.hubitat.com/api
| |
− | | |
− | ===<code>getFullApiServerUrl</code>===
| |
− | :Returns the full URL of the Hubitat cloud API for a specific App.
| |
− | | |
− | :;Signature
| |
− | :: <code>String getFullApiServerUrl()</code>
| |
− | | |
− | :;Parameters
| |
− | ::None
| |
− | | |
− | :;Returns
| |
− | ::The URL of the Hubitat cloud API for the app, generally https<span>://</span>cloud.hubitat.com/api/<code>hubid</code>/apps/<code>appid</code>
| |
− | | |
− | ===<code>getLocalApiServerUrl</code>===
| |
− | :Returns the base URL of the Hubitat local API.
| |
− | | |
− | :;Signature
| |
− | :: <code>String getLocalApiServerUrl()</code>
| |
− | | |
− | :;Parameters
| |
− | ::None
| |
− | | |
− | :;Returns
| |
− | ::The base URL of the Hubitat local API, generally https<span>://</span><code>hubip</code>/apps/api
| |
− | | |
− | ===<code>getFullLocalApiServerUrl</code>===
| |
− | :Returns the base URL of the Hubitat local API for a specific App.
| |
− | | |
− | :;Signature
| |
− | :: <code>String getFullLocalApiServerUrl()</code>
| |
− | | |
− | :;Parameters
| |
− | ::None
| |
− | | |
− | :;Returns
| |
− | ::he URL of the Hubitat local API for the app, generally generally https<span>://</span><code>hubip</code>/apps/api/<code>appid</code>
| |
− | | |
− | ===<code>getHubUID</code>===
| |
− | :Retrieves a unique identifier that represents your hub.
| |
− | | |
− | :;Signature
| |
− | :: <code>String getHubUID()</code>
| |
− | | |
− | :;Parameters
| |
− | :: None
| |
− | | |
− | :;Returns
| |
− | :: A UUID that uniquely identifies your hub.
| |
− | | |
− | ===<code>subscribe</code>===
| |
− | :Subscribe to events sent from a device, app or location.
| |
− | | |
− | :;Signature
| |
− | :: <code>void subscribe(InstalledAppWrapper app, handlerMethod)</code>
| |
− | :: <code>void subscribe(Location location, handlerMethod)</code>
| |
− | :: <code>void subscribe(DeviceWrapper device, String handlerMethod, Map options = null)</code> (Since 2.2.1)
| |
− | :: <code>void subscribe(DeviceWrapperList devices, String handlerMethod, Map options = null)</code> (Since 2.2.1)
| |
− | :: <code>void subscribe(DeviceWrapper device, String attributeName, handlerMethod, Map options = null)</code>
| |
− | :: <code>void subscribe(DeviceWrapperList devices, String attributeName, handlerMethod, Map options = null)</code>
| |
− | :: <code>void subscribe(Location location, String attributeName, handlerMethod, Map options = null)</code>
| |
− | | |
− | | |
− | :;Parameters
| |
− | ::app - Installed App to subscribe to.
| |
− | ::location - Location to subscribe to.
| |
− | ::device - Device to subscribe to.
| |
− | ::handlerMethod - The method to run when an event is received.
| |
− | ::attributeName - The name of the attribute to subscribe to.
| |
− | ::options - Optional values to configure the subscribe. Possible values:
| |
− | :::''filterEvents'' - Used for device subscriptions. Set to false to receive all events, defaults to true and events that do not have a changed value will not be processed.
| |
− | | |
− | ===<code>unsubscribe</code>===
| |
− | :Unsubscribe from events sent from a device or all event subscriptions.
| |
− | | |
− | :;Signature
| |
− | :: <code>void unsubscribe()</code>
| |
− | :: <code>void unsubscribe(DeviceWrapper device)</code>
| |
− | :: <code>void unsubscribe(List<DeviceWrapper> deviceList)</code>
| |
− | :: <code>void unsubscribe(DeviceWrapper device, String attributeName)</code> (Since 2.0.7)
| |
− | :: <code>void unsubscribe(List<DeviceWrapper> deviceList, String attributeName)</code> (Since 2.1.0)
| |
− | :: <code>void unsubscribe(DeviceWrapper device, String attributeName, String handlerMethod)</code> (Since 2.1.0)
| |
− | :: <code>void unsubscribe(List<DeviceWrapper> deviceList, String attributeName, String handlerMethod)</code> (Since 2.1.0)
| |
− | :: <code>void unsubscribe(InstalledAppWrapper installedApp)</code> (Since 2.1.2)
| |
− | :: <code>void unsubscribe(Location location)</code> (Since 2.1.2)
| |
− | :: <code>void unsubscribe(Location location, String attributeName)</code> (Since 2.1.2)
| |
− | :: <code>void unsubscribe(String handlerMethod)</code> (Since 2.1.2)
| |
− | | |
− | :;Parameters
| |
− | ::device - The device to unsubscribe from.
| |
− | ::deviceList - A list of devices to unsubscribe from.
| |
− | ::attributeName - which attribute you want to unsubscribe from.
| |
− | ::handlerMethod - The name of a method which was subscribed to a device event.
| |
− | ::location - The location to unsubscribe from.
| |
− | ::installedApp - The installed app to unsubscribe from.
| |
− | | |
− | :;Returns
| |
− | ::None
| |
− | | |
− | ===<code>addChildDevice</code>===
| |
− | :Creates a new child device and returns that device from the method call.
| |
− | | |
− | :;Signature
| |
− | :: <code>ChildDeviceWrapper addChildDevice(String namespace, String typeName, String deviceNetworkId)</code> (since 2.1.9)
| |
− | :: <code>ChildDeviceWrapper addChildDevice(String namespace, String typeName, String deviceNetworkId, Map properties)</code> (since 2.1.9)
| |
− | :: <code>ChildDeviceWrapper addChildDevice(String namespace, String typeName, String deviceNetworkId, Long hubId)</code> (deprecated)
| |
− | :: <code>ChildDeviceWrapper addChildDevice(String namespace, String typeName, String deviceNetworkId, Long hubId, Map properties)</code> (deprecated)
| |
− | | |
− | :;Parameters
| |
− | ::namespace - The namespace of the child driver to add as a child device (optional, if not specified it will default the the namespace of the parent)
| |
− | ::typeName - The name of the child driver to add as a child device
| |
− | ::deviceNetworkId - unique identifier for this device
| |
− | ::hubId - present for backwards compatibility, pass 1.
| |
− | ::properties - optional parameters for this child device. Possible values listed below
| |
− | | |
− | :;Properties
| |
− | ::boolean isComponent - true or false, if true, device will still show up in device list but will not be able to be deleted or edited in the UI. If false, device can be modified/deleted on the UI.
| |
− | ::String name - name of child device, if not specified, driver name is used.
| |
− | ::String label - label of child device, if not specified it is left blank.
| |
− | | |
− | :;Returns
| |
− | ::ChildDeviceWrapper
| |
− | | |
− | ===<code>getChildDevices</code>===
| |
− | :Gets a list of all child devices for this device.
| |
− | | |
− | :;Signature
| |
− | :: <code>List<ChildDeviceWrapper> getChildDevices()</code>
| |
− | :: <code>List<ChildDeviceWrapper> getAllChildDevices()</code>
| |
− | | |
− | :;Parameters
| |
− | ::None
| |
− | | |
− | :;Returns
| |
− | ::List<ChildDeviceWrapper>
| |
− | | |
− | ===<code>getChildDevice</code>===
| |
− | :Gets a specific child device with the device network id specified.
| |
− | | |
− | :;Signature
| |
− | :: <code>ChildDeviceWrapper getChildDevice(String deviceNetworkId)</code>
| |
− | | |
− | :;Parameters
| |
− | ::deviceNetworkId - The unique identifier for the device
| |
− | | |
− | :;Returns
| |
− | ::ChildDeviceWrapper
| |
− | | |
− | ===<code>deleteChildDevice</code>===
| |
− | :Deletes a specific child device with the device network id sepcified.
| |
− | | |
− | :;Signature
| |
− | :: <code>void deleteChildDevice(String deviceNetworkId)</code>
| |
− | | |
− | :;Parameters
| |
− | ::deviceNetworkId - The unique identifier for the device
| |
− | | |
− | :;Returns
| |
− | ::None
| |
− | | |
− | ==User Defined Methods==
| |
− | ===<code>installed</code>===
| |
− | :This method is called when the app is first installed.
| |
− | | |
− | :;Signature
| |
− | :: <code>void installed()</code>
| |
− | | |
− | ===<code>updated</code>===
| |
− | :This method is called when the preferences of an installed app are updated.
| |
− | | |
− | :;Signature
| |
− | :: <code>void updated()</code>
| |
− | | |
− | ===<code>uninstalled</code>===
| |
− | :This method is called when the app is uninstalled. This method can be used to do any cleanup that is necessary.
| |
− | | |
− | :;Signature
| |
− | :: <code>void uninstalled()</code>
| |
− | | |
− | == <code>Additional to be documented</code> ==
| |
− | Map getState()
| |
− | String apiServerUrl(String url)
| |
− | String localApiServerUrl(String url)
| |
− | String fullLocalApiServerUrl(String url)
| |
− | void setLocationMode(String mode)
| |
− | void pause(Long millisecs)
| |
− | InstalledAppWrapper getParent()
| |
− | InstalledAppWrapper addChildApp(String namespace, String name, String label, Map properties = null)
| |
− | void deleteChildApp(Long childAppId)
| |
− | DeviceWrapper getSubscribedDeviceById(Long deviceId)
| |
− | void sendEvent(Map properties)
| |
− | void sendEvent(DeviceWrapper device, Map properties)
| |
− | void sendEvent(String dni, Map properties)
| |
− | List<Event> getLocationEventsSince(String attributeName, Date startDate, Map options = null)
| |
− | void subscribe(Object thing, String attributeName, handlerMethod, Map options = null)
| |
− | void subscribe(location, handlerMethod)
| |
− | List<InstalledApp> getAllChildApps()
| |
− | List<InstalledApp> getChildApps()
| |
− | InstalledAppWrapper getChildAppById(Long childAppId)
| |
− | InstalledAppWrapper getChildAppByLabel(String childAppLabel)
| |