Get it in the File Library
Version History
v1.0 - Initial release
Description
This script will loop through all indigo devices looking for devices that report battery levels. We do this by looking at the batteryLevel property that all devices have. If a device doesn't support battery reporting, that value will be 'None'. We also check to see if the device is enabled so that an easy way to shortcut getting notifications you don't want is to just disable the device.
When the script finds one, it will use the following heuristics to decide if a notifiction should be sent for the device:
- if the battery level is below the 'batteryThreshold' OR
- if the device hasn't been updated in more than 'timeThreshold' days
There are a couple of ways to set the thresholds. The default values are:
batteryThreshold = 5%
timeThreshold = 0 days (or anything over 24 hours)
These defaults can be overridden globally by creating Indigo variables named:
lbnBatteryThreshold
lbnTimeThreshold
If either of these are set, they will be used as the global thresholds. You may also use the Global Property Manager plugin to add some properties to specific devices that will override these thresholds:
lbnBatteryThreshold
lbnTimeThreshold
lbnSkipNotification
The latter tells the script to ignore this device (true/false or yes/no). You might want to use that for a battery powered device that can also be plugged into mains power. In that case, it may or may not show battery level and may not actually report status for long periods of time. This is a convenient way to just skip those devices.
Once we've determined that a device needs a notification, then we simply look for an action group named with the device name + " low battery notification". Here's some example names given the device name:
Code: Select all
Device Name | Action Group Name
-------------------+------------------------------
Front Door Lock | Front Door Lock low battery notification
Hall motion sensor | Hall motion sensor low battery notification
Note that the names are case sensitive so make sure they match. If the script finds a matching Action Group, it will execute it.
There are several ways you can run this script: once a day is probably the easiest. You can get clever however and run it every hour. Add some current time conditions to the schedule and it can notify you once an hour between, say, 6pm and 10pm. Lots of options.
I contributed this script because it does what I need it to do, no more or less. There are a lot more things that this script can be expanded to do and is a great start for other kinds of notifications. Feel free to modify it as you see fit. Note, however, that it's not an officially supported script and is not shipped with Indigo. I'll certainly try to answer any questions and will update this post to clarify anything that's unclear, but treat it like any other user-contributed script.