Combining variables in Email Subject field

Posted on
Fri Dec 27, 2019 1:05 pm
TomJ offline
Posts: 8
Joined: Nov 08, 2009
Location: Midwest

Combining variables in Email Subject field

Sorry for writing a book. I felt I needed to clarify my issue.

Previously, I was using Indigo's BUILT-IN EMAIL and used the following AppleScript which worked fine.

property emailAddress : "emailname@yahoo.com"
property newline : ASCII character (10)
tell application "IndigoServer"
set rightNow to (time string of (current date))
set emailSubject to ""
set emailSubject to emailSubject & "Status: " & value of variable "doorsAllCurrentStatus"
set emailSubject to emailSubject & " @ " & rightNow
set emailSubject to emailSubject & " CT"

The resulting email was a succinct one line reply in the SUBJECT FIELD:

SUBJECT: Status is SECURE @ 12:37PM CT

But now converting to Python and now using BETTER EMAIL (and NOT using the Indigo's built-in email), I can insert variable's directly into the SUBJECT line.

Warning: I'm just starting to learn Python so explain it to me like i'm five.

I've had partial success with this in Better Email's SUBJECT field:

%%v:110544018%% %%v:413897097%% %%v:1562782016%% %%v:113832102%%

%%v:110544018%% = "Status is "
%%v:413897097%% = the variable "doorsAllCurrentStatus"
%%v:1562782016%% = "@"
%v:113832102%% = "CT"

Results in:

SUBJECT: Status is SECURE @ CT

How do I add the TIME as well in the SUBJECT line?

Again I'm just learning Python, but how would you code this.

General questions to clarify my weak understanding if you have the time:

1) I can't combine plain text and variables in one line? (Plain text has to be a variable as well?) Mine looks very messy.
2) Abandoning this approach using Better Email, Trying various solutions it appears that I can't use an Indigo Server Actions script that combines the details of both the SUBJECT and BODY because that would rely on Indigo's indigo.server.sendEmailTo command. This requires using Indigo's built-in email ? which is no longer configured as it was recommended to use either the built-in email or Better Email. I understand how this could create problems with polling a POP server and Indigo remembering which emails it has read. However, I'm wondering if I can use BOTH the built-in AND Better Email's SMTP configurations for whatever resulting ACTION works best. Wouldn't these separate SMTP's operate independently without causing problems?
3) I'm in a hole, should I stop digging?

Posted on
Fri Dec 27, 2019 3:14 pm
TomJ offline
Posts: 8
Joined: Nov 08, 2009
Location: Midwest

Re: Combining variables in Email Subject field

I realize now that my original post was TLDR. Let me fix that.

Using the AppleScript below that has been working fine, How can I create an equivalent Python script that uses variables in the SUBJECT field to make the end result look like this?

SUBJECT: Status is SECURE @ 12:37PM CT

property emailAddress : "emailname@yahoo.com"
property newline : ASCII character (10)
tell application "IndigoServer"
set rightNow to (time string of (current date))
set emailSubject to ""
set emailSubject to emailSubject & "Status: " & value of variable "doorsAllCurrentStatus"
set emailSubject to emailSubject & " @ " & rightNow
set emailSubject to emailSubject & " CT"

Using Indigo's built-in Email, Better Email, or using Indigo Server Actions scripts, which would work best?

Posted on
Fri Dec 27, 2019 10:04 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Combining variables in Email Subject field

Start here: https://github.com/FlyingDiver/Indigo-B ... etterEmail

Then you just need a line of code to put the subject line together. It would look something like:

Code: Select all
import datetime

rightNow = datetime.datetime.now().strftime("%H:%M CT")
emailSubject = "Status: " + indigo.variables["doorsAllCurrentStatus"].value + " @ " + rightNow

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

Posted on
Fri Dec 27, 2019 10:07 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Combining variables in Email Subject field


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

Posted on
Sun Jan 12, 2020 1:07 am
pkronen offline
Posts: 57
Joined: Oct 18, 2006
Location: Meggen, Switzerland

Re: Combining variables in Email Subject field

Hi guys
I don't now Python at all.
However, I like to to the following:
Upon sending an Email to Indigo, I'd like it to reply with an email back listing all states of all variables in the 'text' part, not subject part.
How ist that accomplished?

Posted on
Sun Jan 12, 2020 6:15 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Combining variables in Email Subject field

pkronen wrote:
Hi guys
I don't now Python at all.
However, I like to to the following:
Upon sending an Email to Indigo, I'd like it to reply with an email back listing all states of all variables in the 'text' part, not subject part.
How ist that accomplished?

There are a few different ways to do this. One is to use the Better Email plugin and an Email Received trigger. Note that the response time will be controlled by how frequently the plugin checks for new messages.

Screen Shot 2020-01-12 at 6.10.47 AM.png
Screen Shot 2020-01-12 at 6.10.47 AM.png (69.81 KiB) Viewed 2818 times


Screen Shot 2020-01-12 at 6.11.10 AM.png
Screen Shot 2020-01-12 at 6.11.10 AM.png (116.4 KiB) Viewed 2818 times

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

[My Plugins] - [My Forums]

Posted on
Sun Jan 12, 2020 8:47 am
pkronen offline
Posts: 57
Joined: Oct 18, 2006
Location: Meggen, Switzerland

Re: Combining variables in Email Subject field

But then I still need to use a Python script to run the plug-in?
What are the other 'ways'?

Posted on
Sun Jan 12, 2020 9:06 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Combining variables in Email Subject field

Why would you need to use Python? The example I gave uses features built into Indigo and into the Better Email plugin. There's no programming required. The data in the message body is using Indigo's substitution feature (there's a key at the bottom of that dialog).

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

[My Plugins] - [My Forums]

Posted on
Sun Jan 12, 2020 9:34 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Combining variables in Email Subject field

I think the OP wants to parse the email message text to obtain the list of variables that go in the response. I’m traveling today so I can’t work up an actual script for that.


Sent from my iPhone using Tapatalk

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

Posted on
Sun Jan 12, 2020 10:15 am
pkronen offline
Posts: 57
Joined: Oct 18, 2006
Location: Meggen, Switzerland

Re: Combining variables in Email Subject field

It seems I have to install that Plug-in. Would be the first one...
However, I realised that I can see the variables also using the App. This does it for me.
Thanks for your help so far, anyway!
Kind regards.

Posted on
Sun Jan 12, 2020 10:28 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Combining variables in Email Subject field

Yes that's true. You would need to install the Better Email plugin to use the feature. If you do anything with email and Indigo, it's recommended that you use the Better Email plugin.

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

[My Plugins] - [My Forums]

Posted on
Sun Jan 12, 2020 10:54 am
lalisingh offline
Posts: 166
Joined: Mar 27, 2007

Re: Combining variables in Email Subject field

If I understand your question this script should do the trick - I think.

Code: Select all
import datetime
# list of email receipients
slackEmail = indigo.variables[1613172563]
emailFlag = 0
emailSubject = "BMS - Security Sweep " + datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")
emailBody = ""

alarmVar = indigo.variables["Alarm_MainDoor"]
if alarmVar.value == "open":
  emailBody = emailBody + "\n %s is %s" % (str(alarmVar.name) , str(alarmVar.value))
  emailFlag += 1

indigo.server.log(str(emailBody))

if emailFlag > 0:
    emailBody = emailBody + "\n Number of notification in this message is " + str(emailFlag)
    indigo.server.sendEmailTo(slackEmail.value, subject=emailSubject, body=emailBody)

[url]https://www.VillageWorker.com[/url]
Extreme data analytics, Sensing, Control integration work.
Indigo • Barix • Kentix • Mobotix • Mikrotik • Apple

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests