Difference between revisions of "HubAction Object"

From Hubitat Documentation
Jump to: navigation, search
Line 1: Line 1:
==<code>Constructors</code>==
+
===<code>Constructor</code>===
  
 
Create a HubAction object.  While protocol is optional, it is recommended that it be provided.  If it is not specified the system will attempt to determine the protocol to use.
 
Create a HubAction object.  While protocol is optional, it is recommended that it be provided.  If it is not specified the system will attempt to determine the protocol to use.
  
'''Signature:'''
+
:;Signature
HubAction()
+
:: <code>HubAction()</code>
HubAction(String request)
+
:: <code>HubAction(String request)</code>
HubAction(String request, Protocol protocol, String dni)
+
:: <code>HubAction(String request, Protocol protocol, String dni)</code>
HubAction(String request, Protocol protocol, String dni, Map options)
+
:: <code>HubAction(String request, Protocol protocol, String dni, Map options)</code>
HubAction(String request, Protocol protocol)
+
:: <code>HubAction(String request, Protocol protocol)</code>
HubAction(String request, Protocol protocol, Map options)
+
:: <code>HubAction(String request, Protocol protocol, Map options)</code>
HubAction(Map params)
+
:: <code>HubAction(Map params)</code>
HubAction(Map params, String dni)
+
:: <code>HubAction(Map params, String dni)</code>
HubAction(Map params, String dni, Map options)
+
:: <code>HubAction(Map params, String dni, Map options)</code>
  
'''Parameters:'''
+
:;Parameters
;request
+
:: request - The command to send as a String, this can be a ZigBee, Z-Wave or Lan message to send.
: The command to send as a String, this can be a ZigBee, Z-Wave or Lan message to send.
+
:: protocol - The protocol to use when sending the message.  See the Protocol documentation for more info.
;protocol
+
:: dni - The device network Id to use when sending the message.  
: The protocol to use when sending the message.  See the Protocol documentation for more info.
+
:: options - Optional settings when sending the command. See examples for usage. Possible values:
;dni
+
:::''callback'' - This option can be specified in order to pass the response from the HubAction back to a specific method. If this option is not specified the response will be handed to the parse method of a Device or will be discarded if this HubAction was called from an App.
: The device network Id to use when sending the message.  
+
:::''destinationAddress''
;options
+
:::''destinationPort''
: Optional settings when sending the command. Possible values are callback, destinationAddress, destinationPort, type, secureCode, encoding.  See examples for usage.
+
:::''type''
::* callback - This option can be specified in order to pass the response from the HubAction back to a specific method. If this option is not specified the response will be handed to the parse method of a Device or will be discarded if this HubAction was called from an App.
+
:::''secureCode'' - Used as part of a wake on lan request.
::* destinationAddress
+
:::''encoding''
::* destinationPort
+
:::''ignoreResponse'' - Used as part of UDP messages, instructs the system to ignore any response from the device to this message.
::* type
+
:::''timeout'' - Used as part of UPD or TCP messages. Sets the timeout for response from the device, defaults to 10 seconds, acceptable range is 1 to 300.
::* secureCode - Used as part of a wake on lan request.
+
:: params - a list of parameters for sending a Lan message. Possible values:
::* encoding
+
:::''method'' - The http method to use, ie GET, POST, etc.
::* ignoreResponse - Used as part of UDP messages, instructs the system to ignore any response from the device to this message.
+
:::''path'' - The path to access on the http endpoint.
::* timeout - Used as part of UPD or TCP messages. Sets the timeout for response from the device, defaults to 10 seconds, acceptable range is 1 to 300.
+
:::''query'' - Any query parameters to use when calling the path.
;params
+
:::''body'' - The request body to send.
: a list of parameters for sending a Lan message. Possible values for params are:
+
:::''headers'' - Additional headers to use in the http request.
::* method - The http method to use, ie GET, POST, etc.
 
::* path - The path to access on the http endpoint.
 
::* query - Any query parameters to use when calling the path.
 
::* body - The request body to send.
 
::* headers - Additional headers to use in the http request.
 
  
'''Examples:'''
+
:;Examples
  
 
  //Create and send a Z-Wave message
 
  //Create and send a Z-Wave message

Revision as of 17:36, 2 July 2019

Constructor

Create a HubAction object. While protocol is optional, it is recommended that it be provided. If it is not specified the system will attempt to determine the protocol to use.

Signature
HubAction()
HubAction(String request)
HubAction(String request, Protocol protocol, String dni)
HubAction(String request, Protocol protocol, String dni, Map options)
HubAction(String request, Protocol protocol)
HubAction(String request, Protocol protocol, Map options)
HubAction(Map params)
HubAction(Map params, String dni)
HubAction(Map params, String dni, Map options)
Parameters
request - The command to send as a String, this can be a ZigBee, Z-Wave or Lan message to send.
protocol - The protocol to use when sending the message. See the Protocol documentation for more info.
dni - The device network Id to use when sending the message.
options - Optional settings when sending the command. See examples for usage. Possible values:
callback - This option can be specified in order to pass the response from the HubAction back to a specific method. If this option is not specified the response will be handed to the parse method of a Device or will be discarded if this HubAction was called from an App.
destinationAddress
destinationPort
type
secureCode - Used as part of a wake on lan request.
encoding
ignoreResponse - Used as part of UDP messages, instructs the system to ignore any response from the device to this message.
timeout - Used as part of UPD or TCP messages. Sets the timeout for response from the device, defaults to 10 seconds, acceptable range is 1 to 300.
params - a list of parameters for sending a Lan message. Possible values:
method - The http method to use, ie GET, POST, etc.
path - The path to access on the http endpoint.
query - Any query parameters to use when calling the path.
body - The request body to send.
headers - Additional headers to use in the http request.
Examples
//Create and send a Z-Wave message
def hubAction = new hubitat.device.HubAction(new hubitat.zwave.commands.basicv1.BasicGet().format(), hubitat.device.Protocol.ZWAVE)
sendHubCommand(hubAction)
// Protocol.LAN examples

// Send UDP Message
new HubAction("My UDP Message", Protocol.LAN, [type: HubAction.Type.LAN_TYPE_UDPCLIENT])

// Send Binary UDP Message 
new HubAction("48756269746174", Protocol.LAN, [type: HubAction.Type.LAN_TYPE_UDPCLIENT, encoding: HubAction.Encoding.HEX_STRING])

// Send Wake On Lan to mac address 00:11:22:33:44:55
new HubAction("wake on lan 00:11:22:33:44:55", Protocol.LAN)

// Send Wake On Lan to mac address 00:11:22:33:44:55 with secure code
new HubAction("wake on lan 00:11:22:33:44:55", Protocol.LAN, [secureCode: "112233"])

getAction

Can be used to get the request value of the HubAction.

Signature

String getAction()

getCallbackMethod

Signature:

String getCallbackMethod()

getURI

Signature:

URI getURI()