Requirements:
- Indigo email settings must be properly configured.
- Must have two Indigo Variables established (battery threshold and target email address.)
- Code: Select all
target_level = int(indigo.variables[VARIABLE ID NUMBER].value) # lowBatteryLevel
email_address = indigo.variables[VARIABLE ID NUMBER].value # "notificationEmailAddress"
email_body = ""
for dev in indigo.devices.itervalues():
if dev.batteryLevel:
if dev.batteryLevel <= target_level:
email_body += f"{dev.name} battery level: {dev.batteryLevel}\n"
if email_body != "":
email_body = "The following Indigo devices have low battery levels:\n" + email_body
indigo.server.sendEmailTo(email_address, subject="Indigo Low Battery Alert", body=email_body)
(Variations of this script are located elsewhere in the forum, just adding it here for reference and future enhancements.)
[EDIT 1] moved to the Dave's Scripts forum.
[EDIT 2] fixes bug that results in all devices being reported as low.
[EDIT 3] refinements and updates for Python 3.
[EDIT 4] fixes bug that results in report being sent even if there's no low batteries.