The Location object is composed of methods that allow you to interact with the settings and values of a location. This object is available to apps and drivers via the "getLocation()" method or simply using the property location.
A unique id for the location, as a Long.
The name of the location as a String.
The temperature scale of the location as a String (C or F).
The time zone of the location as a TimeZone object.
The zip code of the location as a String.
The latitude of the location as a BigDecimal.
The longitude of the location as a BigDecimal.
The sunrise of the location as a Date.
The sunset of the location as a Date.
The current status of the Hubitat Safety Monitor. This is a String of one of the following values: armedAway, armingAway, armedHome, armingHome, armedNight, armingNight, disarmed, allDisarmed
A list of hubs for this location as a List<Hub>. In Hubitat, there is only one Hub in the list.
The hub for this location.
Retrieve the latitude as a formatted String.
String getFormattedLatitude()None
String - The absolute latitude followed by N for positive values, or S for zero and negative values
Retrieve the longitude as a formatted String.
String getFormattedLongitude()None
String - The absolute longitude followed by E for positive values, or W for zero and negative values
Retrieves whether or not the hub is set to 12 or 24 hour time.
String getTimeFormat()
"12" if the time is set to 12 hour (am/pm), "24" if it is set to 24 hour.
Get a list of modes for the location.
List<Mode> getModes()
A list of Mode objects
Get the current mode of the location.
String getMode()
The name of the current mode, or null if the location has no current mode
Set the current mode of the location.
void setMode(String mode)mode - The name of the mode to set as current.none
Get the current mode of the location as a Mode object (also available as the currentMode property). To get only its name, use getMode().
Mode getCurrentMode()None
The current Mode, or null if the location has no current mode
Get the modes configured for the location. Same as getModes().
List<Mode> getTrueModes()None
A list of Mode objects
Create a location variable.
void createVariable(String name, List values = null)name - The variable name.values - Optional; a List of allowed values. If null, no values are set.none
Remove a location variable.
void removeVariable(String name)name - The name of the variable to remove.none
Get the stored values of a location variable.
List getVariableValues(String locationVariable)locationVariable - The variable name.A List of the variable's values, or null if there is no such variable
Convert the location to a Map.
Map toMap(boolean full = true)full - Optional; true to include mode and hub summaries; defaults to trueMap with these keys:
id: Long location id; nullable.
name: String location name; initialized to an empty String, may be null.
temperatureScale: String temperature scale; initialized to an empty String, may be null.
timeZone: String display name of the configured time zone; requires timeZone to be non-null.
zipCode: String postal code; initialized to an empty String, may be null.
latitude: BigDecimal latitude; default 0.
longitude: BigDecimal longitude; default 0.
sunrise: Date sunrise; nullable.
sunset: Date sunset; nullable.
currentMode: String current mode name; nullable.
modes: present only when full is true; List of String mode names.
hubs: present only when full is true; List of maps each containing:
id: Long hub id; nullable.name: String hub name; nullable.