Difference between revisions of "App Object"
(Document addChildDevice) |
|||
Line 141: | Line 141: | ||
void subscribe(Object thing, String attributeName, handlerMethod, Map options = null) | void subscribe(Object thing, String attributeName, handlerMethod, Map options = null) | ||
void subscribe(Object thing, handlerMethod) | void subscribe(Object thing, handlerMethod) | ||
− | |||
− | |||
List<InstalledApp> getAllChildApps() | List<InstalledApp> getAllChildApps() | ||
List<InstalledApp> getChildApps() | List<InstalledApp> getChildApps() | ||
InstalledAppWrapper getChildAppById(Long childAppId) | InstalledAppWrapper getChildAppById(Long childAppId) | ||
InstalledAppWrapper getChildAppByLabel(String childAppLabel) | InstalledAppWrapper getChildAppByLabel(String childAppLabel) |
Revision as of 16:10, 11 November 2019
Contents
Provided Methods
subscribe
- Subscribe to events sent from a device, app or location.
- Signature
void subscribe(Object thing, handlerMethod)
void subscribe(Object thing, String attributeName, handlerMethod, Map options = null)
- Parameters
- thing - The device, installed app or location 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.
unsubscribe
- Unsubscribe from events sent from a device or all event subscriptions.
- Signature
void unsubscribe()
void unsubscribe(DeviceWrapper device)
void unsubscribe(List<DeviceWrapper> deviceList)
void unsubscribe(DeviceWrapper device, String attributeName)
(Since 2.0.7)void unsubscribe(List<DeviceWrapper> deviceList, String attributeName)
(Since 2.1.0)void unsubscribe(DeviceWrapper device, String attributeName, String handlerMethod)
(Since 2.1.0)void unsubscribe(List<DeviceWrapper> deviceList, String attributeName, String handlerMethod)
(Since 2.1.0)void unsubscribe(InstalledAppWrapper installedApp)
(Since 2.1.2)void unsubscribe(Location location)
(Since 2.1.2)void unsubscribe(Location location, String attributeName)
(Since 2.1.2)void unsubscribe(String handlerMethod)
(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
addChildDevice
- Creates a new child device and returns that device from the method call.
- Signature
ChildDeviceWrapper addChildDevice(String namespace, String typeName, String deviceNetworkId, Map properties = [:])
- 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
- 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
getChildDevices
- Gets a list of all child devices for this device.
- Signature
List<ChildDeviceWrapper> getChildDevices()
List<ChildDeviceWrapper> getAllChildDevices()
- Parameters
- None
- Returns
- List<ChildDeviceWrapper>
getChildDevice
- Gets a specific child device with the device network id specified.
- Signature
ChildDeviceWrapper getChildDevice(String deviceNetworkId)
- Parameters
- deviceNetworkId - The unique identifier for the device
- Returns
- ChildDeviceWrapper
deleteChildDevice
- Deletes a specific child device with the device network id sepcified.
- Signature
void deleteChildDevice(String deviceNetworkId)
- Parameters
- deviceNetworkId - The unique identifier for the device
- Returns
- None
User Defined Methods
installed
- This method is called when the app is first installed.
- Signature
void installed()
updated
- This method is called when the preferences of an installed app are updated.
- Signature
void updated()
uninstalled
- This method is called when the app is uninstalled. This method can be used to do any cleanup that is necessary.
- Signature
void uninstalled()
Additional to be documented
Map getState() String getHubUID() String getApiServerUrl() String getFullApiServerUrl() String apiServerUrl(String url) String getLocalApiServerUrl() String getFullLocalApiServerUrl() String localApiServerUrl(String url) String fullLocalApiServerUrl(String url) void setLocationMode(String mode) String createAccessToken() 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(Object thing, handlerMethod) List<InstalledApp> getAllChildApps() List<InstalledApp> getChildApps() InstalledAppWrapper getChildAppById(Long childAppId) InstalledAppWrapper getChildAppByLabel(String childAppLabel)