Saturday, June 22, 2013

Python Coding Mostly Done

I spent all day working on the python code and made some great progress.  First, I went through the entire email module and got everything working the way I want it to.  The features of the email module are:

  • send an email to one or more email addresses including to, cc, and bcc
  • the email addresses can be sent to the function in either a string or list variable and it will convert them to the correct formats for the header and for SMTP
  • add the correct date to the header with UTC offset 
  • created a new function to determine the UTC offset in hours.  So, the date and time in the email should be correct no matter what time zone the pi is in and regardless of daylight savings or not.
  • added a debug boolean to add more text to the body of the email when testing the email module
Adding the date to the email header turned out to be a lot more trouble than it sounds.  If you don't put a date on the header, pure SMTP email systems show the email as having no date.  Gmail shows the correct date.  After adding the date and time to the header, Gmail started showing the time as two hours in the future.  I had to add the UTC offset in hours and minutes to the date and then Gmail showed it correctly in the header.

Next, I worked on the main HESA program.  It sends power to the output pin for the powerswitch tail and to the water sensor.  It also looks for power coming in on the input pin.  When it senses power coming in, it shuts off the power to the powerswitch tail pin and to the water sensor pin.  Then, it sends an email to a mailing list that forwards on to my personal emails and my cell phone.

I think these are all of the basic features for the python program.

One Linux problem I am having is that my program will not import the modules that I had in another sub-folder.  I did set the PATH and PYTHONPATH variables but python is not using them for some reason.

No comments:

Post a Comment