Example #1
0
	def run_action(self,option,text,conf,a):
		conf.read()
		if option=='0': time.sleep(float(text))
		if option=='1':
			if text:
				text=text.split(' ')
				subprocess.Popen(text)		
		if option=='2': 
			subprocess.Popen(['sudo', 'reboot'])
		if option=='3': 
			subprocess.Popen(['sudo', 'shutdown', '-h', 'now'])
		if option=='4': 
			subprocess.Popen(['pkill', '-9', 'kplex'])
		if option=='5':
			subprocess.call(['pkill', '-9', 'kplex'])
			subprocess.Popen('kplex')
		if option=='6': 
			subprocess.Popen(["pkill", '-9', "node"])
		if option=='7':
			subprocess.call(["pkill", '-9', "node"]) 
			subprocess.Popen(self.home+'/.config/signalk-server-node/bin/nmea-from-10110', cwd=self.home+'/.config/signalk-server-node') 
		if option=='8':
			wlan=conf.get('WIFI', 'device')
			passw2=conf.get('WIFI', 'password')
			ssid2=conf.get('WIFI', 'ssid')
			subprocess.Popen(['sudo', 'python', self.currentpath+'/wifi_server.py', '0', wlan, passw2, ssid2])
			conf.set('WIFI', 'enable', '0')
		if option=='9':
			wlan=conf.get('WIFI', 'device')
			passw2=conf.get('WIFI', 'password')
			ssid2=conf.get('WIFI', 'ssid')
			subprocess.Popen(['sudo', 'python', self.currentpath+'/wifi_server.py', '1', wlan, passw2, ssid2])
			conf.set('WIFI', 'enable', '1')
		if option=='10':
			subprocess.Popen(['pkill', '-9', 'aisdecoder'])
			subprocess.Popen(['pkill', '-9', 'rtl_fm'])
			conf.set('AIS-SDR', 'enable', '0')
		if option=='11':
			gain=conf.get('AIS-SDR', 'gain')
			ppm=conf.get('AIS-SDR', 'ppm')
			channel=conf.get('AIS-SDR', 'channel')
			subprocess.call(['pkill', '-9', 'aisdecoder'])
			subprocess.call(['pkill', '-9', 'rtl_fm'])
			frecuency='161975000'
			if channel=='b': frecuency='162025000'
			rtl_fm=subprocess.Popen(['rtl_fm', '-f', frecuency, '-g', gain, '-p', ppm, '-s', '48k'], stdout = subprocess.PIPE)
			aisdecoder=subprocess.Popen(['aisdecoder', '-h', '127.0.0.1', '-p', '10110', '-a', 'file', '-c', 'mono', '-d', '-f', '/dev/stdin'], stdin = rtl_fm.stdout)
			conf.set('AIS-SDR', 'enable', '1')
		if option=='12':
			now = time.strftime("%H:%M:%S")
			tweetStr = now+' '+text
			send_data=eval(conf.get('TWITTER', 'send_data'))
			for ii in send_data:
				timestamp=eval('a.'+a.DataList[ii]+'[4]')
				if timestamp:
					now=time.time()
					age=now-timestamp
					if age < 20:
						data=''
						value=''
						unit=''
						data=eval('a.'+a.DataList[ii]+'[1]')
						value=eval('a.'+a.DataList[ii]+'[2]')
						unit=eval('a.'+a.DataList[ii]+'[3]')
						if unit: tweetStr+= ' '+data+':'+str(value)+str(unit)
						else: tweetStr+= ' '+data+':'+str(value)+' '
			apiKey = conf.get('TWITTER', 'apiKey')
			apiSecret = conf.get('TWITTER', 'apiSecret')
			accessToken = conf.get('TWITTER', 'accessToken')
			accessTokenSecret = conf.get('TWITTER', 'accessTokenSecret')
			if len(tweetStr)>140: tweetStr=tweetStr[0:140]
			try:
				msg=TwitterBot(apiKey,apiSecret,accessToken,accessTokenSecret)
				msg.send(tweetStr)
			except Exception,e: print str(e)
		if option=='13':
			subject = text
			body = ''
			for ii in a.DataList:
				timestamp=eval('a.'+ii+'[4]')
				if timestamp:
					now=time.time()
					age=now-timestamp
					if age < 20:
						data=''
						value=''
						unit=''
						data=eval('a.'+ii+'[0]')
						value=eval('a.'+ii+'[2]')
						unit=eval('a.'+ii+'[3]')
						if unit: body += data+': '+str(value)+' '+str(unit)+'\n'
						else: body+= data+': '+str(value)+'\n'
			GMAIL_USERNAME = conf.get('GMAIL', 'gmail')
			GMAIL_PASSWORD = conf.get('GMAIL', 'password')
			recipient = conf.get('GMAIL', 'recipient')
			if not body: body = time.strftime("%H:%M:%S")+' '+subject
			try:
				msg=GmailBot(GMAIL_USERNAME,GMAIL_PASSWORD,recipient)
				msg.send(subject,body)
			except Exception,e: print str(e)
		if option=='14':
			subprocess.Popen(['mpg123',text])
		if option=='15':
			subprocess.Popen(['pkill', '-9', 'mpg123'])
		if option=='16':
			subprocess.Popen(['python', self.currentpath+'/message.py', text, conf.get('GENERAL','lang')])
		if option=='17':
			subprocess.Popen(['pkill', '-f', 'message.py'])
		if option=='18':
			tmp=''
			data=conf.get('ACTIONS', 'triggers')
			triggers=data.split('||')
			triggers.pop()
			for index,item in enumerate(triggers):
				ii=item.split(',')
				triggers[index]=ii
			for index,item in enumerate(triggers):
				tmp +='1,'
				tmp +=triggers[index][1]+','+triggers[index][2]+','+triggers[index][3]+'||'
			conf.set('ACTIONS', 'triggers', tmp)
			return 'read'
		if option=='19':
			subprocess.Popen(['python', self.currentpath+'/ctrl_actions.py', '0'])
		if option=='20':
			if conf.get('OUTPUT1', 'enable')=='1':
				channel=int(conf.get('OUTPUT1', 'gpio'))
				GPIO.output(channel, 1)
		if option=='21':
			if conf.get('OUTPUT1', 'enable')=='1':
				channel=int(conf.get('OUTPUT1', 'gpio'))
				GPIO.output(channel, 0)
		if option=='22':
			if conf.get('OUTPUT2', 'enable')=='1':
				channel=int(conf.get('OUTPUT2', 'gpio'))
				GPIO.output(channel, 1)
		if option=='23':
			if conf.get('OUTPUT2', 'enable')=='1':
				channel=int(conf.get('OUTPUT2', 'gpio'))
				GPIO.output(channel, 0)
		if option=='24':
			if conf.get('OUTPUT3', 'enable')=='1':
				channel=int(conf.get('OUTPUT3', 'gpio'))
				GPIO.output(channel, 1)
		if option=='25':
			if conf.get('OUTPUT3', 'enable')=='1':
				channel=int(conf.get('OUTPUT3', 'gpio'))
				GPIO.output(channel, 0)
		if option=='26':
			if conf.get('OUTPUT4', 'enable')=='1':
				channel=int(conf.get('OUTPUT4', 'gpio'))
				GPIO.output(channel, 1)
		if option=='27':
			if conf.get('OUTPUT4', 'enable')=='1':
				channel=int(conf.get('OUTPUT4', 'gpio'))
				GPIO.output(channel, 0)
Example #2
0
	def run_action(self,option,text,conf,a):
		if text:
			text=a.getVariablesValue(text)
		conf.read()
		if option=='ACT1': time.sleep(float(text))
		if option=='ACT2':
			if text:
				try:
					text=text.split(' ')
					subprocess.Popen(text)
				except Exception,e: print str(e)	
		if option=='ACT3': 
			subprocess.Popen(['sudo', 'reboot'])
		if option=='ACT4': 
			subprocess.Popen(['sudo', 'shutdown', '-h', 'now'])
		if option=='ACT5': 
			subprocess.Popen(['pkill', '-9', 'kplex'])
		if option=='ACT6':
			subprocess.call(['pkill', '-9', 'kplex'])
			subprocess.Popen('kplex')
		if option=='ACT7': 
			subprocess.Popen(["pkill", '-9', "node"])
		if option=='ACT8':
			subprocess.call(["pkill", '-9', "node"]) 
			subprocess.Popen(self.home+'/.config/signalk-server-node/bin/openplotter', cwd=self.home+'/.config/signalk-server-node') 
		if option=='ACT9':
			wlan=conf.get('WIFI', 'device')
			passw2=conf.get('WIFI', 'password')
			ssid2=conf.get('WIFI', 'ssid')
			subprocess.Popen(['sudo', 'python', self.currentpath+'/wifi_server.py', '0', wlan, passw2, ssid2])
			conf.set('WIFI', 'enable', '0')
		if option=='ACT10':
			wlan=conf.get('WIFI', 'device')
			passw2=conf.get('WIFI', 'password')
			ssid2=conf.get('WIFI', 'ssid')
			subprocess.Popen(['sudo', 'python', self.currentpath+'/wifi_server.py', '1', wlan, passw2, ssid2])
			conf.set('WIFI', 'enable', '1')
		if option=='ACT11':
			subprocess.Popen(['pkill', '-9', 'aisdecoder'])
			subprocess.Popen(['pkill', '-9', 'rtl_fm'])
			conf.set('AIS-SDR', 'enable', '0')
		if option=='ACT12':
			gain=conf.get('AIS-SDR', 'gain')
			ppm=conf.get('AIS-SDR', 'ppm')
			channel=conf.get('AIS-SDR', 'channel')
			subprocess.call(['pkill', '-9', 'aisdecoder'])
			subprocess.call(['pkill', '-9', 'rtl_fm'])
			frecuency='161975000'
			if channel=='b': frecuency='162025000'
			rtl_fm=subprocess.Popen(['rtl_fm', '-f', frecuency, '-g', gain, '-p', ppm, '-s', '48k'], stdout = subprocess.PIPE)
			aisdecoder=subprocess.Popen(['aisdecoder', '-h', '127.0.0.1', '-p', '10110', '-a', 'file', '-c', 'mono', '-d', '-f', '/dev/stdin'], stdin = rtl_fm.stdout)
			conf.set('AIS-SDR', 'enable', '1')
		if option=='ACT13':
			now = time.strftime("%H:%M:%S")
			tweetStr = now+' '+text
			apiKey = conf.get('TWITTER', 'apiKey')
			apiSecret = conf.get('TWITTER', 'apiSecret')
			accessToken = conf.get('TWITTER', 'accessToken')
			accessTokenSecret = conf.get('TWITTER', 'accessTokenSecret')
			if len(tweetStr)>140: tweetStr=tweetStr[0:140]
			try:
				msg=TwitterBot(apiKey,apiSecret,accessToken,accessTokenSecret)
				msg.send(tweetStr)
			except Exception,e: print str(e)
		if option=='ACT14':
			subject = text
			body = ''
			for ii in a.DataList:
				timestamp=ii[4]
				if timestamp:
					now=time.time()
					age=now-timestamp
					if age < 20:
						data=''
						value=''
						unit=''
						data=ii[0]
						value=ii[2]
						unit=ii[3]
						if unit: body += data+': '+str(value)+' '+str(unit)+'\n'
						else: body+= data+': '+str(value)+'\n'
			GMAIL_USERNAME = conf.get('GMAIL', 'gmail')
			GMAIL_PASSWORD = conf.get('GMAIL', 'password')
			recipient = conf.get('GMAIL', 'recipient')
			if not body: body = time.strftime("%H:%M:%S")+' '+subject
			try:
				msg=GmailBot(GMAIL_USERNAME,GMAIL_PASSWORD,recipient)
				msg.send(subject,body)
			except Exception,e: print str(e)
		if option=='ACT15':
			subprocess.Popen(['mpg123',text])
		if option=='ACT16':
			subprocess.Popen(['pkill', '-9', 'mpg123'])
		if option=='ACT17':
			subprocess.Popen(['python', self.currentpath+'/message.py', text, conf.get('GENERAL','lang')])
		if option=='ACT18':
			subprocess.Popen(['pkill', '-f', 'message.py'])
		if option=='ACT19':
			return 'read'
		if option=='ACT20':
			subprocess.Popen(['python', self.currentpath+'/ctrl_actions.py', '0'])
		if option[:4]=='HOUT':
				channel=self.out_list[self.getoutlistIndex(option[1:])][3]
				GPIO.output(channel, 1)
		if option[:4]=='LOUT':
				channel=self.out_list[self.getoutlistIndex(option[1:])][3]
				GPIO.output(channel, 0)
		if option=='ACT21':
			try:
				sm = gammu.StateMachine()
				sm.ReadConfig()
				sm.Init()
				message = {
					'Text': text, 
					'SMSC': {'Location': 1},
					'Number': conf.get('SMS','phone'),
				}
				sm.SendSMS(message)
			except Exception,e: print str(e)
		if option[:4]=='MQTT':
			topic=self.mqtt_list[self.getmqttlistIndex(option)][1]
			payload= text
			auth = {'username':conf.get('MQTT','username'), 'password':conf.get('MQTT','password')}
			publish.single(topic, payload=payload, hostname='127.0.0.1', port='1883', auth=auth)
			publish.single(topic, payload=payload, hostname=conf.get('MQTT','broker'), port=conf.get('MQTT','port'), auth=auth)
			
Example #3
0
     aisdecoder = subprocess.Popen([
         'aisdecoder', '-h', '127.0.0.1', '-p', '10110', '-a', 'file',
         '-c', 'mono', '-d', '-f', '/dev/stdin'
     ],
                                   stdin=rtl_fm.stdout)
     conf.set('AIS-SDR', 'enable', '1')
 if option == 'ACT13':
     now = time.strftime("%H:%M:%S")
     tweetStr = now + ' ' + text
     apiKey = conf.get('TWITTER', 'apiKey')
     apiSecret = conf.get('TWITTER', 'apiSecret')
     accessToken = conf.get('TWITTER', 'accessToken')
     accessTokenSecret = conf.get('TWITTER', 'accessTokenSecret')
     if len(tweetStr) > 140: tweetStr = tweetStr[0:140]
     try:
         msg = TwitterBot(apiKey, apiSecret, accessToken,
                          accessTokenSecret)
         msg.send(tweetStr)
     except Exception, e:
         print str(e)
 if option == 'ACT14':
     subject = text
     body = ''
     for ii in a.DataList:
         timestamp = ii[4]
         if timestamp:
             now = time.time()
             age = now - timestamp
             if age < 20:
                 data = ''
                 value = ''
                 unit = ''
Example #4
0
 def run_action(self, option, text, conf, extra):
     conf.read()
     if option == "0":
         return
     if option == "1":
         if text:
             text = text.split(" ")
             subprocess.Popen(text)
     if option == "2":
         subprocess.Popen(["sudo", "reboot"])
     if option == "3":
         subprocess.Popen(["sudo", "halt"])
     if option == "4":
         subprocess.Popen(["pkill", "-9", "kplex"])
     if option == "5":
         subprocess.call(["pkill", "-9", "kplex"])
         subprocess.Popen("kplex")
     if option == "6":
         subprocess.Popen(["pkill", "-9", "node"])
     if option == "7":
         subprocess.call(["pkill", "-9", "node"])
         subprocess.Popen(
             self.home + "/.config/signalk-server-node/bin/nmea-from-10110",
             cwd=self.home + "/.config/signalk-server-node",
         )
     if option == "8":
         wlan = conf.get("WIFI", "device")
         passw2 = conf.get("WIFI", "password")
         ssid2 = conf.get("WIFI", "ssid")
         subprocess.Popen(["sudo", "python", self.currentpath + "/wifi_server.py", "0", wlan, passw2, ssid2])
         conf.set("WIFI", "enable", "0")
     if option == "9":
         wlan = conf.get("WIFI", "device")
         passw2 = conf.get("WIFI", "password")
         ssid2 = conf.get("WIFI", "ssid")
         subprocess.Popen(["sudo", "python", self.currentpath + "/wifi_server.py", "1", wlan, passw2, ssid2])
         conf.set("WIFI", "enable", "1")
     if option == "10":
         subprocess.Popen(["pkill", "-9", "aisdecoder"])
         subprocess.Popen(["pkill", "-9", "rtl_fm"])
         conf.set("AIS-SDR", "enable", "0")
     if option == "11":
         gain = conf.get("AIS-SDR", "gain")
         ppm = conf.get("AIS-SDR", "ppm")
         channel = conf.get("AIS-SDR", "channel")
         subprocess.call(["pkill", "-9", "aisdecoder"])
         subprocess.call(["pkill", "-9", "rtl_fm"])
         frecuency = "161975000"
         if channel == "b":
             frecuency = "162025000"
         rtl_fm = subprocess.Popen(
             ["rtl_fm", "-f", frecuency, "-g", gain, "-p", ppm, "-s", "48k"], stdout=subprocess.PIPE
         )
         aisdecoder = subprocess.Popen(
             ["aisdecoder", "-h", "127.0.0.1", "-p", "10110", "-a", "file", "-c", "mono", "-d", "-f", "/dev/stdin"],
             stdin=rtl_fm.stdout,
         )
         conf.set("AIS-SDR", "enable", "1")
     if option == "12":
         conf.set("TWITTER", "enable", "1")
     if option == "13":
         conf.set("TWITTER", "enable", "0")
     if option == "14":
         apiKey = conf.get("TWITTER", "apiKey")
         apiSecret = conf.get("TWITTER", "apiSecret")
         accessToken = conf.get("TWITTER", "accessToken")
         accessTokenSecret = conf.get("TWITTER", "accessTokenSecret")
         now = time.strftime("%H:%M:%S")
         tweetStr = text
         if tweetStr:
             tweetStr = now + " " + tweetStr
             if len(tweetStr) > 140:
                 tweetStr = tweetStr[0:140]
             try:
                 msg = TwitterBot(apiKey, apiSecret, accessToken, accessTokenSecret)
                 msg.send(tweetStr)
             except Exception, e:
                 print str(e)
Example #5
0
	def run_action(self,option,text,conf,a):
		conf.read()
		if option=='ACT1': time.sleep(float(text))
		if option=='ACT2':
			if text:
				try:
					text=text.split(' ')
					subprocess.Popen(text)
				except Exception,e: print str(e)	
		if option=='ACT3': 
			subprocess.Popen(['sudo', 'reboot'])
		if option=='ACT4': 
			subprocess.Popen(['sudo', 'shutdown', '-h', 'now'])
		if option=='ACT5': 
			subprocess.Popen(['pkill', '-9', 'kplex'])
		if option=='ACT6':
			subprocess.call(['pkill', '-9', 'kplex'])
			subprocess.Popen('kplex')
		if option=='ACT7': 
			subprocess.Popen(["pkill", '-9', "node"])
		if option=='ACT8':
			subprocess.call(["pkill", '-9', "node"]) 
			subprocess.Popen(self.home+'/.config/signalk-server-node/bin/openplotter', cwd=self.home+'/.config/signalk-server-node') 
		if option=='ACT9':
			wlan=conf.get('WIFI', 'device')
			passw2=conf.get('WIFI', 'password')
			ssid2=conf.get('WIFI', 'ssid')
			subprocess.Popen(['sudo', 'python', self.currentpath+'/wifi_server.py', '0', wlan, passw2, ssid2])
			conf.set('WIFI', 'enable', '0')
		if option=='ACT10':
			wlan=conf.get('WIFI', 'device')
			passw2=conf.get('WIFI', 'password')
			ssid2=conf.get('WIFI', 'ssid')
			subprocess.Popen(['sudo', 'python', self.currentpath+'/wifi_server.py', '1', wlan, passw2, ssid2])
			conf.set('WIFI', 'enable', '1')
		if option=='ACT11':
			subprocess.Popen(['pkill', '-9', 'aisdecoder'])
			subprocess.Popen(['pkill', '-9', 'rtl_fm'])
			conf.set('AIS-SDR', 'enable', '0')
		if option=='ACT12':
			gain=conf.get('AIS-SDR', 'gain')
			ppm=conf.get('AIS-SDR', 'ppm')
			channel=conf.get('AIS-SDR', 'channel')
			subprocess.call(['pkill', '-9', 'aisdecoder'])
			subprocess.call(['pkill', '-9', 'rtl_fm'])
			frecuency='161975000'
			if channel=='b': frecuency='162025000'
			rtl_fm=subprocess.Popen(['rtl_fm', '-f', frecuency, '-g', gain, '-p', ppm, '-s', '48k'], stdout = subprocess.PIPE)
			aisdecoder=subprocess.Popen(['aisdecoder', '-h', '127.0.0.1', '-p', '10110', '-a', 'file', '-c', 'mono', '-d', '-f', '/dev/stdin'], stdin = rtl_fm.stdout)
			conf.set('AIS-SDR', 'enable', '1')
		if option=='ACT13':
			now = time.strftime("%H:%M:%S")
			tweetStr = now+' '+text
			send_data=eval(conf.get('TWITTER', 'send_data'))
			for ii in send_data:
				for index,item in enumerate(a.DataList):
					if ii==item[9]:
						timestamp=item[4]
						if timestamp:
							now=time.time()
							age=now-timestamp
							if age < 20:
								data=''
								value=''
								unit=''
								data=item[1]
								value=item[2]
								unit=item[3]
								if unit: tweetStr+= ' '+data+':'+str(value)+str(unit)
								else: tweetStr+= ' '+data+':'+str(value)+' '
						timestamp=''
			apiKey = conf.get('TWITTER', 'apiKey')
			apiSecret = conf.get('TWITTER', 'apiSecret')
			accessToken = conf.get('TWITTER', 'accessToken')
			accessTokenSecret = conf.get('TWITTER', 'accessTokenSecret')
			if len(tweetStr)>140: tweetStr=tweetStr[0:140]
			try:
				msg=TwitterBot(apiKey,apiSecret,accessToken,accessTokenSecret)
				msg.send(tweetStr)
			except Exception,e: print str(e)
		if option=='ACT14':
			subject = text
			body = ''
			for ii in a.DataList:
				timestamp=ii[4]
				if timestamp:
					now=time.time()
					age=now-timestamp
					if age < 20:
						data=''
						value=''
						unit=''
						data=ii[0]
						value=ii[2]
						unit=ii[3]
						if unit: body += data+': '+str(value)+' '+str(unit)+'\n'
						else: body+= data+': '+str(value)+'\n'
			GMAIL_USERNAME = conf.get('GMAIL', 'gmail')
			GMAIL_PASSWORD = conf.get('GMAIL', 'password')
			recipient = conf.get('GMAIL', 'recipient')
			if not body: body = time.strftime("%H:%M:%S")+' '+subject
			try:
				msg=GmailBot(GMAIL_USERNAME,GMAIL_PASSWORD,recipient)
				msg.send(subject,body)
			except Exception,e: print str(e)
		if option=='ACT15':
			subprocess.Popen(['mpg123',text])
		if option=='ACT16':
			subprocess.Popen(['pkill', '-9', 'mpg123'])
		if option=='ACT17':
			subprocess.Popen(['python', self.currentpath+'/message.py', text, conf.get('GENERAL','lang')])
		if option=='ACT18':
			subprocess.Popen(['pkill', '-f', 'message.py'])
		if option=='ACT19':
			return 'read'
		if option=='ACT20':
			subprocess.Popen(['python', self.currentpath+'/ctrl_actions.py', '0'])
		if option[:4]=='HOUT':
				channel=self.out_list[self.getoutlistIndex(option[1:])][3]
				GPIO.output(channel, 1)
		if option[:4]=='LOUT':
				channel=self.out_list[self.getoutlistIndex(option[1:])][3]
				GPIO.output(channel, 0)
Example #6
0
	def run_action(self, option, text):
		conf = self.conf
		if option[0] == 'H':
			channel = int(option[1:])
			GPIO.output(channel, 1)
		elif option[0] == 'L':
			channel = int(option[1:])
			GPIO.output(channel, 0)
		elif option == 'ACT1':
			try:
				wait = float(text)
				time.sleep(wait)
			except Exception,e: print 'ERROR wait action: '+str(e)
		elif option == 'ACT2':
			if text:
				try:
					text = text.split(' ')
					subprocess.Popen(text)
				except Exception,e: print 'ERROR command action: '+str(e)
		elif option == 'ACT3':
			subprocess.Popen(['sudo', 'reboot'])
		elif option == 'ACT4':
			subprocess.Popen(['sudo', 'shutdown', '-h', 'now'])
		elif option == 'ACT5':
			subprocess.Popen(['pkill', '-9', 'kplex'])
		elif option == 'ACT6':
			subprocess.call(['pkill', '-9', 'kplex'])
			subprocess.Popen('kplex')
		elif option == 'ACT7':
			subprocess.Popen(['startup', 'stop'])
		elif option == 'ACT8':
			subprocess.Popen(['startup', 'restart'])
		elif option == 'ACT9':
			subprocess.Popen(['sudo', 'python', self.currentpath +'/wifi_server.py', '0'])
			conf.set('WIFI', 'enable', '0')
		elif option == 'ACT10':
			subprocess.Popen(['sudo', 'python', self.currentpath+'/wifi_server.py', '1'])
			conf.set('WIFI', 'enable', '1')
		#elif option == 'ACT11':
		#elif option == 'ACT12':
		elif option == 'ACT13':
			now = time.strftime("%H:%M:%S")
			tweetStr = now + ' ' + text
			apiKey = conf.get('TWITTER', 'apiKey')
			apiSecret = conf.get('TWITTER', 'apiSecret')
			accessToken = conf.get('TWITTER', 'accessToken')
			accessTokenSecret = conf.get('TWITTER', 'accessTokenSecret')
			if len(tweetStr) > 140: tweetStr = tweetStr[0:140]
			try:
				msg = TwitterBot(apiKey, apiSecret, accessToken, accessTokenSecret)
				msg.send(tweetStr)
			except Exception,e: print 'ERROR Twitter action: '+str(e)
		elif option == 'ACT14':
			subject = text
			body = ''
			for i in self.SK.list_SK:
				body += i[1]+': '+str(i[2])+_('\nsource: ')+i[0]+_('\ntimestamp: ')+i[7]+'\n\n'
			GMAIL_USERNAME = conf.get('GMAIL', 'gmail')
			GMAIL_PASSWORD = conf.get('GMAIL', 'password')
			recipient = conf.get('GMAIL', 'recipient')
			if not body: body = time.strftime("%H:%M:%S") + ' ' + subject
			try:
				msg = GmailBot(GMAIL_USERNAME, GMAIL_PASSWORD, recipient)
				msg.send(subject, body)
			except Exception,e: print 'ERROR gmail action: '+str(e)
		elif option == 'ACT15':
			subprocess.Popen(['mpg123', '-q', text])
		elif option == 'ACT16':
			subprocess.Popen(['pkill', '-9', 'mpg123'])
		elif option == 'ACT17':
			subprocess.Popen(['python', self.currentpath + '/message.py', text, conf.get('GENERAL', 'lang')])
		elif option == 'ACT18':
			subprocess.Popen(['pkill', '-f', 'message.py'])
		elif option == 'ACT19':
			subprocess.Popen(['python', self.currentpath+'/ctrl_actions.py', '1'])
		elif option == 'ACT20':
			subprocess.Popen(['python', self.currentpath + '/ctrl_actions.py', '0'])
		elif option == 'ACT21':
			try:
				sm = gammu.StateMachine()
				sm.ReadConfig()
				sm.Init()
				message = {
					'Text': text,
					'SMSC': {'Location': 1},
					'Number': conf.get('SMS', 'phone'),
				}
				sm.SendSMS(message)
			except Exception,e: print 'ERROR SMS action: '+str(e)
		elif option == 'ACT22':
			pairs_list = text.split('\n\n')
			Erg=''
			if pairs_list:
				for i in pairs_list:
					try:
						pairs = i.split('\n')
						skkey = pairs[0].strip('\n')
						value = pairs[1].strip('\n')
						if re.match('^[0-9a-zA-Z\.]+$', skkey) and value:
							Erg += '{"path": "'+skkey+'","value":"'+str(value)+'"},'
					except Exception,e: print 'ERROR parsing Signal K key action: '+str(e)
				if Erg:		
					SignalK='{"updates":[{"$source":"OPactions","values":['
					SignalK+=Erg[0:-1]+']}]}\n'		
					self.sock.sendto(SignalK, ('127.0.0.1', 55557))
		elif option[:4] == 'MQTT':
			topic = option[4:]
			payload = text
			auth = {'username': conf.get('MQTT', 'username'), 'password': conf.get('MQTT', 'password')}
			publish.single(topic, payload=payload, hostname='127.0.0.1', port='1883', auth=auth)
			publish.single(topic, payload=payload, hostname=conf.get('MQTT', 'broker'), port=conf.get('MQTT', 'port'), auth=auth)