Refine BearClaw infrastructure health alerts

master
Carlo Costanzo 1 month ago
parent 11d70e5c02
commit b06565e0a7

@ -192,9 +192,13 @@
icon: mdi:robot-outline
variables:
ok_state: ok
warning_state: warning
status_severity: >
[[[
const raw = String(entity?.state ?? '').toLowerCase();
if (['unknown', 'unavailable', 'none', ''].includes(raw)) return 'unknown';
return raw === 'error' ? 'critical' : 'healthy';
]]]
healthy_text: HEALTHY
warning_text: JOB WARNING
critical_text: JOB ERROR
tap_action:
action: navigate
@ -349,14 +353,12 @@
name: BearClaw scheduled job needs attention
icon: mdi:calendar-alert
variables:
alert_kind: state_not
ok_state: ok
alert_severity: >
[[[ return entity?.state === 'warning' ? 'warning' : 'critical'; ]]]
alert_kind: state_is
alert_state: error
alert_severity: critical
exception_detail: >
[[[ return String(entity?.attributes?.summary ?? 'SCHEDULED JOB STATUS REQUIRES REVIEW').toUpperCase(); ]]]
state_display: >
[[[ return entity?.state === 'warning' ? 'WARNING' : 'ERROR'; ]]]
state_display: ERROR
tap_action:
action: navigate
navigation_path: /dashboard-infrastructure/joanna

@ -177,9 +177,13 @@
critical_text: JOB ERROR
state_display: >
[[[
const count = Number.parseInt(entity?.attributes?.issue_count ?? '0', 10);
if (entity?.state === 'ok') return 'HEALTHY';
return `${Number.isFinite(count) ? count : '?'} ${String(entity?.state ?? 'unknown').toUpperCase()}`;
const errors = Number.parseInt(entity?.attributes?.error_count ?? '0', 10);
const warnings = Number.parseInt(entity?.attributes?.warning_count ?? '0', 10);
const parts = [];
if (Number.isFinite(errors) && errors > 0) parts.push(`${errors} ERROR${errors === 1 ? '' : 'S'}`);
if (Number.isFinite(warnings) && warnings > 0) parts.push(`${warnings} WARN`);
return parts.join(' · ') || 'STATUS UNKNOWN';
]]]
- type: custom:button-card

@ -784,6 +784,10 @@ bearstone_infra_alert_row:
const okState = String(variables?.ok_state ?? '').toLowerCase();
show = stateStr.toLowerCase() !== okState;
}
else if (kind === 'state_is') {
const alertState = String(variables?.alert_state ?? '').toLowerCase();
show = Boolean(alertState) && stateStr.toLowerCase() === alertState;
}
else if (kind === 'ap_zero') show = (stateStr === '0' && ageS >= minAge);
else if (kind === 'disk_high' || kind === 'numeric_high') {
const v = parseFloat(stateStr);

@ -243,7 +243,7 @@ template:
'binary_sensor.kiosk_devices_need_attention'
] %}
{% set category_count = expand(categories) | selectattr('state', 'eq', 'on') | list | count %}
{% set bearclaw_issue = states('sensor.bearclaw_scheduled_job_health') in ['warning', 'error'] %}
{% set bearclaw_issue = is_state('sensor.bearclaw_scheduled_job_health', 'error') %}
{{ category_count + (1 if bearclaw_issue else 0) }}
attributes:
active_entities: >-
@ -257,7 +257,7 @@ template:
'binary_sensor.kiosk_devices_need_attention'
] %}
{% set active = expand(categories) | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list %}
{% if states('sensor.bearclaw_scheduled_job_health') in ['warning', 'error'] %}
{% if is_state('sensor.bearclaw_scheduled_job_health', 'error') %}
{% set active = active + ['sensor.bearclaw_scheduled_job_health'] %}
{% endif %}
{{ active }}

Loading…
Cancel
Save

Powered by TurnKey Linux.