fix: guard against undefined conditions in MQTT monitor

Add check for monitor.conditions before calling fromMonitor() to
prevent JSON.parse(undefined) error when monitors don't have
conditions defined.
This commit is contained in:
mkdev11 2026-01-06 03:19:22 +02:00
parent cf1391db6b
commit e22784aaea

View File

@ -35,8 +35,8 @@ class MqttMonitorType extends MonitorType {
monitor.mqttCheckType = "keyword";
}
// Prepare conditions evaluation
const conditions = ConditionExpressionGroup.fromMonitor(monitor);
// Prepare conditions evaluation (only if monitor has conditions defined)
const conditions = monitor.conditions ? ConditionExpressionGroup.fromMonitor(monitor) : null;
const hasConditions = conditions && conditions.children && conditions.children.length > 0;
// Parse JSON if needed for conditions