Low Battery ?

Posted on
Wed Oct 12, 2022 7:02 am
SearchCz offline
Posts: 172
Joined: Sep 18, 2019

Low Battery ?

Is there a device attribute or trigger I can use to determine which of my devices need their batteries checked / changed ? I have scripts that periodically cycle through all my devices and would be delighted to add a little battery check routine into them.

Posted on
Wed Oct 12, 2022 8:01 am
jalves offline
Posts: 745
Joined: Jun 16, 2013

Re: Low Battery ?

It somewhat depends on what devices you have. Some provide good info about their battery state (typically z-wave) while others provide no, or little info. (Insteon motion sensors). I've seen For those that do report battery state, I just have a trigger that fires whenever the battery reading is below 20%. That trigger sends an email to remind me to replace the battery.

Running Indigo 2023.2 on a 24" iMac M1), OS X 14.4
Jeff

Posted on
Wed Oct 12, 2022 9:57 am
DaveL17 offline
User avatar
Posts: 6755
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Low Battery ?

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.

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

[My Plugins] - [My Forums]

Posted on
Wed Oct 12, 2022 10:14 am
SearchCz offline
Posts: 172
Joined: Sep 18, 2019

Re: Low Battery ?

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.


Sweet ... I'll give it a spin !

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests