Added tests for addconversions

pull/31/head 0.9.7
weetmuts 2019-05-04 22:39:45 +02:00
rodzic ba75bca37c
commit ffae9c91f3
15 zmienionych plików z 96 dodań i 7 usunięć

23
CHANGES
Wyświetl plik

@ -1,3 +1,26 @@
Version 0.9.7: 2019-05-04
FeatureExpert added support for the Vario 451 heat meter. Thanks FeatureExpert!
New feature: --addconversions=GJ,L
This feature required a major rewrite of how meters print their data.
When the new option --addconversion=<unit> is used, then
any meter that outputs a compatible unit (like kWh) will have
the additional unit (like GJ) also added to to the json.
So if there is a total_energy_consumption_kwh in the json,
there will now also be a total_energy_consumption_gj
For the human readable output and the fields output, the kWh is replaced with GJ.
ATTENTION! change in json keys!
Some untyped json field names, like "flow_temperature":10 had to
change name to "flow_temperature_c":0 (so that if --addconversions=F
is used, then "flow_temperature_f":32 will be added.)
Version 0.9.6: 2019-04-27
Added support for the MK Radio 3 water meter. Thanks FeatureExpert!

Wyświetl plik

@ -81,6 +81,7 @@ Usage: wmbusmeters {options} <device> ( [meter_name] [meter_type] [meter_id] [me
As <options> you can use:
--addconversions=<unit>,<unit> change/add units for the meter output
--c1 or --t1 listen to C1 or T1 messages when no meters are supplied
--debug for a lot of information
--exitafter=<time> exit program after time, eg 20h, 10m 5s
@ -123,13 +124,13 @@ Kamstrup flowIQ 3100 (flowiq3100)
Sontex Supercom 587 (supercom587)
Sensus iPERL (iperl)
Apator at-wmbus-16-2 (apator162) (non-standard protocol)
Water meter Techem MK Radio 3 (mkradio3)
Water meter Techem MK Radio 3 (mkradio3) (non-standard protocol)
Supported heat cost allocator:
Qundis Q caloric (qcaloric)
Supported heat meter:
Heat meter Techem Vario 4 (vario451)
Heat meter Techem Vario 4 (vario451) (non-standard protocol)
Supported electricity meters:
Tauron Amiplus (amiplus) (includes vendor apator and echelon)
@ -274,6 +275,12 @@ The source code is modular and it should be relatively straightforward to add mo
Read for example the text file: HowToAddaNewMeter.txt
# Caveat
If you do not get proper readings from the meters with non-standard protocols. apator162, mkradio3, vario451
then you have to open an issue here and help out by logging a lot of messages and reverse engineer them
even more..... :-/
# Good documents on the wireless mbus protocol:
https://oms-group.org/download4all/

Wyświetl plik

@ -144,7 +144,7 @@ unique_ptr<Configuration> parseCommandLine(int argc, char **argv) {
i++;
continue;
}
if (!strncmp(argv[i], "--addconversion=", 16)) {
if (!strncmp(argv[i], "--addconversions=", 16)) {
if (strlen(argv[i]) > 16)
{
string s = string(argv[i]+16);

Wyświetl plik

@ -255,7 +255,10 @@ void startUsingCommandline(Configuration *config)
config->link_mode = toMeterLinkMode(m.type);
config->link_mode_set = true;
} else {
if (config->link_mode != toMeterLinkMode(m.type) && type_and_device.first != DEVICE_RTLWMBUS) {
if (config->link_mode != toMeterLinkMode(m.type)
&& type_and_device.first != DEVICE_RTLWMBUS
&& type_and_device.first != DEVICE_SIMULATOR)
{
// sdr_rtl|rtl_wmbus can listen to both C1 and T1 at the same time.
error("A different link mode has been set already.\n");
}

Wyświetl plik

@ -24,7 +24,10 @@ using namespace std;
X(KWH, GJ, {vto=vfrom*0.0036;}) \
X(GJ, KWH,{vto=vfrom/0.0036;}) \
X(M3, L, {vto=vfrom*1000.0;}) \
X(L, M3, {vto=vfrom/1000.0;})
X(L, M3, {vto=vfrom/1000.0;}) \
X(C, F, {vto=(vfrom*9.0/5.0)+32.0;}) \
X(F, C, {vto=(vfrom-32)*5.0/9.0;}) \
bool canConvert(Unit ufrom, Unit uto)
{

Wyświetl plik

@ -37,9 +37,10 @@
X(M3,m3,m3,Volume,"cubic meter") \
X(L,l,l,Volume,"litre") \
X(KW,kw,kW,Power,"kilo Watt") \
X(M3H,m3h,m3/h,Flow,"cubic meters per hour") \
X(M3H,m3h,m3/h,Flow,"cubic meters per hour") \
X(C,c,°C,Temperature,"celsius") \
X(HCA,hca,hca,HCA,"heat cost allocation") \
X(F,f,°F,Temperature,"fahrenheit") \
X(HCA,hca,hca,HCA,"heat cost allocation") \
X(TXT,txt,txt,Text,"text") \
enum class Unit

Wyświetl plik

@ -20,4 +20,5 @@ tests/test_multiple_ids.sh $PROG
tests/test_conversions.sh $PROG
#tests/test_oneshot.sh $PROG broken test
tests/test_wrongkeys.sh $PROG
tests/test_config4.sh $PROG
tests/test_rtlwmbus.sh $PROG

Wyświetl plik

@ -0,0 +1,5 @@
loglevel=normal
device=simulations/simulation_conversionsadded.txt
logtelegrams=false
format=json
addconversions=GJ,L,F

Wyświetl plik

@ -0,0 +1,4 @@
name=Hettan
type=vario451
id=58234965
key=

Wyświetl plik

@ -0,0 +1,4 @@
name=MyElectricity
type=omnipower
id=15947107
key=

Wyświetl plik

@ -0,0 +1,4 @@
name=MyElement
type=qcaloric
id=78563412
key=

Wyświetl plik

@ -0,0 +1,4 @@
name=MyHeater
type=multical302
id=12345678
key=

Wyświetl plik

@ -0,0 +1,4 @@
name=MyTapWater
type=multical21
id=76348799
key=

Wyświetl plik

@ -0,0 +1,4 @@
name=Vadden
type=multical21
id=44556677
key=

Wyświetl plik

@ -0,0 +1,22 @@
#!/bin/bash
PROG="$1"
TEST=testoutput
mkdir -p $TEST
cat simulations/simulation_conversionsadded.txt | grep '^{' > $TEST/test_expected.txt
$PROG --useconfig=tests/config4 > $TEST/test_output.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 Config4 with addconversions OK
fi
else
echo Failure.
exit 1
fi