def testISO(): for iso in range(100, 900, 100): message = 'ISO:' + str(iso) print(message) camara.addText(message) camara.setIso(iso) camara.getImage()
def getImage(): global camera global time_between_picture global nightMode imageFile = None if camera == None: camera = camara.initCamera() camara.resolucionHD() utils.myLog('Waiting {}s for camera warn'.format(TIME2INITCAMERA)) time.sleep(TIME2INITCAMERA) if camera != None: if nightMode: utils.myLog('nigth Mode') camara.addDateNight() imageFile = camara.getImageNight() else: if datetime.datetime.now().hour >= 20 or datetime.datetime.now( ).hour < 7: camara.addDateNight() else: camara.addDate() imageFile = camara.getImage() if time_between_picture == 0 or time_between_picture > 10000: camera = camara.closeCamera() return imageFile
def testImage(): for i in range(1, 3): camara.addDate() camara.getImage() sleep(5)
# Test de cmara import camara from time import sleep camera = camara.initCamera() # creamos el objeto camara for i in range(1, 3): camara.getImage(camera) sleep(1)
def updateBot(bot): """Answer the message the user sent.""" global update_id global chat_id global camera #utils.myLog('Updating telegramBot') # Request updates after the last update_id for update in bot.get_updates(offset=update_id, timeout=10): update_id = update.update_id + 1 if update.message: # your bot can receive updates without messages # Proccess the incoming message comando = update.message.text # message text command_time = update.message.date # command date user = update.message.from_user #User full objetct chat_id = int(update.message.from_user.id) user_real_name = user.first_name #USER_REAL_NAME TelegramBase.chat_ids[user_real_name] = [command_time, chat_id] utils.myLog('Command: ' + comando + ' from user ' + str(user_real_name) + ' in chat id:' + str(chat_id) + ' at ' + str(command_time)) if comando == '/start': update.message.reply_text("Bienvenido al Bot de riego " + v, reply_markup=user_keyboard_markup) elif comando == 'hi': update.message.reply_text('Hello {}'.format( update.message.from_user.first_name), reply_markup=user_keyboard_markup) elif comando == '/info': answer = 'Datos @ ' + utils.getStrDateTime( ) + '\n==========================\n\n' + riego.getFullData() update.message.reply_text( answer, parse_mode=telegram.ParseMode.MARKDOWN, reply_markup=user_keyboard_markup) elif comando == '/help': bot.send_message(chat_id=chat_id, text=commandList, reply_markup=user_keyboard_markup) elif comando == '/users': sUsers = TelegramBase.getUsersInfo() TelegramBase.send_message(sUsers, chat_id) elif comando.startswith('/riego'): if comando == '/riegoOff': resultado = riego.riegoOff() elif comando == '/riegoOn': resultado = riego.riegoOn() elif comando == '/riegoPalet': resultado = riego.riegoOnSector(config.SectorPalet) elif comando == '/riegoMacetones': resultado = riego.riegoOnSector(config.SectorMacetones) elif comando == '/riegoMacetas': resultado = riego.riegoOnSector(config.SectorMacetas) else: utils.myLog('Comando: ' + comando + ' no reconocido') answer = 'Datos @ ' + utils.getStrDateTime( ) + '\n==========================\n\n' + riego.getFullData() update.message.reply_text( answer, parse_mode=telegram.ParseMode.MARKDOWN, reply_markup=user_keyboard_markup) elif comando == '/imagen': answer = 'No implementada ' + comando if camera != None: imageFile = camara.getImage(camera) answer = imageFile utils.myLog(answer) TelegramBase.send_picture(imageFile, chat_id) update.message.reply_text( answer, parse_mode=telegram.ParseMode.MARKDOWN, reply_markup=user_keyboard_markup) else: update.message.reply_text('echobot: ' + update.message.text, reply_markup=user_keyboard_markup)