Device name substitution?
-
InsteonDiego
- Posts: 48
- Joined: Wed Dec 07, 2016 4:01 pm
Device name substitution?
I'm positive I'm just missing it, but a search of the forums and review of Github didn't point me in the correct direction. Is there a method to include the device name via substitution? I am looking to template my emails for many duplicate triggers and I'd like to be able to replace the device name as well as a few states. I have tried %%d:someID%% and %%d:someID:%% and a variety of others without luck (to be clear, including the state results in a proper substitution, but I am looking to get the device name as well). I realize I could create an action to assign the device name to a variable and then reference that variable with %%v:vID%%, but wondering if there is a more direct route. Thank you!!
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: Device name substitution?
Device name for what device? The device that activated the trigger? Or the SMTP device you're sending the email with? And where do you need to use this substitution?
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
-
InsteonDiego
- Posts: 48
- Joined: Wed Dec 07, 2016 4:01 pm
Re: Device name substitution?
You certainly win the award for fastest response! Thank you 
Ideally the device name for any device I choose. Limiting to the device that activated the trigger wouldn't be ideal for me as it would be one degree of separation in this case (I use the timed devices plugin to trigger based on certain thresholds of the actual device). Below is an example of an email.
Subject: Garage Freezer over 0 for 30 minutes
Body: Current %%d:1368692178%%: %%d:1368692178:Temperature%%
%%d:1368692178%% change in last 10 minutes: %%d:1368692178:TemperatureChange10Minutes%%
From a templating approach, would be nice to replace Garage Freezer with %%d:1368692178%% similar to what I am trying to do in the body. I could then copy and paste this text between email actions and simply bulk change all of the IDs.
Ideally the device name for any device I choose. Limiting to the device that activated the trigger wouldn't be ideal for me as it would be one degree of separation in this case (I use the timed devices plugin to trigger based on certain thresholds of the actual device). Below is an example of an email.
Subject: Garage Freezer over 0 for 30 minutes
Body: Current %%d:1368692178%%: %%d:1368692178:Temperature%%
%%d:1368692178%% change in last 10 minutes: %%d:1368692178:TemperatureChange10Minutes%%
From a templating approach, would be nice to replace Garage Freezer with %%d:1368692178%% similar to what I am trying to do in the body. I could then copy and paste this text between email actions and simply bulk change all of the IDs.
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: Device name substitution?
I'm just using the built-in Indigo substitution routine. You'd have to write your own Python script, and call the BE plugin from there, to do that.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
-
InsteonDiego
- Posts: 48
- Joined: Wed Dec 07, 2016 4:01 pm
Re: Device name substitution?
Thank you.
-
InsteonDiego
- Posts: 48
- Joined: Wed Dec 07, 2016 4:01 pm
Re: Device name substitution?
For anybody else that comes across this and is looking for a quick solution, an embedded python script worked really well. Here is my approach (with some assistance from FlyingDivers's post re using python to send attachments with BetterEmail):
Code: Select all
emailaddress1 = "[email protected]"
ccemailaddress1 = None
bccemailaddress1 = None
betterEmailDevice = indigo.devices[57512184624] # "Gmail SMTP Server"
device = indigo.devices[333487818] # "temp_Garage_Freezer"
emailAttachments = "/Users/thisuser/Documents/INDIGOplotD/Temp Garage Fridge Freezer-minute-S1.png"
emailSubject = u"{} over 15\N{DEGREE SIGN} for 30 minutes".format(device.name)
emailBodyTemplate = u"Current {}: {}\N{DEGREE SIGN}\nChange in last 10 minutes: {}\N{DEGREE SIGN}"
emailBody = emailBodyTemplate.format(device.name, device.states['Temperature'], device.states['TemperatureChange10Minutes'])
valueDict = {
'emailTo': emailaddress1,
'emailCC': ccemailaddress1,
'emailBCC': bccemailaddress1,
'emailSubject': emailSubject,
'emailAttachments': emailAttachments,
'emailMessage': emailBody
}
beDict = {x:y for x,y in valueDict.items() if y!=None}
bePlugin = indigo.server.getPlugin("com.flyingdiver.indigoplugin.betteremail")
if bePlugin.isEnabled():
bePlugin.executeAction("sendEmail", deviceId=betterEmailDevice.id, props=beDict)
else:
indigo.server.log("Trigger attempt to send email via Better Email. Plug-in not enabled!")
return False