diff --git a/bot/conf/greenhouse_config.py b/bot/conf/greenhouse_config.py index 5fa7364..11c9186 100644 --- a/bot/conf/greenhouse_config.py +++ b/bot/conf/greenhouse_config.py @@ -31,8 +31,8 @@ # keyboard configs -kb1 = [[lib.group1[1], lib.group1[2], lib.group1[3], lib.group3[1]], - [lib.group3[2], lib.group2[1], lib.group2[2], lib.group2[3]], +kb1 = [[lib.channel_1, lib.channel_2, lib.channel_3, lib.channel_4], + [lib.channel_5, lib.channel_6, lib.channel_7, lib.channel_8], [lib.grouping], [lib.stop_bot, lib.live_stream, lib.reload] ] @@ -53,20 +53,17 @@ # Raspi core temperature core_temp_format = '{0}{1}{4}{2}{3}°C' -# def board pins/channels, refer hardware/raspi_gpio.info -RELAIS_01 = 29 -RELAIS_02 = 31 -RELAIS_03 = 33 -RELAIS_04 = 35 -RELAIS_05 = 37 -RELAIS_06 = 36 -RELAIS_07 = 38 -RELAIS_08 = 40 - -GROUP_ALL = (RELAIS_01, RELAIS_02, RELAIS_03, RELAIS_04, RELAIS_05, RELAIS_06, RELAIS_07, RELAIS_08) -GROUP_01 = (RELAIS_01, RELAIS_02, RELAIS_03) -GROUP_02 = (RELAIS_06, RELAIS_07, RELAIS_08) -GROUP_03 = (RELAIS_04, RELAIS_05) +# board pins of relays, refer hardware/raspi_gpio.info +RELAY_01 = 29 +RELAY_02 = 31 +RELAY_03 = 33 +RELAY_04 = 35 +RELAY_05 = 37 +RELAY_06 = 36 +RELAY_07 = 38 +RELAY_08 = 40 + +ALL = (RELAY_01, RELAY_02, RELAY_03, RELAY_04, RELAY_05, RELAY_06, RELAY_07, RELAY_08) # live stream address live = access.live diff --git a/bot/conf/lib_english.py b/bot/conf/lib_english.py index 5d045e4..81d6c00 100644 --- a/bot/conf/lib_english.py +++ b/bot/conf/lib_english.py @@ -31,9 +31,15 @@ btn_finished = 'Finished' btn_cancel = cancel reload = 'Reload' -group1 = ('Channel 1 to 3', 'Channel 1', 'Channel 2', 'Channel 3') -group2 = ('Channel 6 to 8', 'Channel 6', 'Channel 7', 'Channel 8') -group3 = ('Channel 4 and 5', 'Channel 4', 'Channel 5') + +channel_1 = 'Channel 1' +channel_2 = 'Channel 2' +channel_3 = 'Channel 3' +channel_4 = 'Channel 4' +channel_5 = 'Channel 5' +channel_6 = 'Channel 6' +channel_7 = 'Channel 7' +channel_8 = 'Channel 8' temp = 'Temperature' hum = 'Humidity' diff --git a/bot/conf/lib_german.py b/bot/conf/lib_german.py index ef5df0d..8f5704b 100644 --- a/bot/conf/lib_german.py +++ b/bot/conf/lib_german.py @@ -33,9 +33,14 @@ btn_finished = 'Fertig' btn_cancel = cancel -group1 = ('Kanal 1 bis 3', 'Kanal 1', 'Kanal 2', 'Kanal 3') -group2 = ('Kanal 6 bis 8', 'Kanal 6', 'Kanal 7', 'Kanal 8') -group3 = ('Kanal 4 und 5', 'Kanal 4', 'Kanal 5') +channel_1 = 'Kanal 1' +channel_2 = 'Kanal 2' +channel_3 = 'Kanal 3' +channel_4 = 'Kanal 4' +channel_5 = 'Kanal 5' +channel_6 = 'Kanal 6' +channel_7 = 'Kanal 7' +channel_8 = 'Kanal 8' temp = 'Temperatur' hum = 'Luftfeuchtigkeit' diff --git a/bot/ext_greenhouse.py b/bot/ext_greenhouse.py index 6b6da05..173cbd4 100644 --- a/bot/ext_greenhouse.py +++ b/bot/ext_greenhouse.py @@ -22,7 +22,7 @@ import peripherals.monitor as monitor logging = log.get_logger() -thread = threading.Thread(target=monitor.main, name='ext bot temperature monitoring') +thread = threading.Thread(target=monitor.main, name='ExtendedBot temperature monitoring') thread.start() pins_state = False @@ -30,20 +30,11 @@ markdown = "-d parse_mode='Markdown'" no_parse_mode = conf.lib.empty -relais01 = conf.RELAIS_01 -relais02 = conf.RELAIS_02 -relais03 = conf.RELAIS_03 -relais04 = conf.RELAIS_04 -relais05 = conf.RELAIS_05 -relais06 = conf.RELAIS_06 -relais07 = conf.RELAIS_07 -relais08 = conf.RELAIS_08 - -group_all = (relais01, relais02, relais03, relais04, - relais05, relais06, relais07, relais08) -group_one = (relais01, relais02, relais03) -group_two = (relais06, relais07, relais08) -group_three = (relais04, relais05) +group_all = (conf.RELAY_01, conf.RELAY_02, conf.RELAY_03, conf.RELAY_04, + conf.RELAY_05, conf.RELAY_06, conf.RELAY_07, conf.RELAY_08) +group_one = (conf.RELAY_01, conf.RELAY_02, conf.RELAY_03) +group_two = (conf.RELAY_06, conf.RELAY_07, conf.RELAY_08) +group_three = (conf.RELAY_04, conf.RELAY_05) # water a group of targets diff --git a/bot/greenhouse.py b/bot/greenhouse.py index eb7ba7a..4df225d 100644 --- a/bot/greenhouse.py +++ b/bot/greenhouse.py @@ -27,21 +27,11 @@ from telegram.ext.dispatcher import run_async logger = logger.get_logger() -thread = threading.Thread(target=monitor.main, name='main bot temperature monitoring') +thread = threading.Thread(target=monitor.main, name='MainBot temperature monitoring') thread.start() -# used library lib = conf.lib - -# define pins -all_groups = conf.GROUP_ALL -group_one = conf.GROUP_01 -group_two = conf.GROUP_02 -group_three = conf.GROUP_03 - -# api and bot settings SELECTION, DURATION, GROUPING = range(3) -# LIST_OF_ADMINS = ['mock to test'] list_of_admins = conf.admins token = conf.token target = lib.empty @@ -49,21 +39,16 @@ user_id = lib.empty jq = None timer_job = None - -# keyboard config +selection = () markup1 = ReplyKeyboardMarkup(conf.kb1, resize_keyboard=True, one_time_keyboard=True) markup2 = ReplyKeyboardMarkup(conf.kb2, resize_keyboard=True, one_time_keyboard=True) markup3 = ReplyKeyboardMarkup(conf.kb3, resize_keyboard=True, one_time_keyboard=True) -# for grouping -selection = () - # Start info def __init_bot_set_pins(): - logger.info('Initialize bot, setup GPIO pins.') + logger.info('Initializing...') utils.set_pins() - logger.info('Switch all off at start.') __all_off() display.show_standby() return @@ -89,23 +74,22 @@ def __start(bot, update): if user_id not in list_of_admins: display.show_stop() - logger.info('Not allowed access by: {0} - {1},{2}'.format( + logger.warning('Not allowed access by: {0} - {1},{2}'.format( str(user_id), update.message.from_user.last_name, update.message.from_user.first_name)) - update.message.reply_text(lib.private_warning.format( - update.message.from_user.first_name, update.message.chat_id), parse_mode=ParseMode.MARKDOWN) + __reply(update, lib.private_warning.format(update.message.from_user.first_name, update.message.chat_id)) return ConversationHandler.END else: display.show_run() - logger.info('Bot started...') + logger.info('Started...') __message_values(update) __cam_on() display.show_ready() - update.message.reply_text('{0}{1}{2}'.format( - lib.msg_welcome.format(update.message.from_user.first_name), lib.space, lib.msg_choice), - parse_mode=ParseMode.MARKDOWN, reply_markup=markup1) - logger.info('Bot is using by: {0} - {1},{2}'.format( + __reply( + update, + '{0}{1}{2}'.format(lib.msg_welcome.format(update.message.from_user.first_name), lib.space, lib.msg_choice), + markup1) + logger.info('Bot usage: {0} - {1},{2}'.format( str(user_id), update.message.from_user.last_name, update.message.from_user.first_name)) - logger.info('Time unit is \'{0}\''.format(str(lib.time_units_name[lib.time_units_index]))) display.show_off() __start_standby_timer(bot, update) @@ -116,19 +100,16 @@ def __start(bot, update): def __selection(bot, update): global target target = update.message.text - __stop_standby_timer(bot, update) if target == str(lib.panic): - update.message.reply_text(lib.msg_panic, - parse_mode=ParseMode.MARKDOWN, reply_markup=ReplyKeyboardRemove()) - logger.info(lib.msg_panic) + logger.info('Panic mode called.') + __reply(update, lib.msg_panic, ReplyKeyboardRemove()) os.system(conf.run_extended_greenhouse + str(user_id)) elif target == str(lib.live_stream): logger.info('Live URL requested.') - update.message.reply_text(lib.msg_live.format(str(conf.live)), - parse_mode=ParseMode.MARKDOWN, reply_markup=markup1) + __reply(update, lib.msg_live.format(str(conf.live)), markup1) __start_standby_timer(bot, update) return SELECTION @@ -143,8 +124,7 @@ def __selection(bot, update): def __selected_target(bot, update, selected_target): - update.message.reply_text(lib.msg_duration.format(selected_target), - parse_mode=ParseMode.MARKDOWN, reply_markup=markup2) + __reply(update, lib.msg_duration.format(selected_target), markup2) logger.info('Selection: {0}'.format(str(selected_target))) __start_standby_timer(bot, update) return DURATION @@ -159,14 +139,17 @@ def __grouping(bot, update, chat_data): if not (btn_click == str(lib.btn_finished) or btn_click == str(lib.cancel)): if not selection.__contains__(int(btn_click)): + __stop_standby_timer(bot, update) selection += (int(btn_click),) bot.edit_message_text(text=lib.msg_grouping_selection.format(selection), chat_id=query.message.chat_id, message_id=query.message.message_id, parse_mode=ParseMode.MARKDOWN, reply_markup=reply_markup) + __start_standby_timer(bot, update) elif btn_click == str(lib.btn_finished) and len(selection) > 0: + __stop_standby_timer(bot, update) global target target = lib.grouping bot.edit_message_text(text=lib.msg_grouping_selection.format(selection), @@ -178,9 +161,11 @@ def __grouping(bot, update, chat_data): parse_mode=ParseMode.MARKDOWN, reply_markup=markup2) logger.info('Selected: {0} {1}'.format(str(target), str(selection))) + __start_standby_timer(bot, update) return DURATION elif btn_click == lib.cancel: + __stop_standby_timer(bot, update) selection = () bot.delete_message(chat_id=query.message.chat_id, message_id=query.message.message_id) @@ -188,25 +173,26 @@ def __grouping(bot, update, chat_data): chat_id=query.message.chat_id, parse_mode=ParseMode.MARKDOWN, reply_markup=markup1) + __start_standby_timer(bot, update) return SELECTION def __group_menu(bot, update): global selection selection = () - logger.info('Grouping mode called.') inline_keyboard = [ - [__get_btn(lib.group1[1], conf.RELAIS_01), __get_btn(lib.group1[2], conf.RELAIS_02), - __get_btn(lib.group1[3], conf.RELAIS_03), __get_btn(lib.group3[1], conf.RELAIS_04)], - [__get_btn(lib.group3[2], conf.RELAIS_05), __get_btn(lib.group2[1], conf.RELAIS_06), - __get_btn(lib.group2[2], conf.RELAIS_07), __get_btn(lib.group2[3], conf.RELAIS_08)], + [__get_btn(lib.channel_1, conf.RELAY_01), __get_btn(lib.channel_2, conf.RELAY_02), + __get_btn(lib.channel_3, conf.RELAY_03), __get_btn(lib.channel_4, conf.RELAY_04)], + [__get_btn(lib.channel_5, conf.RELAY_05), __get_btn(lib.channel_6, conf.RELAY_06), + __get_btn(lib.channel_7, conf.RELAY_07), __get_btn(lib.channel_8, conf.RELAY_08)], [InlineKeyboardButton(lib.btn_finished, callback_data=lib.btn_finished), InlineKeyboardButton(lib.btn_cancel, callback_data=lib.btn_cancel)] ] global reply_markup reply_markup = InlineKeyboardMarkup(inline_keyboard) - update.message.reply_text(lib.msg_grouping, reply_markup=reply_markup, parse_mode=ParseMode.MARKDOWN) + __reply(update, lib.msg_grouping, reply_markup) + logger.info('Grouping called.') return GROUPING @@ -222,104 +208,76 @@ def __duration(bot, update): g_duration_update = update water_time = update.message.text - __stop_standby_timer(bot, update) - if water_time == str(lib.cancel): - update.message.reply_text(lib.msg_new_choice, - parse_mode=ParseMode.MARKDOWN, reply_markup=markup1) + __reply(update, lib.msg_new_choice, markup1) logger.info(lib.msg_new_choice) elif water_time == str(lib.panic): - update.message.reply_text(lib.msg_panic, - parse_mode=ParseMode.MARKDOWN, reply_markup=ReplyKeyboardRemove()) + __reply(update, lib.msg_panic, ReplyKeyboardRemove()) logger.info(lib.msg_panic) os.system(conf.run_extended_greenhouse + str(user_id)) - elif target == str(lib.group1[1]): - """ starts separate thread """ + elif target == str(lib.channel_1): display.show_switch_channel_duration(1, int(water_time)) + __water(bot, update, conf.RELAY_01) - __water(bot, update, group_one[0]) - - elif target == str(lib.group1[2]): - """ starts separate thread """ + elif target == str(lib.channel_2): display.show_switch_channel_duration(2, int(water_time)) + __water(bot, update, conf.RELAY_02) - __water(bot, update, group_one[1]) - - elif target == str(lib.group1[3]): - """ starts separate thread """ + elif target == str(lib.channel_3): display.show_switch_channel_duration(3, int(water_time)) + __water(bot, update, conf.RELAY_03) - __water(bot, update, group_one[2]) + elif target == str(lib.channel_4): + display.show_switch_channel_duration(4, int(water_time)) + __water(bot, update, conf.RELAY_04) - elif target == str(lib.group2[1]): - """ starts separate thread """ - display.show_switch_channel_duration(6, int(water_time)) + elif target == str(lib.channel_5): + display.show_switch_channel_duration(5, int(water_time)) + __water(bot, update, conf.RELAY_05) - __water(bot, update, group_two[0]) + elif target == str(lib.channel_6): + display.show_switch_channel_duration(6, int(water_time)) + __water(bot, update, conf.RELAY_06) - elif target == str(lib.group2[2]): - """ starts separate thread """ + elif target == str(lib.channel_7): display.show_switch_channel_duration(7, int(water_time)) + __water(bot, update, conf.RELAY_07) - __water(bot, update, group_two[1]) - - elif target == str(lib.group2[3]): - """ starts separate thread """ + elif target == str(lib.channel_8): display.show_switch_channel_duration(8, int(water_time)) - - __water(bot, update, group_two[2]) - - elif target == str(lib.group3[1]): - """ starts separate thread """ - display.show_switch_channel_duration(4, int(water_time)) - - __water(bot, update, group_three[0]) - - elif target == str(lib.group3[2]): - """ starts separate thread """ - display.show_switch_channel_duration(5, int(water_time)) - - __water(bot, update, group_three[1]) + __water(bot, update, conf.RELAY_08) elif target == str(lib.grouping): - """ starts separate thread """ display.show_switch_group_duration(int(water_time)) - __water_group(bot, update, selection) else: - update.message.reply_text(lib.msg_choice, reply_markup=markup1) + __reply(update, lib.msg_choice, markup1) - __start_standby_timer(bot, update) return SELECTION # end: duration # watering targets def __all_off(): - logger.info('Switch all off.') - for channel in all_groups: - utils.switch_off(channel) + logger.info('All off.') + for relay in conf.ALL: + utils.switch_out_high(relay) return @run_async def __water(bot, update, channel): - logger.info('Duration: {0}'.format(water_time)) - logger.info('Toggle {0}'.format(str(channel))) __stop_standby_timer(bot, update) - update.message.reply_text(lib.water_on.format(target, water_time), - parse_mode=ParseMode.MARKDOWN, reply_markup=markup3) - - utils.switch_on(channel) + logger.info('Toggle {0} , Duration {1}'.format(str(channel), str(water_time))) + __reply(update, lib.water_on.format(target, water_time), markup3) + utils.switch_out_low(channel) time.sleep(int(water_time) * int(lib.time_conversion)) - utils.switch_off(channel) - - update.message.reply_text('{0}{1}{2}'.format( - __timestamp(), lib.water_off.format(target, water_time), lib.msg_new_choice), - parse_mode=ParseMode.MARKDOWN, reply_markup=markup1) + utils.switch_out_high(channel) + __reply(update, + '{0}{1}{2}'.format(__timestamp(), lib.water_off.format(target, water_time), lib.msg_new_choice), markup1) display.show_off() __start_standby_timer(bot, update) return @@ -327,20 +285,16 @@ def __water(bot, update, channel): @run_async def __water_group(bot, update, group): - logger.info('Duration: {0}'.format(water_time)) - logger.info('Toggle {0}'.format(str(group))) __stop_standby_timer(bot, update) - update.message.reply_text(lib.water_on.format(target, water_time), - parse_mode=ParseMode.MARKDOWN, reply_markup=markup3) - + logger.info('Toggle {0} , Duration {1}'.format(str(group), str(water_time))) + __reply(update, lib.water_on.format(target, water_time), markup3) for channel in group: - utils.switch_on(channel) + utils.switch_out_low(channel) time.sleep((int(water_time) * int(lib.time_conversion))) for channel in group: - utils.switch_off(channel) - update.message.reply_text('{0}{1}{2}'.format( - __timestamp(), lib.water_off.format(target, water_time), lib.msg_new_choice), - parse_mode=ParseMode.MARKDOWN, reply_markup=markup1) + utils.switch_out_high(channel) + __reply(update, + '{0}{1}{2}'.format(__timestamp(), lib.water_off.format(target, water_time), lib.msg_new_choice), markup1) display.show_off() __start_standby_timer(bot, update) return @@ -349,8 +303,8 @@ def __water_group(bot, update, group): # get humidity and temperature values def __message_values(update): - """ to avoid refresh intervals shorter than 3 seconds """ time.sleep(3) + """ avoid refresh intervals shorter than 3 seconds! """ dht.get_values() if dht.temperature == 0: temp = (lib.temp + lib.colon_space + '------') @@ -363,8 +317,7 @@ def __message_values(update): hum = (lib.hum + lib.colon_space + conf.hum_format).format(dht.humidity) core_temp = (lib.core + lib.colon_space + core.get_temperature()) - update.message.reply_text(lib.msg_temperature.format( - __start_time(), temp, hum, core_temp), parse_mode=ParseMode.MARKDOWN, reply_markup=markup1) + __reply(update, lib.msg_temperature.format(__start_time(), temp, hum, core_temp), markup1) return @@ -372,10 +325,10 @@ def __message_values(update): def __stop(bot, update): __all_off() __stop_standby_timer(bot, update) - logger.info('Bot stopped.') + logger.info('Stopped.') __cam_off() display.show_stop() - update.message.reply_text(lib.msg_stop, parse_mode=ParseMode.MARKDOWN, reply_markup=ReplyKeyboardRemove()) + __reply(update, lib.msg_stop, ReplyKeyboardRemove()) time.sleep(2) display.show_standby() return ConversationHandler.END @@ -393,18 +346,18 @@ def __emergency_stop_handler(bot, update, chat_data): def __start_emergency_stop(bot, update): + logger.warning("Initialize emergency stop immediately.") global emergency_job emergency_job = jq.run_once(__job_stop_and_restart, 0, context=update) - logger.info("Initialize emergency stop immediately.") return # end: emergency stop # [#30] implement standby init after given time without user activity def __start_standby_timer(bot, update): + logger.info("Init standby timer of {0} seconds, added to queue.".format(conf.standby_timeout)) global timer_job timer_job = jq.run_once(__job_stop_and_restart, conf.standby_timeout, context=update) - logger.info("Init standby timer of {0} seconds, added to queue.".format(conf.standby_timeout)) return @@ -428,9 +381,10 @@ def __error(bot, update, e): try: display.show_error() __cam_off() + __all_off() utils.GPIO.cleanup() except Exception: - logging.warning('Any error occurs!') + logger.warning('Any error occurs!') return ConversationHandler.END @@ -460,7 +414,16 @@ def __cam_off(): # release info def __message_release_info(bot, update): - update.message.reply_text('`' + utils.get_release_info() + '`', parse_mode=ParseMode.MARKDOWN) + __reply(update, '`' + utils.get_release_info() + '`') + return + + +# reply message +def __reply(update, text, markup=None): + if markup is None: + update.message.reply_text(text, parse_mode=ParseMode.MARKDOWN) + else: + update.message.reply_text(text, parse_mode=ParseMode.MARKDOWN, reply_markup=markup) return @@ -476,7 +439,7 @@ def main(): dp = updater.dispatcher - help_commandhandler = CommandHandler('help', __message_release_info) + help_handler = CommandHandler('help', __message_release_info) emergency_stop_handler = RegexHandler('^{0}$'.format(str(lib.emergency_stop)), __emergency_stop_handler, @@ -485,9 +448,8 @@ def main(): entry_points=[CommandHandler('start', __start)], states={ SELECTION: [RegexHandler('^({0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|{10})$'.format( - str(lib.group1[1]), str(lib.group1[2]), str(lib.group1[3]), - str(lib.group2[1]), str(lib.group2[2]), str(lib.group2[3]), - str(lib.group3[1]), str(lib.group3[2]), + str(lib.channel_1), str(lib.channel_2), str(lib.channel_3), str(lib.channel_4), + str(lib.channel_5), str(lib.channel_6), str(lib.channel_7), str(lib.channel_8), str(lib.panic), str(lib.live_stream), str(lib.reload)), __selection), @@ -508,16 +470,12 @@ def main(): per_user=True ) + dp.add_error_handler(__error) dp.add_handler(emergency_stop_handler) - - dp.add_handler(help_commandhandler) - + dp.add_handler(help_handler) dp.add_handler(ch) - dp.add_error_handler(__error) - updater.start_polling() - updater.idle() diff --git a/bot/peripherals/dht/dht.py b/bot/peripherals/dht/dht.py index 3be886c..06eccbd 100644 --- a/bot/peripherals/dht/dht.py +++ b/bot/peripherals/dht/dht.py @@ -20,13 +20,11 @@ def get_values(): global temperature global humidity - logging.info('Try to get temperature and humidity values.') + logging.info('Get temperature and humidity values.') humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) if humidity is not None and temperature is not None: - logging.info(('{0}{1}{2}{3}{4}{1}{5}'.format( - lib.temp, lib.colon_space, conf.temp_format, lib.space, lib.hum, conf.hum_format)) - .format(temperature, humidity)) + logging.info(('{0}{1}{2}'.format(conf.temp_format, lib.space, conf.hum_format)).format(temperature, humidity)) else: logging.warning('Failed to get temperature and humidity values. Set to \'0\'!') humidity = 0 diff --git a/bot/peripherals/monitor.py b/bot/peripherals/monitor.py index 215ad77..29c8389 100644 --- a/bot/peripherals/monitor.py +++ b/bot/peripherals/monitor.py @@ -14,7 +14,7 @@ logger = logger.get_logger() -message = 'Warning, you Greenhouse Raspi reaches a temperature over {}°C! Current temperature is about {}°C!' +message = 'Warning, your RaspberryPi reaches a temperature over {}°C! Current temperature is about {}°C!' def __calc_core_temp(): @@ -35,13 +35,10 @@ def __send_msg(msg, bot, chat): def __fan_control(temp): if temp >= temperature_max and int(utils.get_pin_state(fan_pin)) == 0: - logger.warning('Current core temperature: {}°C'.format(str(temp))) + logger.warning('Current core temperature: {0}°C {1}'.format(str(temp), "Heat dissipation: Fan on")) utils.switch_out_high(fan_pin) - logger.warning("Heat dissipation: Fan switched on") if temp <= temperature_min and int(utils.get_pin_state(fan_pin)) == 1: - logger.info('Core temperature: {}°C'.format(str(temp))) - utils.switch_out_low(fan_pin) - logger.info("Heat dissipation: Fan switched off") + logger.info('Core temperature: {0}°C {1}'.format(str(temp), "Heat dissipation: Fan off")) return diff --git a/bot/utils/utils.py b/bot/utils/utils.py index 3ee034d..d8eba99 100644 --- a/bot/utils/utils.py +++ b/bot/utils/utils.py @@ -19,7 +19,7 @@ # switch functions def switch_on(pin): - logger.info('switch relais on: ' + str(pin)) + logger.info('switch on: ' + str(pin)) GPIO.setup(pin, GPIO.OUT) GPIO.output(pin, GPIO.LOW) # os.system(run_gpio_check + str(pin)) @@ -27,7 +27,7 @@ def switch_on(pin): def switch_off(pin): - logger.info('switch relais off: ' + str(pin)) + logger.info('switch off: ' + str(pin)) GPIO.setup(pin, GPIO.OUT) GPIO.output(pin, GPIO.HIGH) # os.system(run_gpio_check + str(pin)) @@ -68,7 +68,7 @@ def get_pin_state(pin): def set_pins(): GPIO.setmode(GPIO.BOARD) logger.info('Set GPIO mode: GPIO.BOARD') - # to use GPIO instead board pin numbers, then please adapt pin definition + """ to use GPIO instead board pin numbers, then please adapt pin definition """ # GPIO.setmode(GPIO.BCM) # comment if warnings required GPIO.setwarnings(False)