These methods are available for use in driver code.
TIP: See also Common Methods, which includes methods available to both apps and drivers.
Creates a new child device and returns that device from the method call.
ChildDeviceWrapper addChildDevice(String namespace, String typeName, String deviceNetworkId, Map properties = [:])
ChildDeviceWrapper addChildDevice(String typeName, String deviceNetworkId, Map properties = [:])
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:
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.
ChildDeviceWrapper
Gets a list of all child devices for this device.
List<ChildDeviceWrapper> getChildDevices()
None
List<ChildDeviceWrapper>
Gets a specific child device with the device network id specified.
ChildDeviceWrapper getChildDevice(String deviceNetworkId)
deviceNetworkId
- The unique identifier for the deviceChildDeviceWrapper
Deletes a specific child device with the device network id sepcified.
void deleteChildDevice(String deviceNetworkId)
deviceNetworkId
- The unique identifier for the deviceNone
Returns the parent device (ParentDeviceWrapper
) or app (InstalledAppWrapper
) when called from a child device.
Object getParent()
The ParentDeviceWrapper
or InstalledAppWrapper
Get a data value that was set for this device.
String getDataValue(String name)
name
- The String value of the data item.String
- The value of the data.
DEPRECATED: See getDataValue
; this method is a wrapper for getDataValue.
Returns the user-specified name of the Room to which the user has assigned this device, or null
if no room assigned.
String getRoomName()
None
String
- The name of the assigned room, or null
if no room assigned.
Returns the unique ID of the Room to which the user has assigned this device.
String getRoomId()
None
Long
- The unique ID of the assigned room
Update or create a data value for this device.
void updateDataValue(String name, String value)
name
- The name of the data item to store.
value
- The value of the data item to store.
None
Remove a data value from a device.
void removeDataValue(String name)
(Since 2.2.1)name
- The name of the data item to remove.None.
Use this method to send a HubAction immediately.
void sendHubCommand(HubAction hubAction)
hubAction
- The HubAction object to send.none
Creates a Map representing data for an event. This will not fire an event on its own; the resulting Map
(or a List
of such Map
objects) must be returned from the parse()
method in the driver. Alternatively, use sendEvent()
to create and fire an event (our recommendation). These methods are otherwise identical.
Map createEvent(Map options)
options
identical to those for sendEvent()
(see below)createEvent(name: "switch", value: "off")
Map
with event dataFires an event, i.e., sets the value of an attribute based on the values in the provided map. (Attributes can be seen under Current States on the device detail page in the regular hub interface.)
void sendEvent(Map properties)
properties
- a Map
of properties for the event. Valid keys are:
String name
(required) - name of the event (normally the an name of a device attribute)value
(required) - value of the event (data type should match the type defined for the attribute as defined by either the capability or custom attribute type)String unit
- units corresponding to the value (e.g., could be "%"
for level
or omitted for switch
)String descriptionText
- a human-friendly description of the event, optional but often provided in a format like "[Device name] [event name] is [event value]," possibly with additional information, e.g., "Living Room Dimmer level is 50%" or "Bedroom Button pushed is 1 [phyiscal]".Boolean isStateChange
- set to true
to force an event to be generated even if the new value is the same as the old value (optional and usually omitted in favor of default filtering by platform; button events are one case where it is often needed)sendEvent(name: "colorTemperature", value: 2700, unit: "K")
none
For callback methods — executed in response to certain actions in the Hubitat environment — and more on driver code, see: Device Code.
Map getState()
Zwave getZwave()
Zigbee getZigbee()
HubAction response(String cmd)
HubAction response(hubitat.zwave.Command cmd)
HubMultiAction response(List cmds)
Short getZwaveHubNodeId()
List
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()
List
delayBetween(List
cmds, Long delay)
List
delayBetween(List
cmds)