def exit_application(): database.set_app_running(False) Log.new(Log.DEBUG, "### Exit application! ###") Relay.clear_relay() print("Exiting....") print("Current App Status = " + str(database.get_app_running())) print("##########################") print("####### Clear relay ######") print("##########################") print("####### Goodbye !!#######") print("##########################")
def get(self): from Module.Relay import Relay object_id = self.get_argument("id", "None") relay_action = self.get_argument("type", "None") if object_id not in "None": if relay_action in "off": Relay.set_force_on(object_id, Relay.FORCE_OFF) if relay_action in "on": Relay.set_force_on(object_id, Relay.FORCE_ON) self.redirect('/relay') relay_list = Relay.get_relay_object_list() self.render("relay.html", relay_list=relay_list)
def checker(self): for relay_item in Relay.get_relay_list(): relay = Relay(gpio=relay_item["gpio"], relay_type=relay_item["relay_type"], name=relay_item["name"], status=relay_item["status"], time=relay_item["timer"], active=relay_item["active"], force_on=relay_item["force_on"], object_id=relay_item["_id"]) if self.DEBUG: print("#Relay = " + relay.name + " #Type = " + str(relay.relay_type)) if relay.relay_type in Relay.TYPE_TIMER: self.timer_checker(relay) elif relay.relay_type in Relay.TYPE_SWITCH: self.switch_checker(relay)
def relay_section_draw(self): x = 300 y = 90 r = 9 text_x = 75 list_relay = Relay.get_relay_object_list() for relay in list_relay: if relay.get_state() == 1: color = "green" else: color = "red" self.draw.text((210, text_x), relay.name, fill=(32, 32, 32), font=self.font) self.draw.ellipse((x - r, y - r, x + r, y + r), fill=color) y += 25 text_x += 25
import configparser from Class.RedisDatabase import RedisDatabase from Class.Timer import Timer from Module.Relay import Relay config = configparser.ConfigParser() config.read("config.ini") database = RedisDatabase() Relay.insert_new_relay() #timer = Timer(config=config, redis_database=database) #timer.start()