# Send an email containing a list of devices that have a low battery.
target_level = int(indigo.variables[VARIABLE ID NUMBER].value) # lowBatteryLevel
email_address = indigo.variables[VARIABLE ID NUMBER].value # "notificationicationEmailAddress"
email_body = ""
for dev in indigo.devices.itervalues():
if dev.batteryLevel:
if dev.batteryLevel <= target_level:
email_body = email_body + (u'%s battery level: %s\n' % (dev.name, dev.batteryLevel))
if email_body != "":
indigo.server.sendEmailTo(email_address, subject="Indigo Low Battery Alert", body=email_body)
DaveL17 wrote:Here's a simple script I wrote a while back:
- Code: Select all
# Send an email containing a list of devices that have a low battery.
target_level = int(indigo.variables[VARIABLE ID NUMBER].value) # lowBatteryLevel
email_address = indigo.variables[VARIABLE ID NUMBER].value # "notificationicationEmailAddress"
email_body = ""
for dev in indigo.devices.itervalues():
if dev.batteryLevel:
if dev.batteryLevel <= target_level:
email_body = email_body + (u'%s battery level: %s\n' % (dev.name, dev.batteryLevel))
if email_body != "":
indigo.server.sendEmailTo(email_address, subject="Indigo Low Battery Alert", body=email_body)
It should work in both Python 2.7 and 3.10.
Users browsing this forum: No registered users and 11 guests