Fixed code again, now leds working as they have to, i don't know why all Trues and Falses are upside down, because, where should be True is False and vice versa.
But there is one problem: if leds were turned on by earlier and don't have to glow by condition, they won't turn off until starts other (new) condition when they have to turn on. Where is the problem?
import sys
import time
import datetime
import RPi.GPIO as GPIO
import SDL_DS1307
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
LED_R = 17
LED_G = 27
LED_B = 22
GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
filename = time.strftime("%Y-%m-%d%H:%M:%SRTCTest") + ".txt"
starttime = datetime.datetime.utcnow()
ds1307 = SDL_DS1307.SDL_DS1307(1, 0x68)
ds1307.write_now()
while True:
currenttime = datetime.datetime.utcnow()
deltatime = currenttime - starttime
data=time.strftime("%Y"+"%m"+"%d"+"%H"+"%M")
with open('data.txt') as f:
for line in f:
parts=line.split()
if parts[0]<=(data)<=parts[1]:
if parts[2]=='100':
GPIO.putput(LED_R, False)
GPIO.putput(LED_G, True)
GPIO.putput(LED_B, True)
elif parts[2]=='010':
GPIO.putput(LED_R, True)
GPIO.putput(LED_G, False)
GPIO.putput(LED_B, True)
elif parts[2]=='001':
GPIO.putput(LED_R, True)
GPIO.putput(LED_G, True)
GPIO.putput(LED_B, False)
elif parts[2]=='110':
GPIO.putput(LED_R, False)
GPIO.putput(LED_G, True)
GPIO.putput(LED_B, False)
elif parts[2]=='101':
GPIO.putput(LED_R, True)
GPIO.putput(LED_G, False)
GPIO.putput(LED_B, False)
elif parts[2]=='101':
GPIO.putput(LED_R, False)
GPIO.putput(LED_G, False)
GPIO.putput(LED_B, True)
elif parts[2]=='111':
GPIO.putput(LED_R, False)
GPIO.putput(LED_G, False)
GPIO.putput(LED_B, False)
else:
GPIO.output(LED_R, True)
GPIO.output(LED_G, True)
GPIO.output(LED_B, True)
time.sleep(1.0)