3
3
# greenhouse.py
4
4
5
5
"""
6
- main script for greenhouse bot
7
- using telegram.ext as Python framework for Telegram Bot API
8
- https://core.telegram.org/api#bot-api
9
- original: author: Stefan Weigert http://www.stefan-weigert.de/php_loader/raspi.php
10
- adapted: author : Thomas Kaulke, [email protected]
6
+ main script for greenhouse bot
7
+ using telegram.ext as Python framework for Telegram Bot API
8
+ https://core.telegram.org/api#bot-api
9
+ original: author: Stefan Weigert http://www.stefan-weigert.de/php_loader/raspi.php
10
+ adapted : Thomas Kaulke, [email protected]
11
11
"""
12
-
13
12
from __future__ import absolute_import
14
13
import os
15
14
import time
@@ -91,12 +90,12 @@ def __start(bot, update):
91
90
return ConversationHandler .END
92
91
else :
93
92
display .show_run ()
94
- logging .info ('Bot started.' )
93
+ logging .info ('Bot started... ' )
95
94
__message_values (update )
96
95
__cam_on ()
97
96
display .show_ready ()
98
97
update .message .reply_text ('{0}{1}{2}' .format (
99
- lib .msg_welcome .format (update .message .from_user .first_name ), lib .line_break , lib .msg_choice ),
98
+ lib .msg_welcome .format (update .message .from_user .first_name ), lib .space , lib .msg_choice ),
100
99
parse_mode = ParseMode .MARKDOWN , reply_markup = markup1 )
101
100
logging .info ('Bot is using by: {0} - {1},{2}' .format (
102
101
str (user_id ), update .message .from_user .last_name , update .message .from_user .first_name ))
@@ -309,7 +308,9 @@ def __water_group(bot, update, group):
309
308
return
310
309
311
310
312
- """ humidity and temperature """
311
+ """
312
+ get humidity and temperature values
313
+ """
313
314
def __message_values (update ):
314
315
""" to avoid refresh intervals shorter than 3 seconds """
315
316
time .sleep (3 )
@@ -345,8 +346,9 @@ def __stop(bot, update):
345
346
return ConversationHandler .END
346
347
347
348
348
- """ [#39] Implement emergency stop"""
349
- """# emergency stop """
349
+ """
350
+ [#39] Implement emergency stop
351
+ """
350
352
@run_async
351
353
def __emergency_stop_handler (bot , update , chat_data ):
352
354
emergency = update .message .text
@@ -364,21 +366,26 @@ def __start_emergency_stop(bot, update):
364
366
return
365
367
366
368
367
- """ [#30] implement standby after given time without user activity """
369
+ """
370
+ [#30] implement standby
371
+ init after given time without user activity
372
+ """
368
373
def __start_standby_timer (bot , update ):
369
374
global timer_job
370
375
timer_job = jq .run_once (__job_stop_and_restart , conf .standby_timeout , context = update )
371
- logging .info ("Init standby timer of {0} seconds, added to queue." .format (conf .standby_timeout ))
376
+ logging .warning ("Init standby timer of {0} seconds, added to queue." .format (conf .standby_timeout ))
372
377
return
373
378
374
379
375
380
def __stop_standby_timer (bot , upadate ):
376
381
timer_job .schedule_removal ()
377
- logging .info ("Timer job removed from the queue." )
382
+ logging .warning ("Timer job removed from the queue." )
378
383
return
379
384
380
385
381
- """ job to stop and restart application """
386
+ """
387
+ job to stop and restart application
388
+ """
382
389
def __job_stop_and_restart (bot , job ):
383
390
logging .warning ("Job: Stop and restart called!" )
384
391
stop_and_restart .stop_and_restart (job .context )
0 commit comments