Fix
Build and Push / maintence (push) Successful in 1s
Build and Push / buildApp (push) Successful in 5s
Build and Push / pushApp (push) Failing after 6s

This commit is contained in:
energys
2026-09-25 21:03:11 +09:00
parent 83222d1809
commit 70ceac792e
+4 -9
View File
@@ -74,13 +74,14 @@ def fetch_last_value(dta_list):
def collect_metrics():
"""Основная функция сбора метрик."""
global auth_token
if not auth_token:
logging.warning("No auth token available, trying to authenticate...")
get_auth_token()
if not auth_token:
return
# Запрос данных thermostat_work за последний час (3600 секунд)
now = int(time.time())
mintime = now - 3600
@@ -109,9 +110,7 @@ def collect_metrics():
if not data.get('ok'):
logging.error(f"API returned error: {data.get('error_ui', data.get('error'))}")
# Если токен протух — сбрасываем его
if data.get('error') in ['unauthorized', 'token_expired']:
global auth_token
auth_token = None
return
@@ -125,23 +124,19 @@ def collect_metrics():
logging.info("No thermostat_work data in response.")
return
# 1. Время работы котла за последнюю минуту
boiler_work = fetch_last_value(work_data.get('boiler_work_time'))
if boiler_work is not None:
BOILER_WORK.labels(device_id=str(DEVICE_ID)).set(boiler_work)
# 2. Целевая температура
target_temp = fetch_last_value(work_data.get('target_temp'))
if target_temp is not None:
TARGET_TEMP.labels(device_id=str(DEVICE_ID)).set(target_temp)
# 3. Температура с датчиков (если есть в ответе)
# В thermostat_work датчики могут быть в отдельном поле или не быть вовсе.
# Здесь пример для поля temperature, если оно придёт.
temps = work_data.get('temperature')
if temps and isinstance(temps, dict):
for sensor_id, sensor_info in temps.items():
if not isinstance(sensor_info, dict): continue
if not isinstance(sensor_info, dict):
continue
name = sensor_info.get('name', sensor_id)
val = fetch_last_value(sensor_info.get('temperature'))
if val is not None: