You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

21 lines
690 B

import arrow, time, logging
import RPi.GPIO as GPIO
logging.basicConfig(level=logging.INFO, filename="logfile", filemode="a+",format="%(asctime)-15s %(levelname)-8s %(message)s")
try:
file1 = open('/home/pi/dates.txt', 'r')
Lines = file1.readlines()
except IOError:
logging.error("Erreur de lecture")
exit()
for x in Lines:
if arrow.get(x).to('Europe/Paris').format('hh:mm') == arrow.utcnow().to('Europe/Paris').format('hh:mm'):
logging.info("Sonnerie déclenchée à {}".format(arrow.utcnow().to('Europe/Paris').format('HH:mm')))
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.output(7,GPIO.LOW)
time.sleep(1)
GPIO.output(7,GPIO.HIGH)