- Code: Select all
import datetime
run_duration_seconds = 15
email_to = indigo.variables[blah].value # "email_address_alarms"
# ==============
cat_feeder = indigo.devices[1693226210] # "Cat Feeder"
date_stamp = datetime.datetime.now()
# set time of this event
event_date_cat_feeder = indigo.variables[blah]
indigo.variable.updateValue(event_date_cat_feeder, str(date_stamp))
# turn on cat feeder for n seconds
indigo.device.turnOn(cat_feeder, duration=run_duration_seconds)
email_subject = "[indigo] cat feeder food delivery"
email_body = '\n'
email_body += 'feed date: %s\n' % date_stamp.strftime('%Y-%m-%d, %H:%M:%S')
email_body += 'feeder run time: %s seconds\n' % run_duration_seconds
# add this body copy to the end of the email
feed_detail = """notes
calories needed per day: 190
calories from Gourmet Chicken wet food: 90-94
Blue Wilderness
Wilderness Weight Control, Chicken Recipe(grain free, gold bag)
3441 kcal/kg
3.341 cals per gram
Normal day: 2 feedings, 12-13 gr
Vacation day: 4 feedings, 12-13 gr
Seconds to drop ~12 gr, 24-25 sec
(.41 of a minute runtime via Indigo)
tests
24-25 sec
8, 15, 10, 13, 14, 10
"""
email_body += '\n'
email_body += feed_detail
# send the email alert
indigo.server.sendEmailTo(email_to, subject=email_subject, body=email_body)
That generates an email notification like this
- Code: Select all
feed date: 2021-03-04, 15:20:00
feeder run time: 15 seconds
notes
calories needed per day: 190
calories from Gourmet Chicken wet food: 90-94
Blue Wilderness
Wilderness Weight Control, Chicken Recipe(grain free, gold bag)
3441 kcal/kg
3.341 cals per gram
Normal day: 2 feedings, 12-13 gr
Vacation day: 4 feedings, 12-13 gr
Seconds to drop ~12 gr, 24-25 sec
(.41 of a minute runtime via Indigo)
tests
24-25 sec
8, 15, 10, 13, 14, 10
The entire "note" section of the email is indented by a 2 spaces, which is not intended or desired.
Any python guru know why this is happening?