From 45822e5aecc01787e07358d57a256405f44f100b Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 30 Oct 2023 20:04:43 +0100 Subject: [PATCH] Fixed telemeter rendering --- sbapp/sideband/sense.py | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/sbapp/sideband/sense.py b/sbapp/sideband/sense.py index e1cd131..cad80b3 100644 --- a/sbapp/sideband/sense.py +++ b/sbapp/sideband/sense.py @@ -30,6 +30,7 @@ class Telemeter(): if name != None: s.data = s.unpack(p[sid]) + s.synthesized = True s.active = True t.sensors[name] = s @@ -182,11 +183,12 @@ class Sensor(): @property def data(self): - if self._data == None or (self._stale_time != None and time.time() > self.last_update+self._stale_time): - try: - self.update_data() - except: - pass + if not self.synthesized: + if self._data == None or (self._stale_time != None and time.time() > self.last_update+self._stale_time): + try: + self.update_data() + except: + pass self.last_read = time.time() return self._data @@ -270,11 +272,14 @@ class Time(Sensor): return None def render(self, relative_to=None): - rendered = { - "icon": "clock-time-ten-outline", - "name": "Timestamp", - "values": { "UTC": self.data["utc"] }, - } + if self.data != None: + rendered = { + "icon": "clock-time-ten-outline", + "name": "Timestamp", + "values": { "UTC": self.data["utc"] }, + } + else: + rendered = None return rendered @@ -558,10 +563,6 @@ class Pressure(Sensor): if "mbar" in rs.data and rs.data["mbar"] != None: if self.data["mbar"] != None: delta = round(rs.data["mbar"] - self.data["mbar"], 1) - - # TODO: Remove - # RNS.log("OVERRIDING DELTA", RNS.LOG_WARNING) - # delta = round(740.1 - self.data["mbar"], 1) rendered = { "icon": "weather-cloudy", @@ -1075,10 +1076,6 @@ class AmbientLight(Sensor): if self.data["lux"] != None: delta = round(rs.data["lux"] - self.data["lux"], 2) - # TODO: Remove - # RNS.log("OVERRIDING DELTA", RNS.LOG_WARNING) - # delta = round(2500 - self.data["lux"], 2) - rendered = { "icon": "white-balance-sunny", "name": "Ambient Light",