(Probably) dumb python question

Posted on
Sun Feb 14, 2021 2:09 pm
Stoutjesdijk offline
User avatar
Posts: 135
Joined: Dec 21, 2014
Location: The Netherlands

(Probably) dumb python question

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!

Best regards,

Mark

Trying to tie it all together...
| Indigo | Plex | NAD M33 | Unifi | LG WebOS | Tado | Sonos | SolarEdge | HUE |

Posted on
Sun Feb 14, 2021 9:12 pm
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: (Probably) dumb python question

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 1879 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.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Feb 15, 2021 4:53 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: (Probably) dumb python question

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. :)

Posted on
Mon Feb 15, 2021 12:32 pm
Stoutjesdijk offline
User avatar
Posts: 135
Joined: Dec 21, 2014
Location: The Netherlands

Re: (Probably) dumb python question

Great guys, thanks!!

Best regards,

Mark

Trying to tie it all together...
| Indigo | Plex | NAD M33 | Unifi | LG WebOS | Tado | Sonos | SolarEdge | HUE |

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests

cron