Difference between revisions of "Driver Object"

From Hubitat Documentation
Jump to: navigation, search
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==<code>installed</code>==
+
=Overview=
  
This method is called when the device is first created.
 
  
'''Signature:'''
+
=Methods=
void installed()
 
  
==<code>updated</code>==
+
==Hubitat Provided Methods==
  
This method is called when the preferences of a device are updated.
+
===<code>sendHubCommand</code>===
 +
:Use this method to send a HubAction immediately.
  
'''Signature:'''
+
:;Signature
void updated()
+
:: <code>void sendHubCommand(HubAction hubAction)</code>
  
==<code>sendHubCommand</code>==
+
:;Parameters
 +
::hubAction - The HubAction object to send.
  
Use this method to send a HubAction immediately.
+
:;Returns
 +
:: none
  
'''Signature:'''
+
===<code>addChildDevice</code>===
void sendHubCommand(HubAction hubAction)
+
:Creates a new child device and returns that device from the method call.
  
'''Parameters:'''
+
:;Signature
 +
:: <code>ChildDeviceWrapper addChildDevice(String namespace, String typeName, String deviceNetworkId, Map properties = [:])</code>
 +
:: <code>ChildDeviceWrapper addChildDevice(String typeName, String deviceNetworkId, Map properties = [:])</code>
  
: hubAction - The HubAction object to send.
+
:;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
 +
 +
===<code>getChildDevices</code>===
 +
:Gets a list of all child devices for this device.
 +
 +
:;Signature
 +
:: <code>List<ChildDeviceWrapper> getChildDevices()</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
 +
 +
===<code>getParent</code>===
 +
:Returns the parent Device (ParentDeviceWrapper) or App (InstalledAppWrapper) when called from a child device.
 +
 +
:;Signature
 +
:: <code>Object getParent()</code>
 
'''Returns:'''
 
'''Returns:'''
 +
The ParentDeviceWrapper or InstalledAppWrapper
 +
 +
 +
==User defined methods==
 +
 +
===<code>installed</code>===
 +
:This method is called when the device is first created.
 +
 +
:;Signature
 +
:: <code>void installed()</code>
 +
 +
===<code>updated</code>===
 +
:This method is called when the preferences of a device are updated.
  
none
+
:;Signature
 +
:: <code>void updated()</code>
  
  
Line 33: Line 103:
 
  Zwave getZwave()
 
  Zwave getZwave()
 
  Zigbee getZigbee()
 
  Zigbee getZigbee()
Object getParent()
 
 
  void updateDataValue(String name, String value)
 
  void updateDataValue(String name, String value)
 
  String getDataValue(String name)
 
  String getDataValue(String name)
Line 49: Line 118:
 
  List<String> delayBetween(List<String> cmds, Long delay)
 
  List<String> delayBetween(List<String> cmds, Long delay)
 
  List<String> delayBetween(List<String> cmds)
 
  List<String> delayBetween(List<String> cmds)
ChildDeviceWrapper addChildDevice(String typeName, String deviceNetworkId, Map properties = [:])
 
ChildDeviceWrapper addChildDevice(String namespace, String typeName, String deviceNetworkId, Map properties = [:])
 
List<ChildDeviceWrapper> getChildDevices()
 
ChildDeviceWrapper getChildDevice(String deviceNetworkId)
 
void deleteChildDevice(String deviceNetworkId)
 

Revision as of 17:35, 19 September 2019

Overview

Methods

Hubitat Provided Methods

sendHubCommand

Use this method to send a HubAction immediately.
Signature
void sendHubCommand(HubAction hubAction)
Parameters
hubAction - The HubAction object to send.
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 = [:])
ChildDeviceWrapper addChildDevice(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()
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

getParent

Returns the parent Device (ParentDeviceWrapper) or App (InstalledAppWrapper) when called from a child device.
Signature
Object getParent()

Returns: The ParentDeviceWrapper or InstalledAppWrapper


User defined methods

installed

This method is called when the device is first created.
Signature
void installed()

updated

This method is called when the preferences of a device are updated.
Signature
void updated()


Additional to be documented

Map getState()
Zwave getZwave()
Zigbee getZigbee()
void updateDataValue(String name, String value)
String getDataValue(String name)
String getDeviceDataByName(String name)
HubAction response(String cmd)
HubAction response(hubitat.zwave.Command cmd)
HubMultiAction response(List cmds)
Short getZwaveHubNodeId()
void sendEvent(Map properties)
List<Event> eventsSince(Date startDate, Map options = null)
void telnetConnect(Map options, String ip, int port, String username, String password)
void telnetConnect(String ip, int port, String username, String password)
void telnetClose()
Map createEvent(Map options)
List<String> delayBetween(List<String> cmds, Long delay)
List<String> delayBetween(List<String> cmds)