cat food indention

Posted on
Thu Mar 04, 2021 3:44 pm
WagnerOne offline
Posts: 150
Joined: Jun 12, 2009
Location: Chicago, IL

cat food indention

I have the following scheduled action

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?

Posted on
Thu Mar 04, 2021 4:17 pm
FlyingDiver offline
User avatar
Posts: 7190
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: cat food indention

I don't think it's a Python issue. I think it must be the email sender or possibly client. You can see that the string created is correct.

joe

Code: Select all
Python 2.7.16 (default, Dec 21 2020, 23:00:36)
[GCC Apple LLVM 12.0.0 (clang-1200.0.30.4) [+internal-os, ptrauth-isa=sign+stri on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 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
... """
>>> feed_detail
'notes\n\ncalories needed per day: 190\n\ncalories from Gourmet Chicken wet food: 90-94\n\nBlue Wilderness\nWilderness Weight Control, Chicken Recipe(grain free, gold bag)\n\n3441 kcal/kg\n3.341 cals per gram\n\nNormal day: 2 feedings, 12-13 gr\nVacation day: 4 feedings, 12-13 gr\n\nSeconds to drop ~12 gr, 24-25 sec\n(.41 of a minute runtime via Indigo)\n\ntests\n\n24-25 sec\n8, 15, 10, 13, 14, 10\n'
>>>

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Mar 04, 2021 4:57 pm
WagnerOne offline
Posts: 150
Joined: Jun 12, 2009
Location: Chicago, IL

Re: cat food indention

Thanks for looking at this.

I send a lot of email using this same method via Python in Indigo and this is the first time I saw this.

It's only when using the """whatever""" construct.

I didn't see an equally convenient way to have a "here doc" type of structure in Python, but I can look some more.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest

cron