def set_time(): global start_object if int(start_time[:2])==0 and int(stop_time[:2])==0: start_object=TimeOfDay(time(12,int(start_time[-2:])), time(12,int(stop_time[-2:])),utc=False) elif int(start_time[:2])==0: start_object=TimeOfDay(time(12,int(start_time[-2:])), time(int(stop_time[:2]),int(stop_time[-2:])),utc=False) elif int(stop_time[:2])==0: start_object=TimeOfDay(time(int(start_time[:2]),int(start_time[-2:])), time(12,int(stop_time[-2:])),utc=False) else: start_object=TimeOfDay(time(int(start_time[:2]),int(start_time[-2:])), time(int(stop_time[:2]),int(stop_time[-2:])),utc=False)
def handle_time(): startHour = int(request.form['sTimerH']) startMinute = int(request.form['sTimerM']) endHour = int(request.form['eTimerH']) endMinute = int(request.form['eTimerM']) tempo = TimeOfDay(time(startHour, startMinute),time(endHour, endMinute), utc=False) ledWhite.source = tempo ledRedSts = int(ledRed.is_lit) ledWhiteSts = int(ledWhite.is_lit) now = datetime.datetime.now() timeString = now.strftime("%Y-%m-%d %H:%M") templateData = { 'title' : 'RpiServer!', 'time': timeString, 'ledRed' : ledRedSts, 'ledWhite' : ledWhiteSts, 'sHour' : startHour, 'sMinute' : startMinute, 'eHour' : endHour, 'eMinute' : endMinute } return render_template('index.html', **templateData)
from gpiozero import Energenie, TimeOfDay from datetime import time from signal import pause lamp = Energenie(1) daytime = TimeOfDay(time(8), time(20)) lamp.source = daytime lamp.source_delay = 60 pause()
def set_time(sh, sm, ss, eh, em, es): duringtime = TimeOfDay(time(sh, sm, ss), time(eh, em, es)) led.source = duringtime.values return datetime.now() # led.is_lit
from gpiozero import Energenie, TimeOfDay from datetime import time from signal import pause lamp = Energenie(1) daytime = TimeOfDay(time(8), time(20)) daytime.when_activated = lamp.on daytime.when_deactivated = lamp.off pause()
from gpiozero import TimeOfDay, Energenie from datetime import time from signal import pause daytime = TimeOfDay(time(8), time(18)) lamp = Energenie(1) lamp.source = daytime.values lamp.source_delay = 60 pause()