def attach_event_manager(self): _LOGGER.info("Attach event manager") message_data = MessageData(self.request_id, self.sessionId) message_data.attach() self.send(message_data)
def pre_login(self): _LOGGER.debug("Prepare pre-login message") message_data = MessageData(self.request_id, self.sessionId) message_data.login(self.username) self.transport.write(message_data.to_message())
def send(self, message_data: MessageData): self.request_id += 1 message_data.id = self.request_id if not self.transport.is_closing(): self.transport.write(message_data.to_message())
def keep_alive(self): _LOGGER.debug("Keep alive") message_data = MessageData(self.request_id, self.sessionId) message_data.keep_alive(self.keep_alive_interval) self.send(message_data) Timer(self.keep_alive_interval, self.keep_alive).start()
def login(self): _LOGGER.debug("Prepare login message") password = self._get_hashed_password(self.random, self.realm, self.username, self.password) message_data = MessageData(self.request_id, self.sessionId) message_data.login(self.username, password) self.send(message_data)
def send(self, message_data: MessageData): self.request_id += 1 message_data.id = self.request_id self.transport.write(message_data.to_message())
def __init__(self): Gtk.Window.__init__(self, title="Magic Mirror") self.state_list = [ "HOME", "WEATHER", "TIME", "QUOTE", "CALENDAR", "HELP", "INFO", "MIRROR" ] self.state = "" # Data classes which update from subscriber input_data = InputData() weather_data = WeatherData() quote_data = QuoteData() calendar_data = EventData() message_data = MessageData() home_data = HomeData() self.auth_data = AuthData() pin_data = PinData() # Screen objects that are cycled in the window self.home_screen = Home(weather_data, calendar_data, home_data, self.auth_data) self.auth_screen = Auth(self.auth_data, pin_data) self.weather_screen = Weather(weather_data) self.time_screen = TimeDate() self.message_screen = Messages(message_data) self.quote_screen = Quote(quote_data) self.calendar_screen = Calendar(calendar_data) self.help_screen = Help() self.info_screen = Info() self.mirror_screen = Mirror() # Starts the MQTT subscriber self.data_thread = threading.Thread(target=subscriber.run, args=([ input_data, weather_data, quote_data, calendar_data, home_data, self.auth_data, pin_data ], )) self.data_thread.daemon = True self.data_thread.start() # Updates the value on the screens in separate threads GObject.timeout_add(1000, self.auth_screen.update) GObject.timeout_add(1000, self.weather_screen.update_weather) GObject.timeout_add(1000, self.time_screen.update_clock) GObject.timeout_add(1000, self.quote_screen.update) GObject.timeout_add(1000, self.calendar_screen.update_events) GObject.timeout_add(1000, self.message_screen.update_screen) GObject.timeout_add(1000, self.home_screen.update_home) self.app_stack = Gtk.Stack() self.app_stack.set_transition_type( Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.app_stack.set_transition_duration(500) self.app_stack.add_named(self.auth_screen, "Auth") self.app_stack.add_named(self.home_screen, "Home") self.app_stack.add_named(self.weather_screen, "Weather") self.app_stack.add_named(self.time_screen, "Time") self.app_stack.add_named(self.message_screen, "Message") self.app_stack.add_named(self.quote_screen, "Quote") self.app_stack.add_named(self.calendar_screen, "Calendar") self.app_stack.add_named(self.help_screen, "Help") self.app_stack.add_named(self.info_screen, "Info") self.app_stack.add_named(self.mirror_screen, "Mirror") # Meant to add the default screen self.add(self.app_stack) self.fullscreen() self.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(255, 0, 255)) self.set_icon(IMG.iconpix)