2019-05-20 23:17:58 +02:00
|
|
|
import time
|
|
|
|
|
2019-05-21 15:31:30 +02:00
|
|
|
# print(config)
|
|
|
|
WEEKDAY=0
|
|
|
|
# ON
|
|
|
|
dton = {}
|
|
|
|
tmp = config["1on"].split("-")
|
|
|
|
dton[0] = [int(tmp[0]), int(tmp[1]), int(tmp[2]), WEEKDAY, int(tmp[3]), int(tmp[4]), int(tmp[5])]
|
|
|
|
tmp = config["2on"].split("-")
|
|
|
|
dton[1] = [int(tmp[0]), int(tmp[1]), int(tmp[2]), WEEKDAY, int(tmp[3]), int(tmp[4]), int(tmp[5])]
|
|
|
|
print(dton)
|
|
|
|
|
|
|
|
# OFF
|
|
|
|
dtoff = {}
|
|
|
|
tmp = config["1off"].split("-")
|
|
|
|
dtoff[0] = [int(tmp[0]), int(tmp[1]), int(tmp[2]), WEEKDAY, int(tmp[3]), int(tmp[4]), int(tmp[5])]
|
|
|
|
tmp = config["2off"].split("-")
|
|
|
|
dtoff[1] = [int(tmp[0]), int(tmp[1]), int(tmp[2]), WEEKDAY, int(tmp[3]), int(tmp[4]), int(tmp[5])]
|
|
|
|
print(dtoff)
|
|
|
|
pin_led.on()
|
|
|
|
|
2019-05-20 23:17:58 +02:00
|
|
|
while True:
|
2019-05-21 15:31:30 +02:00
|
|
|
dtnow = rtc.datetime()
|
|
|
|
print("rtc.datetime(): ", dtnow)
|
|
|
|
|
|
|
|
for i in dton:
|
|
|
|
dt = dton[i]
|
|
|
|
if (dt[0] == dtnow[0] and dt[1] == dtnow[1] and dt[2] == dtnow[2] and
|
|
|
|
dt[4] == dtnow[4] and dt[5] == dtnow[5] and dt[6] == dtnow[6]):
|
|
|
|
print("power on: ", dt, " at ", dtnow)
|
|
|
|
pin_led.off()
|
|
|
|
for i in dtoff:
|
|
|
|
dt = dtoff[i]
|
|
|
|
if (dt[0] == dtnow[0] and dt[1] == dtnow[1] and dt[2] == dtnow[2] and
|
|
|
|
dt[4] == dtnow[4] and dt[5] == dtnow[5] and dt[6] == dtnow[6]):
|
|
|
|
print("power off: ", dt, " at ", dtnow)
|
|
|
|
pin_led.on()
|
2019-05-20 23:17:58 +02:00
|
|
|
|
|
|
|
time.sleep(1)
|