Page 1 of 1

(Probably) dumb python question

PostPosted: Sun Feb 14, 2021 2:09 pm
by Stoutjesdijk
Hi,

I am trying to access the TRV devices through Python, and then do some stuff with the Boost. How do I get a directory of methods and properties that I could access?
Specifically, I would like to assess whether Boost is ON or OFF, and I'd like to be able to turn it on and off. The default boost mode is good enough.

I am just starting with Python and am probably missing a very simple way of getting those lists...

Thanks!

Re: (Probably) dumb python question

PostPosted: Sun Feb 14, 2021 9:12 pm
by FlyingDiver
To get the states of the device that you can access, you need to expose the state list below the standard UI. To do that, drag UP on the dimple at the top of the device details pane:

Screen Shot 2021-02-14 at 10.09.23 PM.png
Screen Shot 2021-02-14 at 10.09.23 PM.png (115.7 KiB) Viewed 1907 times


There are standard methods in the Wiki for each of the standard Indigo device types (sensor, relay, thermostat, etc). If the plugin defines custom actions, either they'll be in the documentation for the plugin, or if you're brave you can look at the Actions.xml file in the plugin wrapper and figure it out from there.

Re: (Probably) dumb python question

PostPosted: Mon Feb 15, 2021 4:53 am
by autolog
Hi Mark,
The documentation is not yet completed for scripting. It is on my ever lengthening to-do list. :|

Here is an example script to invoke boost in a script:
Code: Select all
import logging
trvPluginId = "com.autologplugin.indigoplugin.trvcontroller"
trvPlugin = indigo.server.getPlugin(trvPluginId)
if trvPlugin.isEnabled():
    boostMode = "1"  # "1" = Delta T, "2" = Setpoint
    boostDeltaT = "5.0"  # Only needed if boostmode = "1" [Delta T]
    boostSetpoint = "25.0"  # Only needed if boostmode = "2" [Setpoint]
    boostMinutes = "30"

    # Turn on Boost: Change deviceId to the id number of he TRV Controller device you are wanting to boost
    trvPlugin.executeAction("processBoost", deviceId= 12345678, props={"boostMode":boostMode, "boostDeltaT":boostDeltaT, "boostSetpoint":boostSetpoint, "boostMinutes":boostMinutes })

    # Turn off Boost: Change deviceId to the id number of he TRV Controller device you are wanting to boost
    trvPlugin.executeAction("processCancelBoost", deviceId= 12345678)
else:
    indigo.server.log("Boost action ignored as TRV plugin not enabled", level=logging.WARNING) # log a failure message

As Joe has illustrated, all the custom state names are listed in custom states are in the Indigo devices UI.

To access the boost state in a script, you need something like:
Code: Select all
trvDeviceId = 12345678
trvDevice = indigo.devices[trvDeviceId]
boostActive = bool(trvDevice.states["boostActive"])
# boostActive will be either True or False


There isn't (currently) a definitive list of methods and properties in the Wiki.
As Joe points out, you can see what is available by looking at the Actions.xml file in the plugin by using Show Package Contents from the Finder.

Hope this gets you started. :)

Re: (Probably) dumb python question

PostPosted: Mon Feb 15, 2021 12:32 pm
by Stoutjesdijk
Great guys, thanks!!