-
TotalConnect 2.0
+ TotalConnect 2.0
@@ -2142,14 +2143,38 @@ def run_update(accounts=None, exclude=None, full_refresh=False):
status_val = status_val.value
is_disarmed = (status_val == 10200 or str(status_val).upper() == "DISARMED")
- is_triggered = len(prev.get('triggered_partitions', [])) > 0
+
+ # Alarma real activa en zonas o particiones
+ is_triggered = (
+ len(prev.get('triggered_partitions', [])) > 0 or
+ any(z.get('status') == 'Alarma' for z in prev.get('active_zones', []))
+ )
has_faults = len(prev.get('active_zones', [])) > 0
if is_disarmed or is_triggered or has_faults:
- group_b_pool.append((loc_id, location))
+ # Peso de severidad:
+ # 0 = Alarma Activa (Prioridad Absoluta)
+ # 1 = Zonas con fallas/abiertas (Prioridad Media)
+ # 2 = Desarmado simple (Prioridad Baja)
+ severity_weight = 2
+ if is_triggered:
+ severity_weight = 0
+ elif has_faults:
+ severity_weight = 1
+
+ group_b_pool.append((loc_id, location, severity_weight))
- group_b_pool.sort(key=get_download_epoch)
- group_b = group_b_pool[:7]
+ # Ordenar por severidad de fallo/alarma primero, y en caso de empate por antigüedad
+ def sort_group_b(item):
+ loc_tuple = item
+ loc_id_str = str(loc_tuple[0])
+ prev = last_loc_map.get(loc_id_str, {})
+ dl_epoch = prev.get('last_download_epoch', 0)
+ severity = loc_tuple[2]
+ return (severity, dl_epoch)
+
+ group_b_pool.sort(key=sort_group_b)
+ group_b = [(x[0], x[1]) for x in group_b_pool[:7]]
group_b_ids = {x[0] for x in group_b}
# 5. Construir Grupo C (Triggers de SOAP pendientes)
diff --git a/totalconnect.spec b/totalconnect.spec
new file mode 100644
index 0000000..a70d9f1
--- /dev/null
+++ b/totalconnect.spec
@@ -0,0 +1,38 @@
+# -*- mode: python ; coding: utf-8 -*-
+
+
+a = Analysis(
+ ['index.py'],
+ pathex=[],
+ binaries=[],
+ datas=[],
+ hiddenimports=[],
+ hookspath=[],
+ hooksconfig={},
+ runtime_hooks=[],
+ excludes=[],
+ noarchive=False,
+ optimize=0,
+)
+pyz = PYZ(a.pure)
+
+exe = EXE(
+ pyz,
+ a.scripts,
+ a.binaries,
+ a.datas,
+ [],
+ name='totalconnect',
+ debug=False,
+ bootloader_ignore_signals=False,
+ strip=False,
+ upx=True,
+ upx_exclude=[],
+ runtime_tmpdir=None,
+ console=True,
+ disable_windowed_traceback=False,
+ argv_emulation=False,
+ target_arch=None,
+ codesign_identity=None,
+ entitlements_file=None,
+)