def render(self, data: Dict) -> str: return Tile.render_template(os.path.dirname(__file__), __class__.__name__, formattedDates=data['formattedDates'], minValues=data['minValues'], maxValues=data['maxValues'], icons=data['icons'], chartId=str(uuid.uuid4()))
def render(self, data: Dict) -> str: sensorType = data['sensorInfo']['type'] unit = self.UNITS_BY_SENSOR_TYPE.get(sensorType, '') return Tile.render_template(os.path.dirname(__file__), __class__.__name__, data=data, unit=unit)
def render(self, data: Dict) -> str: return Tile.render_template( os.path.dirname(__file__), __class__.__name__, gamesForTwo=data['gamesForTwo'], gamesAtLeastThree=data['gamesAtLeastThree'], gamesForThreeOrMore=data['gamesForThreeOrMore'], randomGame=data['randomGame'])
def unregister_tile(self, pageName: str, tile: Tile): fullName = self.get_full_name(pageName, tile.get_uniqueName()) if fullName not in self.__jobs: LOGGER.warning(f'Tile "{fullName}" is not registered') self.__jobs[fullName].remove() del self.__jobs[fullName] del self.__cache[fullName] del self.__tiles[fullName] LOGGER.debug(f'Unregistered "{fullName}"')
def register_tile(self, pageName: str, tile: Tile): fullName = self.get_full_name(pageName, tile.get_uniqueName()) if fullName in self.__jobs: LOGGER.warning(f'Tile "{fullName}" already registered') return seconds = tile.get_intervalInSeconds() nextRunTime = datetime.now() if seconds == -1: # disable automatic refresh seconds = 9999999999 # 317 years nextRunTime = None # job is paused job = self.__scheduler.add_job(tile.update, 'interval', [pageName], seconds=seconds, next_run_time=nextRunTime) self.__jobs[fullName] = job self.__cache[fullName] = None self.__tiles[fullName] = tile LOGGER.debug(f'Registered "{fullName}" (scheduled every {tile.get_intervalInSeconds()} seconds)')
def render(self, data: Dict) -> str: sensorType = data['sensorInfo']['type'] unit = self.UNIT_BY_SENSOR_TYPE.get(sensorType, '') unescapedUnit = html.unescape(unit) icon = self.ICON_BY_SENSOR_TYPE.get(sensorType, '') textLabels = [ f'{self.__format_date(xItem)} - {yItem}{unescapedUnit}' for xItem, yItem in zip(data['x'], data['y']) ] title = self._settings['title'] if self._settings['showAxes']: days = int(self._settings['numberOfHoursToShow'] / 24) title = f'{title} - {days} days' warningSettings = self._settings['outdatedValueWarning'] timeSinceLastValue = self._get_time_since_last_value( warningSettings, data) self._send_notification(warningSettings, data['sensorInfo'], data['deviceInfo'], timeSinceLastValue) return Tile.render_template(os.path.dirname(__file__), __class__.__name__, x=data['x'], y=data['y'], textLabels=textLabels, min=data['min'], max=data['max'], latest=data['latest'], unit=unit, icon=icon, title=title, lineColor=self._settings['lineColor'], fillColor=self._settings['fillColor'], chartId=str(uuid.uuid4()), ghostTraceX=data['ghostTraceX'], ghostTraceY=data['ghostTraceY'], showAxes=self._settings['showAxes'], timeSinceLastValue=timeSinceLastValue)
def render(self, data: Dict) -> str: return Tile.render_template(os.path.dirname(__file__), __class__.__name__, time=data['time'])