Skip to content

Commit

Permalink
Daily status can be omitted by setting daily_status to False in Email…
Browse files Browse the repository at this point in the history
… section
  • Loading branch information
SylvainGa committed Sep 25, 2024
1 parent 1e84aea commit c5e52cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions check_tesla_windows_mqtt.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ password:
# Recipient address that will receive the emails
to:

# Sends a daily status message at sunset
daily_status: True

[Timers]
# Frequency of the timer and watchdog threads in seconds. If it hasn't ran in that amount of time,
# the script will self destruct and expect the systemd service will auto relaunch it.
Expand Down
16 changes: 11 additions & 5 deletions check_tesla_windows_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ def on_timer():
if (g_debug & 3) > 1:
printWithTime("Tesla-Timer: Debug: It's night with " + str(tomorrow_sr - now_tz) + " until sunrise")
if g_night == False or g_retry == 10: # First time going in since the sun has set, check if we're parked with the windows down and if so, close them
sendEmail = True
if g_retry == 10: # If we got here because we timed out, reset it back to 0
g_retry = 0
g_night = True
Expand Down Expand Up @@ -600,11 +601,15 @@ def on_timer():
emailBody = "Windows were closed at sunset (" + current_time + ")"
emailSubject = "Tesla-Timer: " + emailBody

try:
sender = Emailer()
sender.sendmail(sendTo, emailSubject, emailBody)
except Exception as error:
printWithTime("Tesla-Timer: Unable to send email because of exception: " + type(error).__name__ + ")")
if sendDailyEmail == False:
sendEmail = False

if sendEmail:
try:
sender = Emailer()
sender.sendmail(sendTo, emailSubject, emailBody)
except Exception as error:
printWithTime("Tesla-Timer: Unable to send email because of exception: " + type(error).__name__ + ")")

printWithTime(emailSubject)

Expand Down Expand Up @@ -732,6 +737,7 @@ def on_timer():
tessie_token = Config.get('Tesla', 'tessie_token')
wake_at_start = int(Config.get('Tesla', 'wake_at_start'))
sendTo = Config.get('Email', 'to')
sendDailyEmail = Config.getboolean('Email', 'daily_status')
station_latitude = float(Config.get('MQTT', 'latitude'))
station_longitude = float(Config.get('MQTT', 'longitude'))

Expand Down

0 comments on commit c5e52cc

Please sign in to comment.