Kaithem Automation

<%! from kaithem.src import notifications,auth,unitsofmeasure,pages,alerts import time import quart from kaithem.src.config import config from kaithem.src.unitsofmeasure import format_time_interval pcolor={ "critical": "pink", "error": 'red', "warning": 'orange', "info": 'lightgreen' } iclass={ "critical": "critical-icon", "error": 'error-icon', "warning": 'warning-icon', "info": 'info-icon' } scolor={ 'active':'yellow', 'acknowledged':'orange', "cleared":'blue' } %> <%include file="/pageheader.html"/>

${config['front_page_banner']}

<% if "ackalarm" in quart.request.args: if quart.request.args['ackalarm'] in alerts.all: alerts.all[quart.request.args['ackalarm']].API_ack() toshow = {} l = [] for i in alerts.unacknowledged.values(): i = i() if not i: continue toshow[i.id]=0 l.append(i) try: del i except: pass for i in alerts.active.values(): i = i() if not i: continue if not i.id in toshow: if not i.priority==debug: toshow[i.id]=0 l.append(i) try: del i except: pass l = sorted(l, key=lambda i: (0 if (i.priority in ('error', 'critical')) else 1, i.sm.state=="acknowledged", i.priority, i.zone, i.name)) def getClass(i): if i.sm.state in ("acknowledged", "active"): if i.priority in ('error', 'critical'): return "error" if i.priority in ('warning'): return "warning" return "" %> %for i in l:
${i.priority} ${unitsofmeasure.strftime(i.trippedAt)}(${format_time_interval(time.time()-i.trippedAt,1)} ago)
${i.trip_message}
%if not i.sm.state=="acknowledged":
%else:
%endif
%endfor
<% try: del i del l except: pass %>
{{formatTime(i[0])}}

{{i[2]}}

<%include file="/pagefooter.html"/>