for set hour_on | hour_off, there is in a configuration these command:
HOUR_ON = 8 # Turn Light ON at 08:00
HOUR_OFF = 18 # Turn Light OFF at 18:00
And it's ok, but if I would set HOUR_ON
at 08:30?
You have to modify your sample program to add the functionality for minutes. Please refer to this page for details on Python date manipulation.
This page explains how to modify loop
function to add minutes
functionality,
def loop():
# Get the current time
now = datetime.time(datetime.datetime.now().hour, datetime.datetime.now().minute)
# Automatically switch on LED
if ((now.hour == HOUR_ON.hour) and (now.minute == HOUR_ON.minute) and (now.second == 0)):
if (GPIO.digitalRead(LIGHT) == GPIO.LOW):
GPIO.digitalWrite(LIGHT, GPIO.HIGH)
# Automatically switch off LED
if ((now.hour == HOUR_OFF.hour) and (now.minute == HOUR_OFF.minute) and (now.second == 0)):
if (GPIO.digitalRead(LIGHT) == GPIO.HIGH):
GPIO.digitalWrite(LIGHT, GPIO.LOW)
# Repeat every 1 second
webiopi.sleep(1)