These methods can be used in both apps and drivers
Converts a given Celsius temperature to Fahrenheit.
BigDecimal celsiusToFahrenheit(BigDecimal val)
A temperature in Celsius.
The specified temperature in Fahrenheit.
Converts a given Fahrenheit temperature to Celsius
BigDecimal fahrenheitToCelsius(BigDecimal val)
A temperature in Fahrenheit.
The specified temperature in Celsius.
Converts the given color temperature to a string name. Most commonly used to populate colorName attribute in driver. (Since 2.3.2)
convertTemperatureToGenericColorName(Integer colorTemp)
String name representation of the color temperature (e.g., "Soft White").
Converts the given color (hue and saturation) to a string name. Most commonly used to populate colorName attribute in driver. (Since 2.3.2)
String convertHueToGenericColorName(Integer hue)
String convertHueToGenericColorName(Integer hue, Integer saturation)
hue - The hue, from 0 through 100.
saturation - Optional; the saturation percentage. Defaults to 50; a saturation of zero returns "White".
String name representation of the color (e.g., "Red", "Spring", "Cyan", etc.).
Location getLocation()
Returns the sunset and sunrise values for the current day. (Common method since 2.1.0)
Map getSunriseAndSunset()
Map getSunriseAndSunset(Map options)
options - Map with optional offset for sunrise/sunset or date; possible values are:
sunriseOffset and sunsetOffset: can either be a number of minutes or a String of the format "hours:minutes"date: instance of Date representing the base date (day)Map with key values sunrise and sunset of type Date
// get today's sunrise and sunset
def riseAndSet = getSunriseAndSunset()
log.debug riseAndSet.sunrise
log.debug riseAndSet.sunset
// get sunrise time offset by 1 minute early, and get sunset offset by 1 hour, 5 minutes later
def offsetRiseAndSet = getSunriseAndSunset(sunriseOffset: -1, sunsetOffset: "1:05")
getTodaysSunrise()getTodaysSunrise(TimeZone tz) (since 2.3.6.118)TimeZone tz: optional time zoneDate representing today's sunrise timegetTomorrowsSunrise()getTomorrowsSunrise(TimeZone tz) (since 2.3.6.118)TimeZone tz: optional time zoneDate representing tomorrow's sunrise timegetTodaysSunset()getTodaysSunset(TimeZone tz) (since 2.3.6.118)TimeZone tz: optional time zoneDate representing today's sunset timegetTomorrowsSunset()getTomorrowsSunset(TimeZone tz) (since 2.3.6.118)TimeZone tz: optional time zoneDate representing tomorrow's sunset timeGet the current temperature scale set for the hub.
String getTemperatureScale()
none
String - "F" or "C" based on the setting in the hub.
long now()
Get a Date object with today's date and the time specified
Date timeToday(String timeString, TimeZone timeZone = null)
timeString - The time to use, can be either "HH:mm" or and ISO8601 date/time string
timeZone - (optional) The timezone to use for the new Date.
Date - A Date object with today's date and the time that was passed as timeString
Check if a date is between two dates.
boolean timeOfDayIsBetween(Date start, Date stop, Date value[, TimeZone timeZone])
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
boolean - true if the value date is between the start and stop dates, otherwise returns false.
Converts a number of minutes, or a signed hours:minutes string, to milliseconds. (Since 2.1.0)
Long timeOffset(Number minutes)Long timeOffset(String hoursAndMinutesString)minutes - Optional; Offset in minutes.hoursAndMinutesString - Optional; Offset in signed hours:minutes form.Offset in milliseconds.
Returns a Date for a time of day that is on or after a given start time, on either today or tomorrow. (Since 2.1.0)
Date timeTodayAfter(String startTimeString, String timeString, TimeZone timeZone = null)startTimeString - Start time on the current date.timeString - Desired time on the current date.timeZone - Optional; Time zone for both times; defaults to the JVM time zone.Desired time on today when it is at or after the start, otherwise the same time tomorrow.
Finds the next sunrise that occurs after the current instant.
Date getNextSunrise(TimeZone tz = null, int offsetMinutes = 0)tz - Optional; defaults to null. Time zone used to advance the calendar; the hub location's time zone is used for calculation.offsetMinutes - Optional; defaults to 0. Minutes added to each candidate sunrise before checking whether it is in the future.Next sunrise instant after applying the offset.
Finds the next sunset that occurs after the current instant.
Date getNextSunset(TimeZone tz = null, int offsetMinutes = 0)tz - Optional; defaults to null. Time zone used to advance the calendar; the hub location's time zone is used for calculation.offsetMinutes - Optional; defaults to 0. Minutes added to each candidate sunset before checking whether it is in the future.Next sunset instant after applying the offset.
Tests whether a string uses the platform's accepted time format.
boolean isTimeStringValid(String timeValue)timeValue - Time string to validate.True when the value is a valid time string.
Formats a date in the location time zone.
String formatDate(Date date)date - Date to format.Date in the location's selected date format. Examples: M/d/yyyy, d/M/yyyy, or yyyy/M/d, depending on date format selection
Formats a short date in the location time zone.
String formatShortDate(Date date)date - Date to format.Short date in the location's selected date format. Examples: d/M, M/d, or M/d, depending on date format selection
Formats a time with hours and minutes in the location time zone.
String formatTimeHourMinute(Date date)date - Date to format.Time in the location's selected 12-hour or 24-hour format. Examples: h:mma or HH:mm, depending on time format selection
Formats a time with hours, minutes, and seconds in the location time zone.
String formatTimeHourMinuteSecond(Date date)date - Date to format.Time in the location's selected 12-hour or 24-hour format. Examples: h:mm:ss a or HH:mm:ss, depending on time format selection
Formats a time with hours, minutes, seconds, and milliseconds in the location time zone.
String formatTimeHourMinuteSecondMillis(Date date)date - Date to format.Time with milliseconds in the location's selected 12-hour or 24-hour format. Examples: h:mm:ss.SSS a or HH:mm:ss.SSS, depending on time format selection
Formats an activity timestamp in the location time zone.
String formatActivityDateTime(def date)date - Date to format.Activity timestamp in the location's selected date and time format. Examples: yyyy-MM-dd h:mm:ss a z or yyyy-MM-dd HH:mm:ss z, depending on time format selection
Formats a short activity timestamp in the location time zone.
String formatActivityDateTimeShort(def date)date - Date to format.Short activity timestamp in the location's selected date and time format. Examples: d/M h:mma, M/d h:mma, d/M HH:mm, or M/d HH:mm, depending on format selections
Converts and rounds a temperature to the hub's configured scale when needed.
String convertTemperatureIfNeeded(BigDecimal value, String scale, Integer precision)value - Temperature value in the scale named by scale.scale - Source scale, C or F, case-insensitive.precision - Number of decimal places to retain.Rounded decimal string, or null when an input is missing or scale is invalid.
Remove any scheduled tasks. If method is called without parameters, all schedules will be removed.
void unschedule()
void unschedule(handlerMethod)
handlerMethod - Only remove schedules for this handlerMethod
Send an http GET request and return control to the calling code. Any response from the call will be passed to the callback method.
void asynchttpGet(callbackMethod, Map params, Map data = null)
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. Possible values:
uri - The URI to send the request toqueryString - The raw, already-escaped query string.query - Add these parameters to the existing query string. If any of the parameters already exist in the query, these values will not replace them. Multiple values for the same query parameter may be added by putting them in a list.headers - Request headerspath - The path component of this request. The value may be absolute or relative to the current path.contentType - The content-type used for any data in the request body, as well as the Accept content-type that will be used for parsing the response.requestContentType - Assign a different content-type for the request than is expected for the response.timeout (since 2.0.9) - timeout in seconds for the request, max timeout is 300ignoreSSLIssues (since 2.1.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false.followRedirects (since 2.2.9) - possible values: true, false. Determines whether or not redirects will be automatically followed. Defaults to true.data - optional data to be passed to the callback method.
void asynchttpPost(String callbackMethod = null, Map params, Map data = null)
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. Possible values:
uri - The URI to send the request toqueryString - The raw, already-escaped query string.query - Add these parameters to the existing query string. If any of the parameters already exist in the query, these values will not replace them. Multiple values for the same query parameter may be added by putting them in a list.headers - Request headerspath - The path component of this request. The value may be absolute or relative to the current path.contentType - The content-type used for any data in the request body, as well as the Accept content-type that will be used for parsing the response.requestContentType - Assign a different content-type for the request than is expected for the response.body - The request body. If this is a Map or Array, the system will take care of encoding it based on the requestContentType.timeout (since 2.0.9) - timeout in seconds for the request, max timeout is 300ignoreSSLIssues (since 2.1.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false.followRedirects (since 2.2.9) - possible values: true, false. Determines whether or not redirects will be automatically followed. Defaults to true.data - optional data to be passed to the callback method.
void asynchttpPatch(String callbackMethod = null, Map params, Map data = null)
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 PATCH call. Possible values:
uri - The uri to send the request toqueryString - The raw, already-escaped query string.query - Add these parameters to the existing query string. If any of the parameters already exist in the query, these values will not replace them. Multiple values for the same query parameter may be added by putting them in a list.headers - Request headerspath - The path component of this request. The value may be absolute or relative to the current path.contentType - The content-type used for any data in the request body, as well as the Accept content-type that will be used for parsing the response.requestContentType - Assign a different content-type for the request than is expected for the response.body - The request body. If this is a Map or Array, the system will take care of encoding it based on the requestContentType.timeout (since 2.0.9) - timeout in seconds for the request, max timeout is 300ignoreSSLIssues (since 2.1.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false.followRedirects (since 2.2.9) - possible values: true, false. Determines whether or not redirects will be automatically followed. Defaults to true.data - optional data to be passed to the callback method.
Schedules an asynchronous HTTP PUT request; Map and List bodies are serialized to JSON.
void asynchttpPut(String callbackMethod = null, Map params, Map data = null)callbackMethod - Optional; defaults to null. Name of a two-argument callback method to invoke after the request. The callback receives (AsyncResponse response, Map data); see the example in asynchttpGet. When null or empty, no callback runs.params - HTTP request settings described by httpGet; these methods require uri. A request body is accepted for POST, PUT, and PATCH; GET, HEAD, and DELETE discard it.data - Optional; defaults to null. Caller data map passed unchanged as the callback method second argument; keys and values are caller-defined. Example request: asynchttpPut("handleStatus", [uri: "https://api.example.test/items/42", contentType: "application/json", body: [enabled: true]], [label: "Item API"]).none
Schedules an asynchronous HTTP DELETE request; request bodies are removed before sending.
void asynchttpDelete(String callbackMethod = null, Map params, Map data = null)callbackMethod - Optional; defaults to null. Name of a two-argument callback method to invoke after the request. The callback receives (AsyncResponse response, Map data); see the example in asynchttpGet. When null or empty, no callback runs.params - HTTP request settings described by httpGet; these methods require uri. A request body is accepted for POST, PUT, and PATCH; GET, HEAD, and DELETE discard it.data - Optional; defaults to null. Caller data map passed unchanged as the callback method second argument; keys and values are caller-defined. Example request: asynchttpDelete("handleStatus", [uri: "https://api.example.test/items/42"], [label: "Item API"]).none
Schedules an asynchronous HTTP HEAD request.
void asynchttpHead(String callbackMethod = null, Map params, Map data = null)callbackMethod - Optional; defaults to null. Name of a two-argument callback method to invoke after the request. The callback receives (AsyncResponse response, Map data); see the example in asynchttpGet. When null or empty, no callback runs.params - HTTP request settings described by httpGet; these methods require uri. A request body is accepted for POST, PUT, and PATCH; GET, HEAD, and DELETE discard it.data - Optional; defaults to null. Caller data map passed unchanged as the callback method second argument; keys and values are caller-defined. Example request: asynchttpHead("handleStatus", [uri: "https://api.example.test/status"], [label: "Service"]).none
Send an HTTP GET request. Any response from the call will be passed to the closure.
void httpGet(String uri, Closure closure)
void httpGet(Map params, Closure closure)
uri - The full URI to send the request to.
params - the parameters to use to build the http GET call. Possible values:
uri - The uri to send the request toqueryString - The raw, already-escaped query string.query - Add these parameters to the existing query string. If any of the parameters already exist in the query, these values will not replace them. Multiple values for the same query parameter may be added by putting them in a list.headers - Request headerspath - The path component of this request. The value may be absolute or relative to the current path.contentType - The content-type used for any data in the request body, as well as the Accept content-type that will be used for parsing the response.requestContentType - Assign a different content-type for the request than is expected for the response.timeout (since 2.0.9) - timeout in seconds for the request, max timeout is 300textParser (since 2.1.1) - possible values: true, false. If set to true, the response will be parsed as plain text, if false the system will attempt to determine the content type and parse the response into an object. Defaults to false.ignoreSSLIssues (since 2.1.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false.followRedirects (since 2.2.9) - possible values: true, false. Determines whether or not redirects will be automatically followed. Defaults to true.closure - code to handle a successful HTTP response. an object of type HttpResponseDecorator is passed to this code.
void httpPost(String uri, String body, Closure closure)
void httpPost(Map params, Closure closure)
uri - The full URI to send the request to.
body - The body of the request as a String. Any encoding should be done before passing to the system.
params - the parameters to use to build the http call. Possible values:
uri - The uri to send the request toqueryString - The raw, already-escaped query string.query - Add these parameters to the existing query string. If any of the parameters already exist in the query, these values will not replace them. Multiple values for the same query parameter may be added by putting them in a list.headers - Request headerspath - The path component of this request. The value may be absolute or relative to the current path.contentType - The content-type used for any data in the request body, as well as the Accept content-type that will be used for parsing the response.requestContentType - Assign a different content-type for the request than is expected for the response.body - The request body. If this is a Map or Array, the system will take care of encoding it based on the requestContentType.timeout (since 2.0.9) - timeout in seconds for the request, max timeout is 300*textParser* (since 2.1.1) - possible values: true, false. If set to true, the response will be parsed as plain text, if false the system will attempt to determine the content type and parse the response into an object. Defaults to false.ignoreSSLIssues (since 2.1.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false.followRedirects (since 2.2.9) - possible values: true, false. Determines whether or not redirects will be automatically followed. Defaults to true.closure - code to handle a successful HTTP response. an object of type HttpResponseDecorator is passed to this code.
Similar to httpPost except that the contentType parameter is set to "application/json"
void httpPostJson(String uri, String stringBody, Closure closure)
void httpPostJson(String uri, Map mapBody, Closure closure)
void httpPostJson(Map params, Closure closure)
uri - The full URI to send the request to.
stringBody - The body of the request as a String. Any encoding should be done before passing to the system.
mapBody - The body of the request as a Map.
params - the parameters to use to build the HTTP call. Possible values:
uri - The URI to send the request toqueryString - The raw, already-escaped query string.query - Add these parameters to the existing query string. If any of the parameters already exist in the query, these values will not replace them. Multiple values for the same query parameter may be added by putting them in a list.headers - Request headerspath - The path component of this request. The value may be absolute or relative to the current path.requestContentType - Assign a different content-type for the request than is expected for the response.body - The request body. If this is a Map or Array, the system will take care of encoding it as JSON.timeout (since 2.0.9) - timeout in seconds for the request, max timeout is 300textParser (since 2.1.8) - possible values: true, false. If set to true, the response will be parsed as plain text, if false the system will attempt to determine the content type and parse the response into an object. Defaults to false.ignoreSSLIssues (since 2.1.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false.followRedirects (since 2.2.9) - possible values: true, false. Determines whether or not redirects will be automatically followed. Defaults to true.closure - code to handle a successful HTTP response. an object of type HttpResponseDecorator is passed to this code.
void httpPut(String uri, String body, Closure closure)
void httpPut(Map params, Closure closure)
uri - The full uri to send the request to.
body - The body of the request as a String. Any encoding should be done before passing to the system.
params - the parameters to use to build the http call. Possible values:
uri - The uri to send the request toqueryString - The raw, already-escaped query string.query - Add these parameters to the existing query string. If any of the parameters already exist in the query, these values will not replace them. Multiple values for the same query parameter may be added by putting them in a list.headers - Request headerspath - The path component of this request. The value may be absolute or relative to the current path.requestContentType - The content-type used for any data in the request body, as well as the Accept content-type that will be used for parsing the response.requestContentType - Assign a different content-type for the request than is expected for the response.body - The request body. If this is a Map or Array, the system will take care of encoding it based on the requestContentType.timeout (since 2.0.9) - timeout in seconds for the request, max timeout is 300textParser (since 2.1.1) - possible values: true, false. If set to true, the response will be parsed as plain text, if false the system will attempt to determine the content type and parse the response into an object. Defaults to false.ignoreSSLIssues (since 2.1.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false.followRedirects (since 2.2.9) - possible values: true, false. Determines whether or not redirects will be automatically followed. Defaults to true.closure - code to handle a successful HTTP response. an object of type HttpResponseDecorator is passed to this code.
void httpPatch(String uri, String body, Closure closure)
void httpPatch(Map params, Closure closure)
uri - The full uri to send the request to.
body - The body of the request as a String. Any encoding should be done before passing to the system.
params - the parameters to use to build the http call. Possible values:
uri - The URI to send the request toqueryString - The raw, already-escaped query string.query - Add these parameters to the existing query string. If any of the parameters already exist in the query, these values will not replace them. Multiple values for the same query parameter may be added by putting them in a list.headers - Request headerspath - The path component of this request. The value may be absolute or relative to the current path.contentType - The content-type used for any data in the request body, as well as the Accept content-type that will be used for parsing the response.requestContentType - Assign a different content-type for the request than is expected for the response.body - The request body. If this is a Map or Array, the system will take care of encoding it based on the requestContentType.timeout - timeout in seconds for the request, max timeout is 300textParser - possible values: true, false. If set to true, the response will be parsed as plain text, if false the system will attempt to determine the content type and parse the response into an object. Defaults to false.ignoreSSLIssues (since 2.1.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false.followRedirects (since 2.2.9) - possible values: true, false. Determines whether or not redirects will be automatically followed. Defaults to true.closure - code to handle a successful HTTP response. an object of type HttpResponseDecorator is passed to this code.
Sends a JSON HTTP PUT request using request settings. Sends a JSON HTTP PUT request with a map body. Sends a JSON HTTP PUT request with a string body.
void httpPutJson(Map params, Closure closure)void httpPutJson(String uri, Map body, Closure closure)void httpPutJson(String uri, String body, Closure closure)params - Optional; Request settings with the common HTTP fields described by httpGet; Map and List body values are serialized to JSON.closure - One-argument closure called synchronously with an ExecutorHttpResponse; see httpGet for response properties and an example. Example: httpPutJson([uri: "https://api.example.test/items/42", body: [enabled: true]]) { response -> log.info "HTTP ${response.status}" }.uri - Optional; Absolute request URI.body - Optional; Map serialized to JSON text.none
Sends an HTTP DELETE request and passes its response to a callback. Request bodies are removed before sending.
void httpDelete(Map params, Closure closure)params - Request settings with the common HTTP fields described by httpGet.closure - One-argument closure called synchronously with an ExecutorHttpResponse; see httpGet for response properties and an example. Example: httpDelete([uri: "https://api.example.test/items/42"]) { response -> log.info "HTTP ${response.status}" }.none
String runIn(Long delayInSeconds, String handlerMethod, Map options = null) (since 2.4.2)
void runIn(Long delayInSeconds, String handlerMethod, Map options = null) (2.4.1 and earlier)
delayInSeconds - How long to wait in seconds until the handler should be called, don't expect that it will be called in exactly that time.
handlerMethod - The name of a handler method in your driver or app. The method name should not contain parentheses.
options - Optional values to control the scheduling of this method
overwrite - defaults to true, which cancels the previous scheduled running of the handler method and schedules new; if set to false, this will create a duplicate schedule.data - optional Map of data to be passed to the handler method.misfire - If set to "ignore" then the scheduler will simply try to fire it as soon as it can. NOTE: if a scheduler uses this instruction, and it has missed several of its scheduled firings, then several rapid firings may occur as the scheduler attempts to catch back up to where it would have been.String representing job ID that can be used with cancelRunIn(String jobId) to cancel before the job is executed (since 2.4.2) which will return true if a matching job was cancelled or false if not; or void (in previous platform versions)
runIn(50, "myMethod", [data: [myKey:"myValue"]])
// ...
void myMethod(data) {
log.debug "myMethod parameter: $data"
}
void runInMillis(Long delayInMilliSeconds, String handlerMethod, Map options = null)
delayInMilliseconds - How long to wait until the handler should be called, don't expect that it will be called in exactly that time.
handlerMethod - the name of a handler method in your driver or app. The method name should not contain parentheses.
options - Optional values to control the scheduling of this method
overwrite - defaults to true which cancels the previous scheduled running of the handler method and schedules new, if set to false this will create a duplicate schedule.data - optional Map of data to be passed to the handler method.misfire - If set to "ignore" then the scheduler will simply try to fire it as soon as it can. NOTE: if a scheduler uses this instruction, and it has missed several of its scheduled firings, then several rapid firings may occur as the scheduler attempts to catch back up to where it would have been.private processQueue(Map queue) {
if (isQueueEmpty(queue)) {
sendEvent name: 'lifxdiscovery', value: 'complete'
return
}
def data = getNext(queue)
sendPacket data.ipAddress, data.packet
runInMillis(queue.delay, 'processQueue', [data: queue])
}
runInMillis(50, 'processQueue', [data: queue])
String runOnce(Date dateTime, String handlerMethod, Map options = null) (since 2.4.2)String runOnce(String dateTime, String handlerMethod, Map options = null) (since 2.4.2)void runOnce(Date dateTime, String handlerMethod, Map options = null) (2.4.1 and earlier)void runOnce(String dateTime, String handlerMethod, Map options = null) (2.4.1 and earlier)dateTime: date/time of execution
handlerMethod - the name of a handler method in your driver or app. The method name should not contain parentheses.
options - Optional values to control the scheduling of this method
overwrite - defaults to true which cancels the previous scheduled running of the handler method and schedules new, if set to false this will create a duplicate schedule.data - optional Map of data to be passed to the handler method.misfire - If set to "ignore" then the scheduler will simply try to fire it as soon as it can. NOTE: if a scheduler uses this instruction, and it has missed several of its scheduled firings, then several rapid firings may occur as the scheduler attempts to catch back up to where it would have been.String representing job ID that can be used with cancelRunOnce(String jobId) to cancel before the job is executed (since 2.4.2) which will return true if a matching job was cancelled or false if not; or void (in previous platform versions)
void pauseExecution(Long millisecs)
millisecs - The amount of time in milliseconds to pause.
Converts text to speech.
Map textToSpeech(String stringToBeSynthesized, String voice = null, def initialPauseStr = null)
stringToBeSynthesized - The text to be converted to audio. The text may contain supported SSML tags.
voice - The name of a voice supported by Amazon Polly, you can find a list of voices here. If not specified the default system setting is used.
initialPauseStr - Optional; the length of silence to add at the start, in milliseconds. Non-numeric or null values are treated as zero.
Map - Returns a Map with two entries, uri which contains a URI to the MP3 file and duration is the length of the MP3 in seconds.
Returns a list of the supported text-to-speech voices.
Map getTTSVoices()
None
Map - Returns a Map with three entries: name, which is the name of a voice that can be specified to textToSpeech, gender, which contains either Male or Female; and language, which contains the language of this voice.
Date toDateTime(String dateTimeString)
dateTimeString - A date/time string in ISO8601 format. ("yyyy-MM-dd", "yyyyMMdd'T'HHmmssX", "yyyy-MM-dd'T'HH:mm:ssX", "yyyy-MM-dd'T'HH:mm:ss.SSSX")
void schedule(String expression, String handlerMethod, Map options = null)
void schedule(Date dateTime, String handlerMethod, Map options = null)
dateTime - A Date whose local clock time is used for a daily recurring schedule.
expression - either an ISO date-time string, which creates a daily schedule at that time of day, or a 7-parameter Quartz cron string where the expression is: "Seconds" "Minutes" "Hours" "Day Of Month" "Month" "Day Of Week" "Year"
handlerMethod - method to run at given schedule
options - Optional values to control the scheduling of this method
// run 'mymethod' every tenth minute.
schedule("0 */10 * ? * *", "mymethod")
// same with a parameter
schedule("0 */10 * ? * *", "mymethod", [data: ["myKey":"myValue"]])
// ...
void mymethod(Map data=null) {
log.debug "mymethod data parameter: $data"
}
Cancels the one-shot job identified by its key.
boolean cancelRunIn(String key)key - The job ID returned by runIn().True if a matching job was cancelled; false for a malformed or missing key, or if cancellation fails.
Cancels the one-shot job identified by its key.
boolean cancelRunOnce(String key)key - The job ID returned by runOnce().True if a matching job was cancelled; false for a malformed or missing key, or if cancellation fails.
Schedules recurring execution every 1 minute with a randomized position in the interval.
void runEvery1Minute(String handlerMethod, Map options = null)handlerMethod - Name of the handler method to invoke.options - Optional scheduling settings; recognized keys follow.
none
Schedules recurring execution every 5 minutes with a randomized position in the interval.
void runEvery5Minutes(String handlerMethod, Map options = null)handlerMethod - Name of the handler method to invoke.options - Optional scheduling settings; recognized keys follow.
none
Schedules recurring execution every 10 minutes with a randomized position in the interval.
void runEvery10Minutes(String handlerMethod, Map options = null)handlerMethod - Name of the handler method to invoke.options - Optional scheduling settings; recognized keys follow.
none
Schedules recurring execution every 15 minutes with a randomized position in the interval.
void runEvery15Minutes(String handlerMethod, Map options = null)handlerMethod - Name of the handler method to invoke.options - Optional scheduling settings; recognized keys follow.
none
Schedules recurring execution every 30 minutes with a randomized position in the interval.
void runEvery30Minutes(String handlerMethod, Map options = null)handlerMethod - Name of the handler method to invoke.options - Optional scheduling settings; recognized keys follow.
none
Schedules recurring execution every 1 hour at a random minute and second offset.
void runEvery1Hour(String handlerMethod, Map options = null)handlerMethod - Name of the handler method to invoke.options - Optional scheduling settings; recognized keys follow.
none
Schedules recurring execution every 3 hours at a random minute and second offset.
void runEvery3Hours(String handlerMethod, Map options = null)handlerMethod - Name of the handler method to invoke.options - Optional scheduling settings; recognized keys follow.
none
Pauses the current execution thread for a number of milliseconds.
void sleepForMillis(int sleepFor)sleepFor - Duration to sleep in milliseconds.none
String getObjectClassName(Object obj)
Object obj: any objectThe name of the Java/Groovy class of which the specified object is a type (this is effectively an alternative to <object>.getClass() that is allowed in the Hubitat sandbox)
Parses JSON text into Groovy maps, lists, and scalar values.
Object parseJson(String stringToParse)stringToParse - Valid JSON document.Parsed JSON value; the top-level value may be a Map, List, String, Number, Boolean, or null.
Base64-decodes and parses a JSON document.
Object parseJsonFromBase64(String stringToParse)stringToParse - Base64-encoded UTF-8 JSON text.Parsed JSON value; the top-level value may be a Map, List, String, Number, Boolean, or null.
Parses XML text into a GPathResult tree.
GPathResult parseXML(String stringToParse)stringToParse - XML document text.Parsed XML document.
Encodes UTF-8 text as Base64.
String base64Encode(String str)str - Text to encode.Base64 text, or an empty string when input is blank.
Decodes Base64 text as UTF-8.
String base64Decode(String str)str - Base64 text to decode.Decoded text, or an empty string when input is blank.
URL-encodes text as UTF-8 and represents spaces as %20.
String urlEncode(String str)str - Text to encode.Encoded text, or an empty string when str is null or empty.
Escapes HTML-sensitive characters in a string.
String escapeHtml(String str)str - Text to escape.HTML-escaped text, or an empty string when str is null or empty.
Removes HTML tags from a string.
String removeHtmlTags(String str)str - Text containing HTML.Text with HTML tags removed.
Removes line breaks and leading or trailing whitespace from each HTML line.
String compactHtml(String html)html - HTML text to compact.Compacted HTML, or the original null or empty value.
Replaces line breaks and tabs with spaces and collapses repeated whitespace.
String minimizeWhitespaces(String str)str - Text to compact.Trimmed text with single spaces between words and no spaces between adjacent tags.
Generates a random alphanumeric string.
String generateRandomString(int length)length - Number of characters requested.Random string with the requested length.
Encrypts a string. Use decrypt() to reverse it.
String encrypt(String value)value - Plain text to encrypt.Encrypted text.
Decrypts a string that was encrypted with encrypt().
String decrypt(String value)value - Encrypted text to decrypt.Decrypted plain text.
Creates a signed JSON Web Token from claims and a signing key.
String getJWTtoken(String claims, String signKey)claims - Claims JSON text.signKey - Signing key.Signed JWT text.
Resizes an image to the requested dimensions when either source dimension is larger, then encodes it as JPEG.
byte[] resizeImage(byte[] imageBytes, int maxWidth, int maxHeight)imageBytes - Encoded source image bytes supported by ImageIO.maxWidth - Output image width in pixels.maxHeight - Output image height in pixels.JPEG-encoded image bytes.
Returns the readable hub version.
String getHubVersion()None
Human-readable hub version string.
Returns the numeric hub version.
int getNumericHubVersion()None
Hub version as an integer.
Returns the running platform build version.
String getPlatformVersion()None
Current platform version string.
Returns the latest platform version reported by the cloud, or the running version when no update is available.
String getLatestAvailablePlatformVersion()None
Platform version string.
Returns name and namespace records for every device type in the database.
List<Map> getInstalledDrivers()None
List of driver maps. Each map contains:
namespace: String driver namespace.name: String driver name.Returns names of all rooms, including rooms hidden from the UI room list.
List<String> getAllRoomNames()None
Room names.
Returns the logger for the running app or driver; also available as the log property.
LogWrapper getLog()None
The log object
Formats an exception and its app or driver stack frames.
String getStackTrace(Throwable exception)exception - Exception to format.The exception text followed by the app or driver stack frames
Formats an exception message with the first matching app or driver source line.
String getExceptionMessageWithLine(Throwable exception)exception - Exception to inspect.Class, message, and the first matching source line number, or line 0 when none is found.
Returns names of the configured location variables.
List getLocationVariableNames()None
Location variable names.
Returns the allowed values for one location variable.
List getLocationVariableValues(String locationVariable)locationVariable - Name of the location variable.Allowed values for the variable.
Creates or replaces a location variable.
void createLocationVariable(String name, List values = null, boolean readOnly = false)name - Variable name.values - Optional; defaults to null. Allowed values list, or null when the variable has no enumerated values.readOnly - Optional; defaults to false. True to prevent scripts from changing the variable value.none
Removes a location variable.
void removeLocationVariable(String name)name - Name of the location variable to remove.none
Returns the configured text-to-speech voice id.
String getTTSVoice()None
Current voice id.
Reports whether the hub configuration enables text-to-speech friendly output.
boolean isTTSFriendly()None
Platform setting value.
Sends a mobile push notification when both message and device id are supplied.
void sendPush(String message, String mobileDeviceId = null)message - Notification text.mobileDeviceId - Optional; defaults to null. Target mobile device id; null skips sending.none
Sends a mobile push notification when both message and device id are supplied.
void sendPushMessage(String message, String mobileDeviceId = null)message - Notification text.mobileDeviceId - Optional; defaults to null. Target mobile device id; null skips sending.none
Creates and sends an event for the hub location.
void sendLocationEvent(Map properties)properties - A Map of properties for the event, using the same keys as sendEvent() (e.g., name, value, unit, descriptionText, isStateChange).none
Looks up the MAC address associated with an IP address.
String getMACFromIP(String ipAddr)ipAddr - IP address to look up.MAC address, or null when no matching address is found.
Returns resolved mDNS service endpoints for a local service type.
List<Map> getMDNSEntries(String serviceType)serviceType - Service type without the .local. suffix.List of endpoint maps. Each map contains:
server: String server name.port: Integer service port.ip4Addresses: comma-separated String of IPv4 addresses; empty when none are reported.ip6Addresses: comma-separated String of IPv6 addresses; empty when none are reported.Registers the shared mDNS listener for a local service type if one is not already registered.
void registerMDNSListener(String serviceType)serviceType - Service type without the .local. suffix.none
Listens for mDNS service changes on a worker thread for a bounded duration.
void startMdnsListener(String serviceType, int durationSeconds = 30)serviceType - The mDNS service type, without the .local. suffix.durationSeconds - Optional; Listen duration in seconds; defaults to 30 and must be between 15 and 60.none
Tests whether a string is a valid IP address.
boolean isValidIP(String ip)ip - Address text to validate.true if the string is a valid IP address, false otherwise.
Tests whether a string is a valid MAC address.
boolean isValidMAC(String mac)mac - Address text to validate.true if the string is a valid MAC address, false otherwise.
Decodes a LAN message and parses its optional HTTP headers and body.
Map parseLanMessage(String stringToParse)stringToParse - Comma-separated key:value fields, with headers and body values Base64-encoded when present.Map containing the parsed comma-separated input fields and these conditional entries:
headers: when present in the input and at least one header line is decoded, it is replaced with a Map<String,String-or-null> of header names and values; a line without a colon has a null value.header: decoded header block String when input headers are present.status: Integer HTTP status when a decoded header line contains a parseable HTTP/1.x status line with three space-separated parts.body: decoded body String when input body is present.json: parsed JSON Object when body content type is JSON or JavaScript and parsing succeeds.xml: parsed GPathResult when body content type is XML and parsing succeeds.data: the same parsed value as json or xml when parsing succeeds.Input fields are String keys with trimmed String values, or null for empty values. Null input or input without a comma produces an empty map. JSON or XML parse failures leave out the parsed-value entries.
ArrayIndexOutOfBoundsException when a non-empty comma-separated field has no colon.
NullPointerException when a decoded header block has entries but no HTTP/1.x status line.
Looks up a Z-Wave device join name from integer identifiers. Looks up a Z-Wave device join name from hexadecimal identifiers.
String getZWaveDeviceJoinName(Integer mfr, Integer typeId, Integer productId)String getZWaveDeviceJoinName(String mfr, String typeId, String productId)mfr - Manufacturer id.typeId - Device type id.productId - Product id.Matching device type name, or the service fallback when no match exists.
Looks up a Zigbee device join name from manufacturer and model strings.
String getZigbeeDeviceJoinName(String manufacturer, String model)manufacturer - Manufacturer string reported by the device.model - Model string reported by the device.Matching device type name, or the service fallback when no match exists.