solarcene_community_setup/solar_bot/backup/turn_on.py

33 lines
744 B
Python
Raw Permalink Normal View History

2024-12-05 20:23:25 +00:00
# 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')