Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
indigo_5_documentation:server_commands [2011/10/20 21:06]
jay [Get Serial Ports]
indigo_5_documentation:server_commands [2019/01/26 00:10] (current)
Line 1: Line 1:
 +====== Server Commands (indigo.server.*) ======
  
 +Commands that aren't associated with any specific object type are collected up in the indigo.server.* command namespace.
 +
 +==== 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 ​ ^
 +|<​code>​indigo.server.calculateSunrise()</​code>​|
 +|<​code>​indigo.server.calculateSunrise(myDateObject)</​code>​|
 +
 +^  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 ​ ^
 +|<​code>​indigo.server.calculateSunset()</​code>​|
 +|<​code>​indigo.server.calculateSunset(myDateObject)</​code>​|
 +
 +^  Parameters ​ ^^^^
 +^  Parameter ​ ^  Required ​ ^  Type  ^  Description ​ ^
 +|direct parameter| ​ No  |  //''​datetime.date''// ​ |a //''​datetime.date''//​ object representing the day to calculate the sunrise 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 ​ ^
 +|<​code>​indigo.server.getEventLogList()</​code>​|
 +|<​code>​indigo.server.getEventLogList(lineCount=5)</​code>​|
 +|<​code>​indigo.server.getEventLogList(showTimeStamp=False)</​code>​|
 +|<​code>​indigo.server.getEventLogList(lineCount=5,​ showTimeStamp=False)</​code>​|
 +|<​code>​indigo.server.getEventLogList(returnAsList=True,​ lineCount=5)</​code>​|
 +
 +^  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 it’s timestamp prepended to the log entry - the default is true|
 +
 +==== 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 ​ ^
 +|<​code>​latLong=indigo.server.getLatitudeAndLongitude()
 +lat = latLong[0]
 +long = latLong[1]</​code>​|
 +
 +==== Get Plugin ====
 +
 +Returns a plugin object given the plugin id.
 +
 +^  Command Syntax Examples ​ ^
 +|<​code>​myPlugin=indigo.server.getPlugin("​com.company.pluginId"​)</​code>​|
 +
 +^  Parameters ​ ^^^^
 +^  Parameter ​ ^  Required ​ ^  Type  ^  Description ​ ^
 +|direct parameter| ​ Yes  |string|the id of the plugin to retrieve|
 +
 +See [[https://​wiki.indigodomo.com/​doku.php?​id=indigo_5_documentation:​plugin_scripting_tutorial#​scripting_indigo_plugins|scripting plugins]] for details and examples of using this method.
 +
 +==== 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 ​ ^
 +|<​code>​indigo.server.getSerialPorts()</​code>​|
 +|<​code>​indigo.server.getSerialPorts(filter="​indigo.ignoreBluetooth"​)</​code>​|
 +
 +^  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|
 +
 +=== Examples ===
 +
 +<​code>​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.itervalues():​
 + print(uiName)
 +# iterate through both
 +for posixPath, uiName in ports.iteritems():​
 + print(posixPath)
 + print(uiName)</​code>​
 +
 +==== Get Time ====
 +
 +Returns a datetime object representing the server'​s current time.
 +
 +^  Command Syntax Examples ​ ^
 +|<​code>​indigo.server.getTime()</​code>​|
 +
 +No Parameters
 +
 +=== Examples ===
 +
 +<​code>​serverTime = indigo.server.getTime()</​code>​
 +
 +==== 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. ​
 +
 +^  Command Syntax Examples ​ ^
 +|<​code>​indigo.server.log("​Text to log"​)</​code>​|
 +|<​code>​indigo.server.log("​Text to log", type="​myType"​)</​code>​|
 +|<​code>​indigo.server.log("​Text to log", isError=True)</​code>​|
 +
 +^  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|
 +|''//​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 ​ ^
 +|<​code>​indigo.server.removeAllDelayedActions()</​code>​|
 +
 +==== Send Email ====
 +
 +This tells IndigoServer to send an email using the SMTP settings configured in the preferences “Email” tab.
 +
 +^  Command Syntax Examples ​ ^
 +|<​code>​indigo.server.sendEmailTo("​my.address@example.com"​)</​code>​|
 +|<​code>​indigo.server.sendEmailTo("​my.address@example.com",​ subject="​Subject of email",​ body="​Body of email"​)</​code>​|
 +
 +^  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 ​ ^
 +|<​code>​indigo.server.speak("​text to speak",​ waitUntilDone=True)</​code>​|
 +
 +^  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)|
 

© Perceptive Automation, LLC. · Privacy