Compare commits

...

2 Commits

Author SHA1 Message Date
d21fb0ca3b [minor] parameter change 2022-11-29 10:42:29 +01:00
19b8df8f7d [minor] add html class for mobile (WIP) 2022-11-29 10:42:15 +01:00
3 changed files with 25 additions and 8 deletions

View File

@ -4,7 +4,7 @@ networks: ["1Y", "HA"]
stations: "*"
locations: "*"
channels: ["EX1", "EX2", "EX3", "VEI"] # Specify SOH channels, currently supported EX[1-3] and VEI
channel_names: ["Temperature (°)", "230V/12V Status (V)", "Router/Charger State (V)", "Logger Voltage (V)"] # names for plotting (optional)
channel_names: ["Temperature (°C)", "230V/12V Status (V)", "Router/Charger State (V)", "Logger Voltage (V)"] # names for plotting (optional)
stations_blacklist: ["TEST", "EREA"]
networks_blacklist: []
interval: 60 # Perform checks every x seconds
@ -48,7 +48,8 @@ THRESHOLDS:
# nw (e.g. 1Y), st (e.g. GR01A), nwst_id (e.g. 1Y.GR01A)
# optional!
add_links:
slmon: {"URL": "{nw}_{st}.html", "text": "show"} # for example: slmon: {"URL": "path/{nw}_{st}.html", "text": "link"}
slmon: {"URL": "../slmon/{nw}_{st}.html", "text": "show"} # for example: slmon: {"URL": "path/{nw}_{st}.html", "text": "link"}
24h-plot: {"URL": "../scheli/{nw}/{st}.png", "text": "plot"}
# E-mail notifications (optional)
EMAIL:
@ -68,4 +69,4 @@ CHANNEL_UNITS:
CHANNEL_TRANSFORM:
EX1:
- ["*", 20]
- ["-", 20]
- ["-", 20]

View File

@ -352,7 +352,17 @@ class SurveillanceBot(object):
fig.savefig(fnout, dpi=150., bbox_inches='tight')
plt.close(fig)
def write_html_table(self, default_color='#e6e6e6', default_header_color='#999'):
def write_html_table(self, default_color='#e6e6e6', default_header_color='#999', hide_keys_mobile=('other')):
def get_html_class(status=None, check_key=None):
""" helper function for html class if a certain condition is fulfilled """
html_class = None
if status and status.is_active:
html_class = 'blink-bg'
if check_key in hide_keys_mobile:
html_class = 'hidden-mobile'
return html_class
self.check_html_dir()
fnout = pjoin(self.outpath_html, 'survBot_out.html')
if not fnout:
@ -370,7 +380,8 @@ class SurveillanceBot(object):
header.insert(-1, key)
header_items = [dict(text='Station', color=default_header_color)]
for check_key in header:
item = dict(text=check_key, color=default_header_color)
html_class = get_html_class(check_key=check_key)
item = dict(text=check_key, color=default_header_color, html_class=html_class)
header_items.append(item)
write_html_row(outfile, header_items, html_key='th')
@ -397,8 +408,9 @@ class SurveillanceBot(object):
if not type(message) in [str]:
message = str(message) + deg_str
html_class = get_html_class(status=status, check_key=check_key)
item = dict(text=str(message), tooltip=str(detailed_message), color=bg_color,
blink=status.is_active)
html_class=html_class)
elif check_key in self.add_links:
value = self.add_links.get(check_key).get('URL')
link_text = self.add_links.get(check_key).get('text')

View File

@ -18,6 +18,9 @@ def write_html_header(fobj, refresh_rate=10):
'</head>',
f'<meta http-equiv="refresh" content="{refresh_rate}" >',
'<meta charset="utf-8">',
'<meta name="viewport" content="width=device-width, initial-scale=1">',
'<link rel="stylesheet" media="only screen and (max-width: 400px)" href="mobile.css" />',
'<link rel="stylesheet" media="only screen and (min-width: 401px)" href="desktop.css" />',
'<body>']
# style = ['<style>',
# 'table, th, td {',
@ -58,8 +61,9 @@ def write_html_row(fobj, items, html_key='td'):
color = '#e6e6e6' if color == '#000000' else color
hyperlink = item.get('hyperlink')
image_str = f'<a href="{hyperlink}">' if hyperlink else ''
blink_str = f' class="blink-bg"' if item.get('blink') else ''
fobj.write(2 * default_space + f'<{html_key}{blink_str} bgcolor="{color}" title="{tooltip}"> {image_str}'
html_class = item.get('html_class')
class_str = f' class="{html_class}"' if html_class else ''
fobj.write(2 * default_space + f'<{html_key}{class_str} bgcolor="{color}" title="{tooltip}"> {image_str}'
+ text + f'</{html_key}>\n')
fobj.write(default_space + '</tr>\n')