Exemplo n.º 1
0
 def __init__(self):
     try:
         if self.loadingdone:
             pass
     except:
         self.loadingdone = True
         self.openhab = pf_openhab()
         self.name = "state_handler"
         self.database = main_database()
         self.setting_handler = setting_handler()
         self.message_handler = message_handler()
         self.logging = Logging()
         settings_c = Settings()
         self.host = settings_c.get_setting("main", "hostname")
         self.port = settings_c.get_setting("main", "port")
         self.http = urllib3.PoolManager()
         self.timeouts = {}
         self.update_timeout("screensaver", 60)
         self.update_timeout("message", -1)
         self.screentrigger = 0
         self.screen_state = True
         try:
             self.im_size = settings_c.get_setting("album", "image_size") 
             self.album_url = settings_c.get_setting("album", "random_picture_url") 
         except Exception as e:
             self.logging.error("Invalid album settings: " + str(e), location=self.name)
             self.album_url = "none"
         try:
             self.album_info_url = settings_c.get_setting("album", "picture_info_url") 
             if self.album_info_url == None:
                 raise Exception("No data")
         except:
             self.logging.warn("No album info url", location=self.name)
             self.album_info_url = "none"
def prop_update_factory(zone):
    def thing_prop_update_handler(r, kind, body):
        try:
            id, props = body
        except:
            print('bad tup {}'.format(body))
        else:
            if id in zone.things:
                thing = zone.things[id]
                thing.update(props)
            else:
                thing = zone.add_thing(props)
    return message_handler('tup')(thing_prop_update_handler)
Exemplo n.º 3
0
 def __init__(self):
     self.openhab = pf_openhab()
     self.name = "page_handler"
     self.database = main_database()
     self.setting_handler = setting_handler()
     self.message_handler = message_handler()
     self.widgets_handler = widgets_handler()
     self.state_handler = state_handler()
     self.logging = Logging()
     settings_c = Settings()
     self.host = settings_c.get_setting("main", "hostname")
     self.port = settings_c.get_setting("main", "port")
     self.enable_screen_control = settings_c.get_setting(
         "main", "enable_screen_control")
     self.openhab_host = settings_c.get_setting("main", "openhab_ip")
     self.openhab_port = settings_c.get_setting("main", "openhab_port")
Exemplo n.º 4
0
    def __init__(self, interval=60):
        ##read settings from file
        self.settings_c = settings.Settings()
        ##enable logging
        self.logging = logger.Logging()
        ##loading database
        self.maindatabase = data.main_database()
        self.interval = interval
        self.page_handler = page_handler()
        self.setting_handler = setting_handler()
        self.item_handler = item_handler()
        self.state_handler = state_handler()
        self.message_handler = message_handler()
        self.task_scheduler = task_scheduler()

        thread = threading.Thread(target=self.run, args=())
        thread.daemon = True  # Daemonize thread
        thread.start()  # Start the execution
Exemplo n.º 5
0
 def __init__(self):
     self.openhab = pf_openhab()
     self.name = "item_handler"
     self.database = main_database()
     self.setting_handler = setting_handler()
     self.page_handler = page_handler()
     self.message_handler = message_handler()
     self.logging = Logging()
     settings_c = Settings()
     self.host = settings_c.get_setting("main", "hostname")
     self.port = settings_c.get_setting("main", "port")
     self.enable_clock = settings_c.get_setting("main", "enable_clock")
     self.enable_album = settings_c.get_setting("main", "enable_album")
     self.openhab_server = settings_c.get_setting("main", "openhab_ip")
     self.openhab_port = settings_c.get_setting("main", "openhab_port")
     self.http = urllib3.PoolManager()
     self.timeout_message_popup = 0
     self.saved_chart_periods = {}
     self.screentrigger = 0
Exemplo n.º 6
0
def send_echo(message):
    message_handler(message, bot)