Add regression test for yet another weird izar.

pull/241/head
Fredrik Öhrström 2021-02-07 08:27:01 +01:00
rodzic 3ed662c07c
commit 14742c713e
5 zmienionych plików z 122 dodań i 33 usunięć

Wyświetl plik

@ -0,0 +1,23 @@
# The design philosophy of the izar water meters, is never ever let
# a water meter report itself as a water meter....
# Test IZAR RC 868 I R4 PL water meter telegram, it reports itself as an oil meter... duh?
# But wmbusmeters politely translates this into water.
telegram=|1944304C72242421D401A2|013D4013DD8B46A4999C1293E582CC|
{"media":"water","meter":"izar","name":"IzarWater","id":"21242472","total_m3":3.488,"last_month_total_m3":3.486,"last_month_measure_date":"2019-09-30","remaining_battery_life_y":14.5,"current_alarms":"meter_blocked,underflow","previous_alarms":"no_alarm","timestamp":"1111-11-11T11:11:11Z"}
# Test new version of IZAR
telegram=|2944A511780729662366A20118001378D3B3DB8CEDD77731F25832AAF3DA8CADF9774EA673172E8C61F2|
{"media":"water","meter":"izar","name":"IzarWater2","id":"66290778","total_m3":16.76,"last_month_total_m3":11.84,"last_month_measure_date":"2019-11-30","remaining_battery_life_y":12,"current_alarms":"no_alarm","previous_alarms":"no_alarm","timestamp":"1111-11-11T11:11:11Z"}
# Yet another silly version of IZAR, come again, type 0x20 = Breaker (electricity) for a water meter!
telegram=|1944A511780779194820A1|21170013355F8EDB2D03C6912B1E37
{"media":"water","meter":"izar","name":"IzarWater3","id":"19790778","total_m3":4.366,"last_month_total_m3":0,"last_month_measure_date":"2020-12-31","remaining_battery_life_y":11.5,"current_alarms":"no_alarm","previous_alarms":"no_alarm","timestamp":"1111-11-11T11:11:11Z"}
# And another izar sillines, this time its a "heat meter" and a mfct specific tpl ci field a3.
telegram=|1944304c9c5824210c04a363140013716577ec59e8663ab0d31c|
{"media":"water","meter":"izar","name":"IzarWater4","id":"2124589c","total_m3":38.944,"last_month_total_m3":38.691,"last_month_measure_date":"2021-02-01","remaining_battery_life_y":10,"current_alarms":"no_alarm","previous_alarms":"no_alarm","timestamp":"1111-11-11T11:11:11Z"}

Wyświetl plik

@ -104,24 +104,6 @@ telegram=|5744b40988227711101b7ab20800000265a00842658f088201659f08226589081265a0
{"media":"room sensor","meter":"rfmamb","name":"Rummet","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|Rummet;11772288;22.080000;44.200000;1111-11-11 11:11.11
# Test IZAR RC 868 I R4 PL water meter telegram
telegram=|1944304C72242421D401A2|013D4013DD8B46A4999C1293E582CC|
{"media":"water","meter":"izar","name":"IzarWater","id":"21242472","total_m3":3.488,"last_month_total_m3":3.486,"last_month_measure_date":"2019-09-30","remaining_battery_life_y":14.5,"current_alarms":"meter_blocked,underflow","previous_alarms":"no_alarm","timestamp":"1111-11-11T11:11:11Z"}
|IzarWater;21242472;3.488000;3.486000;2019-09-30;14.500000;meter_blocked,underflow;no_alarm;1111-11-11 11:11.11
# Test new version of IZAR
telegram=|2944A511780729662366A20118001378D3B3DB8CEDD77731F25832AAF3DA8CADF9774EA673172E8C61F2|
{"media":"water","meter":"izar","name":"IzarWater2","id":"66290778","total_m3":16.76,"last_month_total_m3":11.84,"last_month_measure_date":"2019-11-30","remaining_battery_life_y":12,"current_alarms":"no_alarm","previous_alarms":"no_alarm","timestamp":"1111-11-11T11:11:11Z"}
|IzarWater2;66290778;16.760000;11.840000;2019-11-30;12.000000;no_alarm;no_alarm;1111-11-11 11:11.11
# Yet another silly version of IZAR, come again, type 0x20 = Breaker (electricity) for a water meter!
telegram=|1944A511780779194820A1|21170013355F8EDB2D03C6912B1E37
{"media":"water","meter":"izar","name":"IzarWater3","id":"19790778","total_m3":4.366,"last_month_total_m3":0,"last_month_measure_date":"2020-12-31","remaining_battery_life_y":11.5,"current_alarms":"no_alarm","previous_alarms":"no_alarm","timestamp":"1111-11-11T11:11:11Z"}
|IzarWater3;19790778;4.366000;0.000000;2020-12-31;11.500000;no_alarm;no_alarm;1111-11-11 11:11.11
# Test Hydrus water meter telegram
telegram=|4E44A5116464646470077AED004005|2F2F01FD08300C13741100007C1300000000FC101300000000FC201300000000726C00000B3B00000002FD748713025A6800C4016D3B177F2ACC011300020000|
{"media":"water","meter":"hydrus","name":"HydrusWater","id":"64646464","total_m3":1.174,"max_flow_m3h":0,"flow_temperature_c":10.4,"total_at_date_m3":0.2,"at_date":"2019-10-31 23:59","remaining_battery_life_y":13.686516,"status":"OK","timestamp":"1111-11-11T11:11:11Z"}

Wyświetl plik

@ -30,6 +30,9 @@ if [ "$?" != "0" ]; then RC="1"; fi
tests/test_apas.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi
tests/test_izars.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi
tests/test_aes.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi

Wyświetl plik

@ -0,0 +1,96 @@
#!/bin/sh
PROG="$1"
mkdir -p testoutput
TEST=testoutput
TESTNAME="Test Izas meters"
TESTRESULT="ERROR"
LOGFILE=$TEST/logfile
LOGFILE_EXPECTED=$TEST/logfile_expected
mkdir -p $TEST
rm -f $LOGFILE
METERS="IzarWater izar 21242472 NOKEY
IzarWater2 izar 66290778 NOKEY
IzarWater3 izar 19790778 NOKEY
IzarWater4 izar 2124589c NOKEY"
cat simulations/simulation_izars.txt | grep '^{' > $TEST/test_expected.txt
$PROG --format=json simulations/simulation_izars.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt
if [ "$?" = "0" ]
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
diff $TEST/test_expected.txt $TEST/test_responses.txt
if [ "$?" = "0" ]
then
echo OK json: $TESTNAME
TESTRESULT="OK"
else
TESTRESULT="ERROR"
fi
else
echo "wmbusmeters returned error code: $?"
cat $TEST/test_output.txt
cat $TEST/test_stderr.txt
fi
if [ "$TESTRESULT" = "ERROR" ]
then
echo ERROR: $TESTNAME
exit 1
fi
TESTNAME="Test listen to all izas"
TESTRESULT="ERROR"
cat > $LOGFILE_EXPECTED <<EOF
No meters configured. Printing id:s of all telegrams heard!
Received telegram from: 21242472
manufacturer: (SAP) Sappel (0x4c30)
type: Oil meter (0x01)
ver: 0xd4
driver: izar
Received telegram from: 66290778
manufacturer: (DME) DIEHL Metering, Germany (0x11a5)
type: Unknown (0x66)
ver: 0x23
driver: izar
Received telegram from: 19790778
manufacturer: (DME) DIEHL Metering, Germany (0x11a5)
type: Breaker (electricity) (0x20)
ver: 0x48
driver: izar
Received telegram from: 2124589c
manufacturer: (SAP) Sappel (0x4c30)
type: Heat meter (0x04)
ver: 0x0c
driver: izar
EOF
RES=$($PROG --logfile=$LOGFILE --t1 simulations/simulation_izars.txt 2>&1)
if [ ! "$RES" = "" ]
then
echo ERROR: $TESTNAME
echo Expected no output on stdout and stderr
echo but got------------------
echo $RES
echo ---------------------
exit 1
fi
RES=$(diff $LOGFILE $LOGFILE_EXPECTED)
if [ ! -z "$RES" ]
then
echo ERROR: $TESTNAME
echo -----------------
diff $LOGFILE $LOGFILE_EXPECTED
echo -----------------
exit 1
else
echo OK: $TESTNAME
fi

Wyświetl plik

@ -119,21 +119,6 @@ Received telegram from: 11772288
type: Room sensor (eg temperature or humidity) (0x1b)
ver: 0x10
driver: rfmamb
Received telegram from: 21242472
manufacturer: (SAP) Sappel (0x4c30)
type: Oil meter (0x01)
ver: 0xd4
driver: izar
Received telegram from: 66290778
manufacturer: (DME) DIEHL Metering, Germany (0x11a5)
type: Unknown (0x66)
ver: 0x23
driver: izar
Received telegram from: 19790778
manufacturer: (DME) DIEHL Metering, Germany (0x11a5)
type: Breaker (electricity) (0x20)
ver: 0x48
driver: izar
Received telegram from: 64646464
manufacturer: (DME) DIEHL Metering, Germany (0x11a5)
type: Water meter (0x07)