1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#!/usr/bin/env python
import os
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
# set BCM pin number for the halogene.
HALO = 27
HALOLED = 5
GPIO.setup(HALO, GPIO.OUT)
GPIO.output(HALO, GPIO.HIGH)
GPIO.setup(HALOLED, GPIO.OUT)
GPIO.output(HALOLED, GPIO.LOW)
# set desired status halogene using consigne file from sms or switch
def consigne():
readconsigne = open("/script/consigne_statut/halogene/consigne")
setconsigne = readconsigne.readline(11)
readconsigne.close()
return setconsigne
def holdconsigne():
if consigne() == "Halogene ON":
GPIO.output(HALO, GPIO.LOW)
GPIO.output(HALOLED, GPIO.HIGH)
print("CONSIGNE ON")
time.sleep(1)
elif consigne() == "Halogene OF":
GPIO.output(HALO, GPIO.HIGH)
GPIO.output(HALOLED, GPIO.LOW)
print ("CONSIGNE OFF")
time.sleep(1)
else:
print ("MESSAGE INCONNU")
GPIO.output(HALO, GPIO.HIGH)
GPIO.output(HALOLED, GPIO.LOW)
time.sleep(1)
# this constructs an infinite loop
infloop = 1
while infloop == 1 :
holdconsigne() |
Partager