Page 1 of 1

Get indigo variable into email via python

PostPosted: Sat Jan 02, 2016 7:21 am
by farberm
This may have been answered before but I cannot seem to find it in the forums.

I have created an indigo variable that is called daily_pool_water_fill

I would like to send an email with the value of daily_pool_water_fill via python script

the variable id for daily_pool_water_fill is 410242667

I create this script to send an email however I am getting an error. I do not have the proper syntax for the variable. Any help appreciated

This is the script and the error I receive

SCRIPT
poolfill = indigo.variable[410242667]
theSubject = "Pool Water Fill: is %s" % (poolfill)
theBody = "Login to see monthly chart"
indigo.server.sendEmailTo("xxxyyy@me.com", subject=theSubject, body=theBody)
return

ERROR

Jan 2, 2016, 8:16:53 AM
Script Error embedded script: 'VariableCmds' object does not support indexing
Script Error Exception Traceback (most recent call shown last):

embedded script, line 1, at top level
TypeError: 'VariableCmds' object does not support indexing

Re: Get indigo variable into email via python

PostPosted: Sat Jan 02, 2016 7:34 am
by autolog
Try:
Code: Select all
poolfill = indigo.variables[410242667].value
Note the spelling of variables (S at the end) plus you want the value :)

Documentation available here: Variables

Re: Get indigo variable into email via python

PostPosted: Sat Jan 02, 2016 7:41 am
by farberm
thx it works great

Re: Get indigo variable into email via python

PostPosted: Sat Jan 02, 2016 7:45 am
by FlyingDiver
Or, if you don't want to do any scripting at all, use the BetterEmail plugin to send the email. Then you just need to use the variable substitution syntax (%%v: 410242667%%) to put the variable value in the email text.