contador = 0 try: for tweets in x.user_timeline(): contador += 1 if contador > 1: x.destroy_status(tweets.id) else: if fecha != tweets.created_at: fecha = tweets.created_at text = tweets.text if text == "Encender led 1" or text == "Encender led 2" or text == "Apagar led 1" or text == "Apagar led 2": comando.comando(text, app) if text == "Encender television" or text == "Apagar television" or text == "Subir programa" or text == "Bajar programa" or text == "Subir volumen" or text == "Bajar volumen": comando.arduino(text, app) if text == "Grafico": photo_path = '/var/www/html/img/grafico.png' x.update_with_media(photo_path) if text == "Leds": mensaje = "Led 1: " + linea[ 0] + "\n" + "Led 2: " + linea[2] x.update_status(mensaje) if text == "Temperatura": x.update_status(tem) if text == "Humedad": x.update_status(hum) time.sleep(10) except tweepy.TweepError:
import sys, comando comando.arduino(sys.argv[1], "(web)")
print "trl+C" print "Cerrando programa." sys.exit(0) signal.signal(signal.SIGINT, signal_handler) GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP) app = "(voz)" while 1: GPIO.wait_for_edge(23, GPIO.FALLING) os.system('./s2t.sh') speech = os.popen('cat text.txt').read() speech = speech.replace("\n", '') if speech == "temperatura": os.system( "tail -1 temperatura.txt | sed 's/C/ºC/g' | espeak -ves 2> /dev/null" ) elif speech == "humedad": os.system('tail -1 humedad.txt | espeak -ves 2> /dev/null') else: speech = speech.capitalize() if speech == "Encender led 1" or speech == "Encender led 2" or speech == "Apagar led 1" or speech == "Apagar led 2": comando.comando(speech, app) if speech == "Encender television" or speech == "Apagar television" or speech == "Subir programa" or speech == "Bajar programa" or speech == "Subir volumen" or speech == "Bajar volumen": comando.arduino(speech, app)
if index3 == 1: telegram.sendline('msg ' + contacto + ' ' + hum) if index3 == 2: telegram.sendline('send_photo ' + contacto + ' /var/www/html/img/grafico.png') if index3 == 4: telegram.sendline('msg ' + contacto + ' timeout-->') pass if index == 2: telegram.sendline('msg ' + contacto + ' -->') index4 = telegram.expect([ 'On', 'Off', 'Prog', 'prog', 'V', 'v', pexpect.EOF, pexpect.TIMEOUT ]) if index4 == 0: comando.arduino("Encender television", app) if index4 == 1: comando.arduino("Apagar television", app) if index4 == 2: comando.arduino("Subir programa", app) if index4 == 3: comando.arduino("Bajar programa", app) if index4 == 4: comando.arduino("Subir volumen", app) if index4 == 5: comando.arduino("Bajar volumen", app) if index4 == 7: telegram.sendline('msg ' + contacto + ' timeout-->') pass if index == 5:
import signal, sys, os, time, comando, getpass comandos = [] comandos.append("Encender led 1") comandos.append("Apagar led 1") comandos.append("Encender led 2") comandos.append("Apagar led 2") arduinos = [] arduinos.append("Encender television") arduinos.append("Apagar television") arduinos.append("Subir programa") arduinos.append("Bajar programa") arduinos.append("Subir volumen") arduinos.append("Bajar volumen") cmd = sys.argv[1].capitalize() for com in comandos: if cmd == com: comando.comando(cmd, sys.argv[2]) sys.exit() for com in arduinos: if cmd == com: comando.arduino(cmd, sys.argv[2]) sys.exit()