Пример #1
0
def alarmsnooze(request):
	subprocess.call(['killall', 'mpg123'])
	regels = ['Snooze, let me sleep!']
	sendCommand('S')
	TaskLog(task_name = ArduinoTask.objects.get(task_name = 'checkAlarm'), task_result = False, task_decimal = 0,task_message = "Snooze", set_by = request.user).save()
	day 		= DayOfWeek.objects.filter(weekday = datetime.today().weekday()+1)	#+1 egint bij 0
	timeOfDay 	= datetime.time(datetime.now() + timedelta(0, 300))
	kindOfDay 	= DayRoster.objects.filter(roster=1, day_of_week= day).last()
	TimeItem(kind_of_day= kindOfDay.kind_of_day, task_name = ArduinoTask.objects.get(task_name = 'checkAlarm'), action_time = timeOfDay, target_value=99).save()
	return render(request, "arduinoControl/index.html", {'templist': regels})
Пример #2
0
def alarmon(request):
	mp3_files = [ f for f in listdir('.') if f[-4:] == '.mp3' ]
	index=0
	#sendCommand('P')
	if not (len(mp3_files) > 0):
		result = "No mp3 files found!"
	else:
		subprocess.Popen(['mpg123', mp3_files[index]])
		result = '-- Playing: ' + mp3_files[index] + ' ---'
	regels = [result, 'Lights on']
	sendCommand('P')
	TaskLog(task_name = ArduinoTask.objects.get(task_name = 'checkAlarm'), task_result = True, task_decimal = 0,task_message = "Get up!", set_by = request.user).save()
	return render(request, "arduinoControl/index.html", {'templist': regels})
Пример #3
0
def alarmoff(request):
	subprocess.call(['killall', 'mpg123'])
	regels = ['Alarm is off', 'I repeat the alarm is off']
	sendCommand('S')
	TaskLog(task_name = ArduinoTask.objects.get(task_name = 'checkAlarm'), task_result = False, task_decimal = 0,task_message = "I'm awake!", set_by = request.user).save()
	return render(request, "arduinoControl/index.html", {'templist': regels})