diff --git a/src/wmbus.cc b/src/wmbus.cc index 508c683..1e69031 100644 --- a/src/wmbus.cc +++ b/src/wmbus.cc @@ -3439,7 +3439,7 @@ void WMBusCommonImplementation::checkStatus() } strprintf(msg, "Failed to reset wmbus device %s %s! Emergency exit!", toString(type()), device().c_str()); - logAlarm("PROTOCOL_ERROR", msg); + logAlarm("WMBUS_DEVICE_ERROR", msg); manager_->stop(); return; } @@ -3454,7 +3454,8 @@ void WMBusCommonImplementation::checkStatus() } // The timeout has expired! But is the timeout expected because there should be no activity now? - // Also, do not alarm unless we actually have a possible timeout within the expected activity. + // Also, do not sound the alarm unless we actually have a possible timeout within the expected activity, + // otherwise we will always get an alarm when we enter the expected activity period. if (isInsideTimePeriod(now, expected_activity_) && isInsideTimePeriod(then, expected_activity_)) { @@ -3471,7 +3472,7 @@ void WMBusCommonImplementation::checkStatus() timeout_, now.c_str(), expected_activity_.c_str(), since, toString(type()), device().c_str()); - logAlarm("PROTOCOL_ERROR", msg); + logAlarm("TIMEOUT_ERROR", msg); bool ok = reset(); if (ok) @@ -3481,7 +3482,7 @@ void WMBusCommonImplementation::checkStatus() else { strprintf(msg, "Failed to reset wmbus device %s %s! Emergency exit!", toString(type()), device().c_str()); - logAlarm("TIMEOUT_ERROR", msg); + logAlarm("WMBUS_DEVICE_ERROR", msg); manager_->stop(); } } diff --git a/tests/config7/etc/wmbusmeters.conf b/tests/config7/etc/wmbusmeters.conf index 2277d2d..6d12d03 100644 --- a/tests/config7/etc/wmbusmeters.conf +++ b/tests/config7/etc/wmbusmeters.conf @@ -7,7 +7,7 @@ format=json shell=echo METER =="$METER_JSON"== >> /tmp/wmbusmeters_telegram_test # Add alarm for the wmbus dongle, it might need re-initilization. # The alarm will always be logged in the log file. -alarmshell=echo "ALARM_SHELL $ALARM_TYPE $ALARM_MESSAGE" >> /tmp/wmbusmeters_alarm_test +alarmshell=echo ALARM_SHELL "$ALARM_TYPE" "$ALARM_MESSAGE" >> /tmp/wmbusmeters_alarm_test # Expect a received telegram no longer than 1 second since the last telegram! alarmtimeout=1s # Only sound the alarm if the timeout is reached when the radio is actually diff --git a/tests/test_alarm.sh b/tests/test_alarm.sh index 8723eef..6bd9ba7 100755 --- a/tests/test_alarm.sh +++ b/tests/test_alarm.sh @@ -15,7 +15,7 @@ echo "RUNNING $TESTNAME ..." $PROG --useconfig=tests/config7 --device=simulations/simulation_alarm.txt | sed 's/....-..-.. ..:../1111-11-11 11:11/' > $TEST/test_output.txt cat > $TEST/test_expected.txt < /tmp/wmbusmeters_alarm_expected <