-
Notifications
You must be signed in to change notification settings - Fork 1
Conversion Devices
Conversion devices allow you to manipulate values from other devices or variables. There may be a number of reasons that you want to have a conversion device, depending on your home automation needs. The conversion does several things for you, any one of which may enhance your control pages or ease in automating other parts of your system.
The following conversions are possible:
- Fahrenheit to Celsius and Celsius to Fahrenheit
- Device State to Boolean Value
- LUX Value to Human Readable Word
- Date and Time to Elapsed Minutes
- Boolean Value to String
- Boolean Type to Boolean Type
- Value Is Always True or Always False
- Value to String With Ability To Trim String
- Date and Time Reformatting (from any Python format to any Python format)
- Strings to Numbers
- Strings to Cased Strings (mixed, proper, lower, upper)
Many folks use the Indigo UI as their primary interface to their devices. Device extensions allows you to create different values and views for your data - not only in the device state itself but also the icon you see.

You can gain access to your converted values from the device states that are a part of every conversion device.
convertedBoolean : true (bool) convertedNumber : 0 (integer) convertedValue : true (string)
Accessing via Python code:
dev = indigo.devices[1329518440] # "Yale Door Lock"
if dev.states["convertedBoolean"] == True:
...
if dev.states["convertedValue"] == "Locked":
...
if dev.states["convertedNumber"] == 0:
...
Using in the Indigo dialogs:

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from Celsius to Fahrenheit or Fahrenheit to Celsius.
Introduced In: Version 1.x
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device
- Variable: Any Indigo variable
- State: Any number state on the device that represents the temperature you want to convert
- Action: Convert Celsius to Fahrenheit / Fahrenheit to Celsius: Convert any numeric state from one measurement to another, this will show in your Indigo device list as the converted temperature
- Decimal Precision: How many decimals the end result should round to. If set to zero the return value will be an integer (i.e., 74.3 will return as 74, not 74.0)

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from any Indigo device state to a boolean (true/false) value.
Introduced In: Version 1.x
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device
- Variable: Any Indigo variable
- State: Any state you want to convert
- Action: Convert State To Boolean: Converts any device state to a boolean value. This is handy for control pages when you want an indicator showing if some particular device state is true
- True / False Values: Whatever the state must equal to be either true or false. While you can use both conditions, you might only want to use a single condition since if neither condition passes or both conditions pass the result will be false. You can If-Then-Else this by using the world ELSE (not case sensitive) as one of the values

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from any LUX representation to a phase of what that LUX actually means in human-readable terms.
Introduced In: Version 1.x, Updated in 2.0.5
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device
- Variable: Any Indigo variable
- Action: Convert Lux to Word State: Yes, this is an odd conversion but one I found myself wanting. I have devices that show the Lux light level in a room but always wonder "Is 200 considered light or dark", this clears that up by converting the Lux value to an actual word state so I can create triggers that say "If room is Dim Indoors then turn on lights when motion detected".
- Adjustment: If the device you are referencing uses a LUX maximum of less than 100,001 (the normal max LUX rating) then you can use this field to adjust it appropriately, enter the maximum as a decimal. For instance, the Fibaro motion sensor will report LUX up to 32,767 so you would enter .32,767 as the value. This translates as "instead of 100,001 being direct sunlight max LUX, 32,676 is direct sunlight max LUX"

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from any date and time stored in a device state or a variable and show how many minutes have elapsed since that time.
Introduced In: Version 1.x
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device and select device properties
- Variable: Any Indigo variable
- Date/Time Python Format: The format of the date/time you are converting using Python date/time values. This must exactly match the date/time you are converting. The default value is the format used in date/time variables assigned by Indigo and should be fine for the majority of your needs.

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from a boolean (true/false) value to any string you want (i.e., when True the value is "YES!!").
Introduced In: Version 1.x
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device
- Variable: Any Indigo variable
- State: Any state you want to convert
- Action: Convert Boolean to String: If the boolean state is true then the value is what you enter in the True Value, otherwise it is the False Value

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from one boolean type to another (i.e., True to Open or False to Closed). The types are the same types used by Indigo in their various forms.
Introduced In: Version 1.x
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device
- Variable: Any Indigo variable
- State: Any state you want to convert
- Action: Convert to Boolean Type: Convert any boolean type to any other boolean type - including some that are not included in Indigo
- Reverse: If you want to reverse it at the same time and make True become False (and thus Open become Closed, etc) check this box


In this example you will learn how to create a device where the stored values and the UI state represent a static conversion so that something is always True or always False.
Introduced In: Version 1.x

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from a string value where you have trimmed any portion of the beginning or ending of the string. The trimming doesn't have to be limited to white space, it will count in the number of characters configured.
Introduced In: Version 1.x
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device
- Variable: Any Indigo variable
- State: Any state you want to convert
- Action: Convert to String will take any state value and convert it to a string. For example you may want to convert a boolean True/False to "true" or "false" or a number to a string, etc. While this is fairly pedestrian in its uses the net three fields might give you more reasons why you may want this conversion
- Max String Length: If you are trying to squeeze a state value into something else you may want to truncate the value. Say you have a date of 07/01/2016 09:23:14 but want to get only the date out of it, you could have a string length of 10 and return only the date value of that state
- Remove beginning characters: Takes this many characters off the start of the string, so taking 5 characters off the string "The big brown fox jumps" becomes "ig brown fox jumps" instead
- Remove end characters: Takes this many characters from the end of the string
- You can use a combination of all the fields to extract the "center" value of a string, if you trim the first 2 and last 3 characters from the phrase "The big brown fox" you end up with "e big brown "

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from any date format to any other date format.
Introduced In: Version 1.x
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device
- Variable: Any Indigo variable
- State: Any state you want to convert
- Input Format: The Python format of the date you are reading (what you see in the screenshot is the default for almost all Indigo dates)
- Output Format: The Python format you want to convert this to

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from any string that contains numbers that you want to extract and turn that result into an integer or decimal (float) number.
Introduced In: Version 1.x
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device
- Variable: Any Indigo variable
- State: Any state you want to convert
- Remove beginning characters: Takes this many characters off the start of the string, so taking 5 characters off the string "The big brown fox jumps" becomes "ig brown fox jumps" instead
- Remove end characters: Takes this many characters from the end of the string
- You can use a combination of all the fields to extract the "center" value of a string, if you trim the first 2 and last 3 characters from the phrase "The big brown fox" you end up with "e big brown "

In this example you will learn how to create a device where the stored values and the UI state represent a conversion from any string to a string that has capitalization in the fashion you require.
Introduced In: Version 1.x
- Select Use Device to use a device state or deselect it to use a variable value
- Device: Any Indigo device
- Variable: Any Indigo variable
- Convert To: Convert the string to all upper, all lower, title case (first letter of each word) or proper case (first letter of first word)
