Difference between revisions of "HubAction Object"

From Hubitat Documentation
Jump to: navigation, search
(Replaced content with " <big>'''We're moving!''' Please visit http://docs2.hubitat.com for the latest documentation.</big> <big> This document is available at: http://docs2.hubitat.com/en/devel...")
(Tag: Replaced)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
===<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 default to the LAN protocol.
+
<big>'''We're moving!''' Please visit http://docs2.hubitat.com for the latest documentation.</big>
  
:;Signature
+
<big>
:: <code>HubAction()</code>
+
This document is available at: http://docs2.hubitat.com/en/developer/hubaction-object
:: <code>HubAction(String request)</code>
+
</big>
:: <code>HubAction(String request, Protocol protocol, String dni)</code>
 
:: <code>HubAction(String request, Protocol protocol, String dni, Map options)</code>
 
:: <code>HubAction(String request, Protocol protocol)</code>
 
:: <code>HubAction(String request, Protocol protocol, Map options)</code>
 
:: <code>HubAction(Map params)</code>
 
:: <code>HubAction(Map params, String dni)</code>
 
:: <code>HubAction(Map params, String dni, Map options)</code>
 
 
 
:;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'' - A method name to pass the response from the HubAction back to. If 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'' - The destination address to use when sending LAN messages. In the format ip:port, if no port is specified it defaults to 80.
 
:::''destinationPort'' - The port number to use when sending UPNP discovery messages. Defaults to 1900.
 
:::''type'' - The type of message to send if its not a standard HTTP request.
 
::::''HubAction.LAN_TYPE_UDPCLIENT'' - Send message as a UDP package.
 
::::''HubAction.LAN_TYPE_RAW'' - Send message as a raw TCP message.
 
:::''secureCode'' - Used as part of a wake on lan request.
 
:::''encoding''
 
:::''ignoreResponse'' - (true/false) Used as part of UDP messages, instructs the system to ignore any response from the device to this message.
 
:::''parseWarning'' - (true/false) Used as part of UDP messages, instructs the system to send any error message back to the parse method of the device. (Since 2.2.0)
 
:::''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"])
 
 
 
===<code>getAction</code>===
 
 
 
Can be used to get the request value of the HubAction.
 
 
 
:;Signature
 
:: <code>String getAction()</code>
 
 
 
===<code>getCallbackMethod</code>===
 
 
 
:;Signature
 
:: <code>String getCallbackMethod()</code>
 
 
 
===<code>getURI</code>===
 
 
 
:;Signature
 
:: <code>URI getURI()</code>
 

Latest revision as of 19:36, 25 September 2022

We're moving! Please visit http://docs2.hubitat.com for the latest documentation.

This document is available at: http://docs2.hubitat.com/en/developer/hubaction-object