Skip to content

Commit 7c9dc8d

Browse files
authored
Merge pull request #2159 from adafruit/pi_alert_update
updating circuitpython code
2 parents 206ad31 + 4e34ff1 commit 7c9dc8d

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Pi_In_Stock_Notifier/code.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@
115115
if timestamp.startswith(current_time.text[0 : 10]):
116116
print("match")
117117
# grabs the hour of the tweet timestamp
118-
tweet_hour = int(timestamp[11:12])
118+
tweet_hour = int(timestamp[11:13])
119119
print(tweet_hour)
120120
# grabs the current hour
121-
current_hour = int(current_time.text[11:12])
121+
current_hour = int(current_time.text[11:13])
122122
print(current_hour)
123123
# if it's been less than an hour since the tweet...
124-
if abs(current_hour - tweet_hour) < 2:
124+
if abs(current_hour - tweet_hour) < 1:
125125
print("in the last hour")
126126
# displays tweet text and time on screen
127127
text_area.text = "\n".join(wrap_text_to_lines(stock_check, 21))
@@ -131,13 +131,15 @@
131131
alarm_out.value = True
132132

133133
else:
134-
pass
135-
# if the tweet wasn't today
136-
else:
137-
# if it's not new, then the wait continues
138-
no_tweet_text = ("No stock in last hour :( Last stock: %s" % (timestamp))
139-
text_area.text = "\n".join(wrap_text_to_lines(no_tweet_text, 21))
140-
print("no new in stock notifications :(")
141-
134+
# if it's not new, then the wait continues
135+
no_tweet_text = ("No stock in last hour :( Last stock: %s" % (timestamp))
136+
text_area.text = "\n".join(wrap_text_to_lines(no_tweet_text, 21))
137+
print("no new in stock notifications :(")
142138
# updates tweet ID
143139
last_value = value
140+
# if the tweet wasn't today
141+
else:
142+
# if it's not new, then the wait continues
143+
no_tweet_text = ("No stock in last hour :( Last stock: %s" % (timestamp))
144+
text_area.text = "\n".join(wrap_text_to_lines(no_tweet_text, 21))
145+
print("no new in stock notifications :(")

0 commit comments

Comments
 (0)