diff --git a/simulations/simulation_t1.txt b/simulations/simulation_t1.txt index 19099b4..c93290a 100644 --- a/simulations/simulation_t1.txt +++ b/simulations/simulation_t1.txt @@ -219,8 +219,8 @@ telegram=|2E449215303099990D077AB50820452F2F_0C12495849004C12557545000FB10445007 # Test Elster Merlin 868 radio attachement telegram=|2E4492159293949511377ABE0020252F2F_04135515000004FD971D80800000441300000000426C000002FDFD02B300| -{"media":"radio converter (meter side)","meter":"emerlin868","name":"Vodda","id":"95949392","total_m3":5.461,"target_m3":0,"timestamp":"1111-11-11T11:11:11Z"} -|Vodda;95949392;5.461000;0.000000;1111-11-11 11:11.11 +{"media":"radio converter (meter side)","meter":"emerlin868","name":"Vodda","id":"95949392","total_m3":5.461,"target_m3":0,"target_date":"2000-00-00","timestamp":"1111-11-11T11:11:11Z"} +|Vodda;95949392;5.461;0;1111-11-11 11:11.11 # Test Techem TSD2 smoke detector telegram=|294468506935639176F0A0_009F2782290060822900000401D6311AF93E1BF93E008DC3009ED4000FE500| diff --git a/src/driver_ev200.cc b/src/driver_ev200.cc new file mode 100644 index 0000000..5fb13a7 --- /dev/null +++ b/src/driver_ev200.cc @@ -0,0 +1,66 @@ +/* + Copyright (C) 2017-2022 Fredrik Öhrström (gpl-3.0-or-later) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include"meters_common_implementation.h" + +namespace +{ + struct Driver : public virtual MeterCommonImplementation + { + Driver(MeterInfo &mi, DriverInfo &di); + }; + + static bool ok = registerDriver([](DriverInfo&di) + { + di.setName("ev200"); + di.setDefaultFields("name,id,total_m3,target_m3,timestamp"); + di.setMeterType(MeterType::WaterMeter); + di.addLinkMode(LinkMode::T1); + di.addDetection(MANUFACTURER_ELR, 0x07, 0x0d); + di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr(new Driver(mi, di)); }); + }); + + Driver::Driver(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) + { + addNumericFieldWithExtractor( + "total", + "The total water consumption recorded by this meter.", + PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT, + Quantity::Volume, + VifScaling::Auto, + FieldMatcher::build() + .set(MeasurementType::Instantaneous) + .set(VIFRange::Volume) + ); + + addNumericFieldWithExtractor( + "target", + "The target water consumption recorded at previous period.", + PrintProperty::JSON | PrintProperty::FIELD | PrintProperty::IMPORTANT, + Quantity::Volume, + VifScaling::Auto, + FieldMatcher::build() + .set(MeasurementType::Instantaneous) + .set(VIFRange::Volume) + .set(StorageNr(1))); + } +} + +// Test: Voda ev200 99993030 NOKEY +// telegram=|2E449215303099990D077AB50820452F2F_0C12495849004C12557545000FB10445007022C50BFFFFFFFF0000FFF000| +// {"media":"water","meter":"ev200","name":"Voda","id":"99993030","total_m3":49.5849,"target_m3":45.7555,"timestamp":"1111-11-11T11:11:11Z"} +// |Voda;99993030;49.5849;45.7555;1111-11-11 11:11.11 diff --git a/src/meter_detection.h b/src/meter_detection.h index 1a20699..d35fbc2 100644 --- a/src/meter_detection.h +++ b/src/meter_detection.h @@ -42,7 +42,6 @@ X(EHZP, MANUFACTURER_EMH, 0x02, 0x02) \ X(ESYSWM, MANUFACTURER_ESY, 0x37, 0x30) \ X(EM24, MANUFACTURER_KAM, 0x02, 0x33) \ - X(EMERLIN868,MANUFACTURER_ELR, 0x37, 0x11) \ X(EVO868, MANUFACTURER_MAD, 0x07, 0x50) \ X(FHKVDATAIII,MANUFACTURER_TCH, 0x80, 0x69) \ X(FHKVDATAIII,MANUFACTURER_TCH, 0x80, 0x94) \ diff --git a/src/meter_emerlin868.cc b/src/meter_emerlin868.cc deleted file mode 100644 index 4a0f3a9..0000000 --- a/src/meter_emerlin868.cc +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (C) 2017-2020 Fredrik Öhrström (gpl-3.0-or-later) - Copyright (C) 2018 David Mallon (gpl-3.0-or-later) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include"dvparser.h" -#include"meters.h" -#include"meters_common_implementation.h" -#include"wmbus.h" -#include"wmbus_utils.h" - -using namespace std; - -struct MeterEMerlin868 : public virtual MeterCommonImplementation { - MeterEMerlin868(MeterInfo &mi); - - // Total water counted through the meter - double totalWaterConsumption(Unit u); - bool hasTotalWaterConsumption(); - double targetWaterConsumption(Unit u); - bool hasTargetWaterConsumption(); - -private: - void processContent(Telegram *t); - - double actual_total_water_consumption_m3_ {}; - double last_total_water_consumption_m3h_ {}; -}; - -MeterEMerlin868::MeterEMerlin868(MeterInfo &mi) : - MeterCommonImplementation(mi, "emerlin868") -{ - setMeterType(MeterType::WaterMeter); - - setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV); - - addLinkMode(LinkMode::T1); - - // version 0x68 - // version 0x7c Sensus 640 - - addPrint("total", Quantity::Volume, - [&](Unit u){ return totalWaterConsumption(u); }, - "The total water consumption recorded by this meter.", - PrintProperty::FIELD | PrintProperty::JSON); - - addPrint("target", Quantity::Volume, - [&](Unit u){ return targetWaterConsumption(u); }, - "The target water consumption recorded at previous period.", - PrintProperty::FIELD | PrintProperty::JSON); -} - -shared_ptr createEMerlin868(MeterInfo &mi) -{ - return shared_ptr(new MeterEMerlin868(mi)); -} - -void MeterEMerlin868::processContent(Telegram *t) -{ - int offset; - string key; - - if(findKey(MeasurementType::Instantaneous, VIFRange::Volume, 0, 0, &key, &t->dv_entries)) { - extractDVdouble(&t->dv_entries, key, &offset, &actual_total_water_consumption_m3_); - t->addMoreExplanation(offset, " actual total consumption (%f m3)", actual_total_water_consumption_m3_); - } - - if(findKey(MeasurementType::Instantaneous, VIFRange::Volume, 1, 0, &key, &t->dv_entries)) { - extractDVdouble(&t->dv_entries, key, &offset, &last_total_water_consumption_m3h_); - t->addMoreExplanation(offset, " last total consumption (%f m3)", last_total_water_consumption_m3h_); - } - - -} - -double MeterEMerlin868::totalWaterConsumption(Unit u) -{ - assertQuantity(u, Quantity::Volume); - return convert(actual_total_water_consumption_m3_, Unit::M3, u); -} - -bool MeterEMerlin868::hasTotalWaterConsumption() -{ - return true; -} - -double MeterEMerlin868::targetWaterConsumption(Unit u) -{ - assertQuantity(u, Quantity::Volume); - return convert(last_total_water_consumption_m3h_, Unit::M3, u); -} - -bool MeterEMerlin868::hasTargetWaterConsumption() -{ - return true; -} diff --git a/src/meters.h b/src/meters.h index b74909a..4d51819 100644 --- a/src/meters.h +++ b/src/meters.h @@ -69,7 +69,6 @@ LIST_OF_METER_TYPES X(ehzp, T1_bit, ElectricityMeter, EHZP, EHZP) \ X(esyswm, T1_bit, ElectricityMeter, ESYSWM, ESYSWM) \ X(em24, C1_bit, ElectricityMeter, EM24, EM24) \ - X(emerlin868, T1_bit, WaterMeter, EMERLIN868, EMerlin868) \ X(evo868, T1_bit, WaterMeter, EVO868, EVO868) \ X(fhkvdataiii,T1_bit, HeatCostAllocationMeter, FHKVDATAIII, FHKVDataIII) \ X(fhkvdataiv, T1_bit, HeatCostAllocationMeter, FHKVDATAIV, FHKVDataIV) \