Difference between revisions of "Common Methods Object"

From Hubitat Documentation
Jump to: navigation, search
Line 1: Line 1:
 
These methods can be used in both Apps and Drivers
 
These methods can be used in both Apps and Drivers
 +
 +
== <code>getTemperatureScale</code> ==
 +
 +
Gets the current temperature scale set for the hub.
 +
 +
'''Signature:'''
 +
String getTemperatureScale()
 +
 +
'''Parameters:'''
 +
 +
none
 +
 +
'''Returns:'''
 +
 +
: "F" or "C" based on the setting in the hub.
  
 
== <code>timeOfDayIsBetween</code> ==
 
== <code>timeOfDayIsBetween</code> ==
Line 21: Line 36:
  
  
== <code>asynchttpGet</code> ==
+
== <code>unschedule</code> ==
  
Send an http GET request and return control to the calling codeAny response from the call will be passed to the callback method.
+
Remove any scheduled tasksIf method is called without paramters, all schedules will be removed.
  
 
'''Signature:'''
 
'''Signature:'''
  void asynchttpGet(callbackMethod, Map params, Map data = null)
+
  void unschedule()
 +
void unschedule(handlerMethod)
  
 
'''Parameters:'''
 
'''Parameters:'''
  
: callbackMethod - The name of a callback method to send the response to.  Can be null if the response can be ignored.
+
: handlerMethod - Only remove schedules for this handlerMethod
: params - the parameters to use to build the http GET call.
+
 
: data - optional data to be passed to the callback method.
+
 
  
== <code>unschedule</code> ==
+
== <code>asynchttpGet</code> ==
  
Remove any scheduled tasksIf method is called without paramters, all schedules will be removed.
+
Send an http GET request and return control to the calling codeAny response from the call will be passed to the callback method.
  
 
'''Signature:'''
 
'''Signature:'''
  void unschedule()
+
  void asynchttpGet(callbackMethod, Map params, Map data = null)
void unschedule(handlerMethod)
 
  
 
'''Parameters:'''
 
'''Parameters:'''
  
: handlerMethod - Only remove schedules for this handlerMethod
+
: callbackMethod - The name of a callback method to send the response to.  Can be null if the response can be ignored.
 +
: params - the parameters to use to build the http GET call.
 +
: data - optional data to be passed to the callback method.

Revision as of 01:29, 5 October 2018

These methods can be used in both Apps and Drivers

getTemperatureScale

Gets the current temperature scale set for the hub.

Signature:

String getTemperatureScale()

Parameters:

none

Returns:

"F" or "C" based on the setting in the hub.

timeOfDayIsBetween

Check if a date is between two dates.


Signature:

boolean timeOfDayIsBetween(Date start, Date stop, Date value[, TimeZone timeZone])

Parameters:

start - The date to start comparison against.
stop - The date to stop comparison against.
value - The date to compare
timezone - (Optional) The timezone to use for the comparison


Returns:

true if the value date is between the start and stop dates, otherwise returns false.


unschedule

Remove any scheduled tasks. If method is called without paramters, all schedules will be removed.

Signature:

void unschedule()
void unschedule(handlerMethod)

Parameters:

handlerMethod - Only remove schedules for this handlerMethod


asynchttpGet

Send an http GET request and return control to the calling code. Any response from the call will be passed to the callback method.

Signature:

void asynchttpGet(callbackMethod, Map params, Map data = null)

Parameters:

callbackMethod - The name of a callback method to send the response to. Can be null if the response can be ignored.
params - the parameters to use to build the http GET call.
data - optional data to be passed to the callback method.