Server Properties and Commands (indigo.server.*)¶
In this guide
These are properties and commands that aren't associated with any specific object type and are inside the indigo.server.* command namespace.
Properties For Connected Indigo Server¶
| Property | Type | Writable | Description |
|---|---|---|---|
address |
string | No | the IP address of the currently connected Indigo Server |
apiVersion |
string | No | API v1.7 the currently connected Indigo Server plugin API version as a string (ex: "1.7") |
connectionGood |
boolean | No | true if the connection to the Indigo Server is currently good |
licenseStatus |
string | No | API v2.5 returns one of the values specified in the indigo.kLicenseStatus enumeration below |
portNum |
integer | No | the port number of the currently connected Indigo Server |
tags |
dictionary | No | API v3.9 the entire tag library as a dictionary mapping each tag name to a dictionary of its colors - see Tag Library below |
version |
string | No | the currently connected Indigo Server version string |
License Status Enumeration¶
indigo.kLicenseStatus |
|
|---|---|
| Value | Description |
ActiveTrial |
the license is a trial |
ActiveSubscription |
license has an active Indigo Up-to-Date subscription (access to a reflector) |
ExpiredSubscription |
license has an expired Indigo Up-to-Date subscription (no access to a reflector) |
Unknown |
license is in an unknown state |
Broadcast to Subscribers¶
This command will broadcast a message to other plugins that have subscribed to the specified plugin's messages.
Command Syntax Examples
indigo.server.broadcastToSubscribers(messageName)
Calculate Sunrise¶
This command will return a datetime object that represents the sunrise for the specified day (or the next sunrise if no date is passed in).
Command Syntax Examples
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| direct parameter | No | datetime.date |
a datetime.date object representing the day to calculate the sunrise time for |
Calculate Sunset¶
This command will return a datetime object that represents the sunset for the specified day (or the next sunset if no date is passed in).
Command Syntax Examples
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| direct parameter | No | datetime.date |
a datetime.date object representing the day to calculate the sunset time for |
Event Log List¶
This command will return a string that contains the latest log entries. Each line is terminated with a line feed character.
Command Syntax Examples
indigo.server.getEventLogList()
indigo.server.getEventLogList(lineCount=5)
indigo.server.getEventLogList(showTimeStamp=False)
indigo.server.getEventLogList(lineCount=5, showTimeStamp=False)
indigo.server.getEventLogList(returnAsList=True, lineCount=5)
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| returnAsList | No | boolean | if true a list of dicts is returned containing individual log entry attributes; if false a string containing a textual description of the log lines is returned - the default is false |
| lineCount | No | integer | the number of lines to return from the event log starting from newest and going backwards in time - the default is 1500 |
| showTimeStamp | No | boolean | indicate whether every line should have its timestamp prepended to the log entry - the default is true |
Get Database File Name¶
Returns the name of the current database (without the file extension). It takes no parameters.
Command Syntax Examples
name=indigo.server.getDbName()
Get Database File Path¶
Returns the POSIX path to the current database file (includes the file name with extension). It takes no parameters.
Command Syntax Examples
name=indigo.server.getDbFilePath()
Get Deprecated Elements¶
Returns the server's list of elements that have attributes or properties that are now deprecated.
Command Syntax Examples
name=indigo.server.getDeprecatedElems(includeWarnings=[True/False])
Get Install Folder Path¶
Returns the POSIX path to the current Indigo installation path. Useful if you want to manipulate files (like graphics and scripts) that are in the Indigo installation path. It takes no parameters.
Command Syntax Examples
name=indigo.server.getInstallFolderPath()
Get Latitude and Longitude¶
Returns a list of floating point numbers where the first float is the latitude and the second (and last) is the longitude. It takes no parameters.
Command Syntax Examples
Get Plugin¶
Returns a PluginInfo object given the plugin id.
Command Syntax Examples
myPlugin=indigo.server.getPlugin("com.company.pluginId")
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| direct parameter | Yes | string | the id of the plugin to retrieve |
See Plugin Info for the object's properties and methods, and scripting plugins for details and examples of using this method.
Get Plugin List¶
API v2.4 Returns a list of PluginInfo object instances. By default, only enabled plugins are returned — pass includeDisabled=True to get disabled ones as well.
Command Syntax Examples
enabled_plugin_list=indigo.server.getPluginList()
all_plugin_list=indigo.server.getPluginList(includeDisabled=True)
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| includeDisabled | No | boolean | include disabled plugins in addition to enabled ones (defaults to False) |
Get Reflector URL¶
API v2.5 Returns a string with the URL to the active reflector. Returns None if there is no reflector or if remote access is disabled.
Command Syntax Examples
Get Serial Ports¶
Returns a dictionary representing all serial ports on the server machine. The key is the full path specification for the port (for use by PySerial) and the value is just the name of the port (for display purposes).
Command Syntax Examples
ports = indigo.server.getSerialPorts(filter="indigo.ignoreBluetooth")
# iterate through the full paths
for posixPath in ports:
print(posixPath)
# iterate through just the port name itself
for uiName in ports.iter():
print(uiName)
# iterate through both
for posixPath, uiName in ports.iter():
print(posixPath)
print(uiName)
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
filter |
No | string | currently there’s only one valid filter: "indigo.ignoreBluetooth" which will remove the "Bluetooth-PDA-Sync" option from the list |
Get Time¶
Returns a datetime object representing the server's current time.
Command Syntax Examples
indigo.server.getTime()
Parameters
None
Get Web Server URL¶
Returns a URL string that best represents the URL to the active Indigo Web Server. This is the order of which URL will be returned:
- Reflector (
https://reflector.indigodomo.net) if a reflector is configured. - Bonjour name (
http://MacName.local:PORT) if it can be determined. - Localhost (
http://localhost:PORT) if all else fails.
Note, there is no trailing slash. PORT is the port number of the server (for example, 8176).
Command Syntax Examples
indigo.server.getWebServerURL()
Parameters
None
Log¶
This tells IndigoServer to write a log entry with the specified text. The type in the log will be the name of the plugin. The examples below that refer to the logging package assume that you've done this somewhere before: import logging
Command Syntax Examples
indigo.server.log("Info Text to log")
indigo.server.log("Info Text to log", type="myType")
indigo.server.log("Warning Text to log", level=logging.WARNING)
indigo.server.log("Error Text to log1", level=logging.ERROR)
indigo.server.log("Error Text to log2", isError=True)
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| direct parameter | Yes | string | this is the text that’s written to the log |
type |
No | string | a string representing the type - if it’s not included and is run from a Server Plugin, the name of the plugin will automatically be used |
level |
No | integer | API v2.4 the python logging level which determines both the type shown and the text color used. (ex: using level=logging.WARNING will show orange text) |
isError |
No | boolean | if True, it will show up in red in the event log - default is False - if no type is included, the name of the plugin will automatically be used with " Error" appended |
Remove All Delayed Actions¶
This command will remove all delayed actions currently scheduled. It doesn’t take any parameters.
Command Syntax Examples
indigo.server.removeAllDelayedActions()
Restart Plugin¶
This command will tell the server to restart our plugin process. The message is printed to the event log, and if isError is true then it's logged as an error. This command can only be called from a plugin, and it refers to the plugin itself (not other plugins).
Command Syntax Examples
indigo.server.restartPlugin("Restarting now for some reason", isError=True)
Save Plugin Preferences¶
The Indigo server will save changes to plugin preferences automatically, and this command will cause the server to save plugin preferences immediately. It doesn’t take any parameters.
Command Syntax Examples
indigo.server.savePluginPrefs()
Send Email¶
This tells IndigoServer to send an email using the SMTP settings configured in the preferences "Email" tab.
Command Syntax Examples
indigo.server.sendEmailTo("[email protected]")
indigo.server.sendEmailTo("[email protected]",
`subject="Subject of email", body="Body of email")
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| direct parameter | Yes | string | a semicolon separated string of email addresses |
subject |
No | string | the subject of the email |
body |
No | string | the body of the email |
Speak¶
Speak a text string using the built-in speech synthesizer.
Command Syntax Examples
indigo.server.speak("text to speak", waitUntilDone=True)
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| direct parameter | Yes | string | the string to speak |
waitUntilDone |
No | boolean | should the method call block until speaking is complete or should it just return immediately (queue up the speech) |
Stop Plugin¶
Tell the server to shut down our plugin process. Plugin will remain enabled but be in a stopped state. This command can only be called from a plugin, and it refers to the plugin itself (not all plugins).
Command Syntax Examples
indigo.server.stopPlugin("Stopping now for some reason", isError=True)
Subscribe To Log Broadcasts¶
Subscribes to all server event log broadcasts.
Command Syntax Examples
indigo.server.subscribeToLogBroadcasts()
Parameters
None
Subscribe To Tag Changes¶
API v3.9 Asks the server to tell this plugin when the tag library changes. One subscription covers the whole library, since one library is shared by every object type.
Command Syntax Examples
indigo.server.subscribeToTagChanges()
Parameters
None
Call it once, in startup(). It delivers the tag_created, tag_updated and tag_deleted callbacks — see Folder and Tag Methods. Plugins only: calling it from a script or the interactive shell raises ValueError.
Tag Library¶
API v3.9 Tags are labels you can put on devices, variables, triggers, schedules, action groups, and control pages. They live in one library owned by the server, and these commands maintain that library. See Tags for what tags are and how they differ from folders.
Assigning Tags
To assign a tag that is already in the library to an Indigo object instance, use the add_tag and remove_tag commands in that object's own namespace — indigo.device.add_tag(), indigo.variable.remove_tag(), and so on.
Reading The Library¶
The indigo.server.tags property is the whole library: a dictionary mapping every tag name to a dictionary of that tag's colors.
indigo.server.tags
# {"kitchen": {"color": "4A90D9", "text_color": "082F53", "border_color": "1C65AB"}, ...}
# Both of these read the way you'd expect, since the library is a dictionary keyed by name:
if "kitchen" in indigo.server.tags:
indigo.server.log(indigo.server.tags["kitchen"]["color"])
A tag's value is a dictionary with three colors in it, not a bare color string:
| Key | Settable | Description |
|---|---|---|
color |
Yes | the color the user chose - the tag's background, and the only one that is stored |
text_color |
No | the color to draw the tag's text in, derived from color by the server |
border_color |
No | the color to draw the tag's border in, derived from color by the server |
All three are six uppercase hex digits with no separators and no leading #, for example "4A90D9". That is the same format the HTTP and WebSocket APIs use, so nothing in the stack converts between color representations.
The library is a copy
indigo.server.tags hands you a copy of the library, so changing it changes nothing on the
server: indigo.server.tags["kitchen"]["color"] = "FF8800" runs without an error and the tag
keeps its color. To change a tag, use update_tag(), for example
indigo.server.update_tag("kitchen", new_color="FF8800").
Draw tags with text_color and border_color, don't compute your own
Only color is a choice; the other two are derived from it in the server, taking the tag's own
hue darker or lighter. Publishing them is the whole reason they exist: every Indigo interface
derives them with one shared implementation, so a plugin or a third-party client that reads
them off the tag's dictionary draws a tag exactly the way Indigo does. Working out your own contrast
against the background is how three interfaces end up disagreeing about the same tag. A border
is optional: Indigo Touch for Web draws one in border_color, while the Mac client draws no
border and uses only color and text_color.
Note that indigo.server.tags and an object's own tags property are different shapes on purpose. The library maps every name to a dictionary of colors; an object's tags is a plain read-only list of the names that object carries.
Create Tag¶
Adds a tag to the library. It is not put on any object; use add_tag for that.
Command Syntax Examples
indigo.server.create_tag("kitchen", "4A90D9")
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| direct parameter | Yes | string | the tag name - lowercase letters separated by single dashes |
| second parameter | Yes | string | the tag's color as six hex digits, no leading # (ex: "4A90D9") |
Creating a tag that is already in the library raises ValueError.
Delete Tag¶
Removes a tag from the library, and from every object currently carrying it. This can't be undone.
Command Syntax Examples
indigo.server.delete_tag("kitchen")
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| direct parameter | Yes | string | the tag name to delete |
Update Tag¶
Renames a tag, changes its color, or both. A rename carries the tag on every object that has it, so nothing loses its tag.
Command Syntax Examples
indigo.server.update_tag("kitchen", new_tag="kitchen-area")
indigo.server.update_tag("kitchen", new_color="FF8800")
indigo.server.update_tag("kitchen", new_tag="kitchen-area", new_color="FF8800")
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| direct parameter | Yes | string | the tag name to change |
new_tag |
No | string | the new name for the tag |
new_color |
No | string | the new color as six hex digits, no leading # |
At least one of new_tag and new_color must be given - a call that asks for no change is reported as an error rather than ignored. Passing the tag's current name or current color is accepted and does nothing. Renaming a tag to a name that already belongs to a different tag raises.
Recoloring touches no objects at all, since the color belongs to the library entry rather than to the objects carrying the tag.
Errors¶
A malformed tag name or color raises indigo.utils.ValidationError. Naming a tag that isn't in the library raises ValueError, as does creating one that already is.
Wait Until Idle¶
Wait (block) until server has completed event processing and command sending.
Command Syntax Examples
indigo.server.waitUntilIdle()
Parameters
None