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.
 

25 lines
844 B

import arrow, time, logging, os
import RPi.GPIO as GPIO
# VARIABLES
log_file = "logfile"
dates_file = "dates.txt"
logging.basicConfig(level=logging.INFO, filename=os.path.join(os.path.dirname(__file__),log_file), filemode="a+",format="%(asctime)-15s %(levelname)-8s %(message)s")
try:
file1 = open(os.path.join(os.path.dirname(__file__),dates_file), 'r')
Lines = file1.readlines()
except IOError:
logging.error("Erreur de lecture")
exit()
for x in Lines:
if arrow.get(x).to('Europe/Paris').format('YYYY-MM-DD HH:mm') == arrow.utcnow().to('Europe/Paris').format('YYYY-MM-DD 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)