Add solar_bot/backup/turn_off.py
This commit is contained in:
parent
4ec5a5ff43
commit
6c991b6314
|
@ -0,0 +1,33 @@
|
||||||
|
# Toggles gpio to turn grow lights on/off
|
||||||
|
import requests
|
||||||
|
import time
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
gpio_lights = "4"
|
||||||
|
|
||||||
|
def toggle_lights(state):
|
||||||
|
|
||||||
|
if state == 'on':
|
||||||
|
print('on')
|
||||||
|
subprocess.run(["gpio", "mode", gpio_lights, "out"])
|
||||||
|
subprocess.run(["gpio", "write", gpio_lights, "1"])
|
||||||
|
else:
|
||||||
|
print('off')
|
||||||
|
subprocess.run(["gpio", "write", gpio_lights, "0"])
|
||||||
|
subprocess.run(["gpio", "mode", gpio_lights, "in"])
|
||||||
|
|
||||||
|
|
||||||
|
def turn_on_lights():
|
||||||
|
print('Turning lights on')
|
||||||
|
toggle_lights('on')
|
||||||
|
|
||||||
|
def turn_off_lights():
|
||||||
|
print('Turning lights off')
|
||||||
|
toggle_lights('off')
|
||||||
|
|
||||||
|
print('Starting up')
|
||||||
|
#Just to check lights are off
|
||||||
|
turn_off_lights()
|
||||||
|
print('Lights are off')
|
||||||
|
#turn_on_lights()
|
||||||
|
#print('Lights are on')
|
Loading…
Reference in New Issue