def leave(): s = getState() s['people'] = max(s.get("people", 1)-1, 0) saveState(s) if s['people'] == 0: home.off() return "You're the last to leave; turning everything off!" p = "people remain" if s['people'] > 1 else "person remains" return "Goodbye! Keeping power on since %d %s." % (s['people'], p)
def turnOff(): home.off() return "ok"