thanks for the quick response
I made an other action group just to double check sending mail
it is working fine
I know I have at least one insteon with low battery as it keeps smiling me. no idea which one
Dual wrote:I have already modified your code and scheduled it to send one email with the state of all batteries (i.e. even if 100%).
## Check devices battery levels
# Set the target battery level and the email address to notify
TargetLevel=25
EmailAddress="example@example.com"
LowBatteryCount=0
# Shortcut the log function
def log(msg):
indigo.server.log(msg, type="Low Battery Notification Script")
log ("Starting check")
emailBody="The following devices have low batteries: \r\n\r\n"
# Loop round all the devices
for dev in indigo.devices.itervalues():
if (dev.batteryLevel != None) and (dev.enabled):
log (emailBody)
if (dev.batteryLevel < TargetLevel):
log ("Device below threshold, sending email")
emailBody=emailBody+"\t"+(u'%s (battery level: %s' % (dev.name, dev.batteryLevel)) + "%)\r\n"
LowBatteryCount+=1
emailBody=emailBody+"\r\n-End-"
if LowBatteryCount >0:
indigo.server.sendEmailTo(EmailAddress, subject="Indigo battery alert", body=emailBody)
log ("Finished check")
captcurrent wrote:This is exactly what I want
But as usual. I just don't seem to get it
To test I added an action group with the following script
- Code: Select all
targetLevel = 100
emailAddress = "reallyme@somewhere.com"
for dev in indigo.devices.itervalues():
if dev.batteryLevel:
if dev.batteryLevel < targetLevel:
emailBody = (u'%s battery level: %s' % (dev.name, dev.batteryLevel))
indigo.server.sendEmailTo(emailAddress, subject="Indigo Low Battery Alert", body=emailBody)
I added a schedule. and figured with 100 thresh hold I would get a good start position
Log says its is running my no email or errors in log
It has to be something simple I am not doing . Thoughts or suggestions?
if dev.batteryLevel < targetLevel:
if dev.batteryLevel <= targetLevel:
jaknudsen wrote:I would be really grateful if you could share your modified script
emailAddress = "me@me.com"
emailBody="BATTERY UPDATE."
for dev in indigo.devices.itervalues():
if dev.batteryLevel:
emailBody = emailBody + "\n \n" + str(dev.batteryLevel) + " ... " + dev.name
indigo.server.sendEmailTo(emailAddress, subject="BATTERY UPDATE", body=emailBody)
Users browsing this forum: No registered users and 4 guests