Rest documentation

Posted on
Tue Dec 01, 2020 12:12 pm
DPattee offline
Posts: 453
Joined: Jan 14, 2004
Location: Redmond, WA

Rest documentation

I tried a quick forum search but didn't find what I was looking for., and google only found https://wiki.indigodomo.com/doku.php?id ... stful_urls

Is that the whole rest api?

I was looking for like a /status or something that would let me get some kinds of information like what interfaces were online/offline, or a /log endpoint that would let me get the latest log message (or just the latest error level message, etc)

My goal is to set up a remote monitor to let me know when indigo is effectively offline. I already have some triggers within Indigo that can email when when an error appears in the log and stuff liek that, but I'm trying to standardize monitoring for all my services (not just home automation) through a tool that can do http calls and analyze the output (notify on change, regex based alerting, that kind of stuff)

Posted on
Tue Dec 01, 2020 12:38 pm
DPattee offline
Posts: 453
Joined: Jan 14, 2004
Location: Redmond, WA

Re: Rest documentation

Just tried making some triggers to put data in to variables so I could use the /variables api.

There is a Trigger for interface initi / fail, but I didn't see a python API to get the list of interfaces to jam as a string in a variable. https://wiki.indigodomo.com/doku.php?id ... r_commands shows how to get the serial ports and another page mentions how you can programmatically set up a trigger based on interface failures...

Posted on
Tue Dec 01, 2020 1:18 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Rest documentation

This may not give you everything you want/need, but using Python you can always run a dir to see all the commands made available by the indigo.server.* namespace:

Code: Select all
foo = dir(indigo.server)
indigo.server.log(u"{0}".format(foo))
Which yields:

Code: Select all
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_displayServerProgress', '_progressClearAll', '_progressFlash', '_progressInPop', '_progressInPush', '_progressInPushPop', '_progressOutPop', '_progressOutPush', '_progressOutPushPop', '_pushPayload', '_setInterfaceConnectState', '_triggerInterfaceFailure', '_triggerInterfaceInitialized', '_triggerPowerFailure', 'address', 'apiVersion', 'broadcastToSubscribers', 'calculateSunrise', 'calculateSunset', 'connectionGood', 'getDbFilePath', 'getDbName', 'getDeprecatedElems', 'getEventLogList', 'getInstallFolderPath', 'getLatitudeAndLongitude', 'getLogsFolderPath', 'getPlugin', 'getSerialPorts', 'getTime', 'log', 'portNum', 'removeAllDelayedActions', 'savePluginPrefs', 'sendEmailTo', 'speak', 'stopPlugin', 'subscribeToBroadcast', 'subscribeToLogBroadcasts', 'version', 'waitUntilIdle']
We can get the attributes of a method by using getattr like so:

Code: Select all
import inspect


method_to_call = getattr(indigo.server, "log")
inspector = inspect.getdoc(method_to_call)
indigo.server.log(u"{0}".format(inspector))
Which yields:

Code: Select all
log( (object)message [, (object)type='' [, (bool)isError=False]]) -> None :
    Writes a log entry with the specified text. By default the
    type shown in the log will be the name of the plugin.
This will give you access to all that is available--whether or not you're allowed (or should) varies. The best shortcut to this information is through the Indigo Scripting Shell, where:
Code: Select all
help(indigo.server.log)
Yields:

Code: Select all
log( (object)message [, (object)type='' [, (bool)isError=False]]) -> None :
    Writes a log entry with the specified text. By default the
    type shown in the log will be the name of the plugin.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Dec 01, 2020 1:52 pm
DPattee offline
Posts: 453
Joined: Jan 14, 2004
Location: Redmond, WA

Re: Rest documentation

Oh those are good tips, I had no idea even about dir for example

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests

cron