from gpiozero import LED
import shelve
led = LED(17)
def state(current : bool = None):
with shelve.open("Settings.conf") as settings:
if not "state" in settings:
settings["state"] = False
if current != None:
settings["state"] = current
else:
return settings["state"]
def unlock():
led.on()
state(True)
def lock():
led.off()
state(False)
def switch():
if state():
lock()
unlock()