Influx graph part only + device name on jump and start + fixed dselect z-index

This commit is contained in:
l_samenv
2024-08-21 10:05:47 +02:00
parent 2ea1674991
commit 89dd427a22
8 changed files with 115 additions and 12 deletions

View File

@@ -199,6 +199,19 @@ class InfluxDataGetter:
res[variable] = points
return res
def get_device_name(self, time):
"""
Gets the device name available at time with stick and addons
Parameters :
time (int) : the Unix timestamp in seconds of the time we want the device name
Returns :
str : the device name
"""
components = self._get_device_name_components(time)
return "/".join(components)
# ----- PRIVATE METHODS
def _get_all_setup_info_as_dict(self, times, all=False):
@@ -740,4 +753,32 @@ class InfluxDataGetter:
except:
value = None
res.append([t, value])
return res
def _get_device_name_components(self, time):
"""
Gets the components of the device name, first in the main name, then stick, then addons.
Parameters :
time (int) : the Unix timestamp in seconds of the time we want the device name
Returns :
[str] : an array of string, each one being a component of the device name
"""
measurements = ["nicos/se_main", "nicos/se_stick", "nicos/se_addons"]
res = []
for measurement in measurements:
query = f"""
from(bucket: "{self._bucket}")
|> range(start: 0, stop: {time + 1})
|> filter(fn: (r) => r._measurement == "{measurement}")
|> filter(fn: (r) => r._field == "value")
|> last()
"""
tables = self._db.query(query)
for table in tables:
for record in table.records:
name = ast.literal_eval(record.get_value())
if name != None and name != '':
res.append(ast.literal_eval(record.get_value()))
return res