kopia lustrzana https://github.com/weetmuts/wmbusmeters
Refactor driver compact5.
rodzic
c3a1f22ac1
commit
32f6987d68
|
@ -230,12 +230,12 @@ telegram=|294468506935639176F0A0_009F2782290060822900000401D6311AF93E1BF93E008DC
|
|||
# Test Techem Compact V heat meter
|
||||
telegram=|36446850626262624543A1_009F2777010060780000000A000000000000000000000000000000000000000000000000A0400000B4010000|
|
||||
{"media":"heat","meter":"compact5","name":"Heating","id":"62626262","total_kwh":495,"current_kwh":120,"previous_kwh":375,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
|Heating;62626262;495.000000;120.000000;375.000000;1111-11-11 11:11.11
|
||||
|Heating;62626262;495;120;375;1111-11-11 11:11.11
|
||||
|
||||
# Another Compact V heat meter
|
||||
telegram=|37446850336633663943a2_10672c866100181c01000480794435d50000000000000000000000000000000000000000000000000000000000|
|
||||
{"media":"heat","meter":"compact5","name":"Heating2","id":"66336633","total_kwh":25250,"current_kwh":284,"previous_kwh":24966,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
|Heating2;66336633;25250.000000;284.000000;24966.000000;1111-11-11 11:11.11
|
||||
|Heating2;66336633;25250;284;24966;1111-11-11 11:11.11
|
||||
|
||||
# Test Maddalena EVO 868 wmbus module on water meter
|
||||
telegram=|aa4424347677787950077ac10000202f2f041306070000046d1e31b12104fd17000000000e787880048120004413c9040000426c9f2c840113c904000082016c9f2cd3013b9a0200c4016d0534a7218104fd280182046c9f2c840413c9040000c404131b00000084051300000000c405130000000084061300000000c406130000000084071300000000c407130000000084081300000000c408130000000084091300000000c4091300000000ffff|
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
Copyright (C) 2020-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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include"meters_common_implementation.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Driver : public virtual MeterCommonImplementation
|
||||
{
|
||||
Driver(MeterInfo &mi, DriverInfo &di);
|
||||
|
||||
void processContent(Telegram *t);
|
||||
|
||||
double total_energy_kwh_ {};
|
||||
double curr_energy_kwh_ {};
|
||||
double prev_energy_kwh_ {};
|
||||
};
|
||||
|
||||
static bool ok = registerDriver([](DriverInfo&di)
|
||||
{
|
||||
di.setName("compact5");
|
||||
di.setDefaultFields("name,id,total_kwh,current_kwh,previous_kwh,timestamp");
|
||||
di.setMeterType(MeterType::WaterMeter);
|
||||
di.addLinkMode(LinkMode::T1);
|
||||
di.addLinkMode(LinkMode::C1);
|
||||
di.addDetection(MANUFACTURER_TCH, 0x04, 0x45);
|
||||
di.addDetection(MANUFACTURER_TCH, 0xc3, 0x45);
|
||||
di.addDetection(MANUFACTURER_TCH, 0x43, 0x22);
|
||||
di.addDetection(MANUFACTURER_TCH, 0x43, 0x45);
|
||||
di.addDetection(MANUFACTURER_TCH, 0x43, 0x39);
|
||||
|
||||
di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr<Meter>(new Driver(mi, di)); });
|
||||
});
|
||||
|
||||
Driver::Driver(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di)
|
||||
{
|
||||
addPrint("total", Quantity::Energy,
|
||||
[&](Unit u){ return convert(total_energy_kwh_, Unit::KWH, u); },
|
||||
"The total energy consumption recorded by this meter.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("current", Quantity::Energy,
|
||||
[&](Unit u){ return convert(curr_energy_kwh_, Unit::KWH, u); },
|
||||
"Energy consumption so far in this billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("previous", Quantity::Energy,
|
||||
[&](Unit u){ return convert(prev_energy_kwh_, Unit::KWH, u); },
|
||||
"Energy consumption in previous billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
}
|
||||
|
||||
void Driver::processContent(Telegram *t)
|
||||
{
|
||||
// Unfortunately, the Techem Compact V is mostly a proprieatary protocol
|
||||
// simple wrapped inside a wmbus telegram since the ci-field is 0xa2.
|
||||
// Which means that the entire payload is manufacturer specific.
|
||||
|
||||
map<string,pair<int,DVEntry>> vendor_values;
|
||||
vector<uchar> content;
|
||||
|
||||
t->extractPayload(&content);
|
||||
|
||||
if (content.size() < 9) return;
|
||||
|
||||
uchar prev_lo = content[3];
|
||||
uchar prev_hi = content[4];
|
||||
double prev = (256.0*prev_hi+prev_lo);
|
||||
|
||||
string prevs;
|
||||
strprintf(prevs, "%02x%02x", prev_lo, prev_hi);
|
||||
int offset = t->parsed.size()+3;
|
||||
vendor_values["0215"] = { offset, DVEntry(offset, DifVifKey("0215"), MeasurementType::Instantaneous, 0x15, {}, 0, 0, 0, prevs) };
|
||||
Explanation pe(offset, 2, prevs, KindOfData::CONTENT, Understanding::FULL);
|
||||
t->explanations.push_back(pe);
|
||||
t->addMoreExplanation(offset, " energy used in previous billing period (%f KWH)", prev);
|
||||
|
||||
uchar curr_lo = content[7];
|
||||
uchar curr_hi = content[8];
|
||||
double curr = (256.0*curr_hi+curr_lo);
|
||||
|
||||
string currs;
|
||||
strprintf(currs, "%02x%02x", curr_lo, curr_hi);
|
||||
offset = t->parsed.size()+7;
|
||||
vendor_values["0215"] = { offset, DVEntry(offset, DifVifKey("0215"), MeasurementType::Instantaneous, 0x15, {}, 0, 0, 0, currs) };
|
||||
Explanation ce(offset, 2, currs, KindOfData::CONTENT, Understanding::FULL);
|
||||
t->explanations.push_back(ce);
|
||||
t->addMoreExplanation(offset, " energy used in current billing period (%f KWH)", curr);
|
||||
|
||||
total_energy_kwh_ = prev+curr;
|
||||
curr_energy_kwh_ = curr;
|
||||
prev_energy_kwh_ = prev;
|
||||
}
|
||||
}
|
||||
|
||||
// Test: Heating compact5 62626262 NOKEY
|
||||
// telegram=|36446850626262624543A1_009F2777010060780000000A000000000000000000000000000000000000000000000000A0400000B4010000|
|
||||
// {"media":"heat","meter":"compact5","name":"Heating","id":"62626262","total_kwh":495,"current_kwh":120,"previous_kwh":375,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
// |Heating;62626262;495;120;375;1111-11-11 11:11.11
|
||||
|
||||
// Test: Heating2 compact5 66336633 NOKEY
|
||||
// telegram=|37446850336633663943a2_10672c866100181c01000480794435d50000000000000000000000000000000000000000000000000000000000|
|
||||
// {"media":"heat","meter":"compact5","name":"Heating2","id":"66336633","total_kwh":25250,"current_kwh":284,"previous_kwh":24966,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
// |Heating2;66336633;25250;284;24966;1111-11-11 11:11.11
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2020 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include"dvparser.h"
|
||||
#include"meters.h"
|
||||
#include"meters_common_implementation.h"
|
||||
#include"wmbus.h"
|
||||
#include"wmbus_utils.h"
|
||||
#include"units.h"
|
||||
#include"util.h"
|
||||
|
||||
struct MeterCompact5 : public virtual MeterCommonImplementation
|
||||
{
|
||||
MeterCompact5(MeterInfo &mi);
|
||||
|
||||
double totalEnergyConsumption(Unit u);
|
||||
double currentPeriodEnergyConsumption(Unit u);
|
||||
double previousPeriodEnergyConsumption(Unit u);
|
||||
|
||||
private:
|
||||
|
||||
void processContent(Telegram *t);
|
||||
|
||||
double total_energy_kwh_ {};
|
||||
double curr_energy_kwh_ {};
|
||||
double prev_energy_kwh_ {};
|
||||
};
|
||||
|
||||
shared_ptr<Meter> createCompact5(MeterInfo &mi)
|
||||
{
|
||||
return shared_ptr<Meter>(new MeterCompact5(mi));
|
||||
}
|
||||
|
||||
MeterCompact5::MeterCompact5(MeterInfo &mi) :
|
||||
MeterCommonImplementation(mi, "compact5")
|
||||
{
|
||||
setMeterType(MeterType::HeatMeter);
|
||||
|
||||
// media 0x04 is used for C telegrams
|
||||
// media 0xC3 is used for T telegrams
|
||||
|
||||
addLinkMode(LinkMode::C1);
|
||||
addLinkMode(LinkMode::T1);
|
||||
|
||||
addPrint("total", Quantity::Energy,
|
||||
[&](Unit u){ return totalEnergyConsumption(u); },
|
||||
"The total energy consumption recorded by this meter.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("current", Quantity::Energy,
|
||||
[&](Unit u){ return currentPeriodEnergyConsumption(u); },
|
||||
"Energy consumption so far in this billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("previous", Quantity::Energy,
|
||||
[&](Unit u){ return previousPeriodEnergyConsumption(u); },
|
||||
"Energy consumption in previous billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
}
|
||||
|
||||
double MeterCompact5::totalEnergyConsumption(Unit u)
|
||||
{
|
||||
assertQuantity(u, Quantity::Energy);
|
||||
return convert(total_energy_kwh_, Unit::KWH, u);
|
||||
}
|
||||
|
||||
double MeterCompact5::currentPeriodEnergyConsumption(Unit u)
|
||||
{
|
||||
assertQuantity(u, Quantity::Energy);
|
||||
return convert(curr_energy_kwh_, Unit::KWH, u);
|
||||
}
|
||||
|
||||
double MeterCompact5::previousPeriodEnergyConsumption(Unit u)
|
||||
{
|
||||
assertQuantity(u, Quantity::Energy);
|
||||
return convert(prev_energy_kwh_, Unit::KWH, u);
|
||||
}
|
||||
|
||||
void MeterCompact5::processContent(Telegram *t)
|
||||
{
|
||||
// Unfortunately, the Techem Compact V is mostly a proprieatary protocol
|
||||
// simple wrapped inside a wmbus telegram since the ci-field is 0xa2.
|
||||
// Which means that the entire payload is manufacturer specific.
|
||||
|
||||
map<string,pair<int,DVEntry>> vendor_values;
|
||||
vector<uchar> content;
|
||||
|
||||
t->extractPayload(&content);
|
||||
|
||||
if (content.size() < 9) return;
|
||||
|
||||
uchar prev_lo = content[3];
|
||||
uchar prev_hi = content[4];
|
||||
double prev = (256.0*prev_hi+prev_lo);
|
||||
|
||||
string prevs;
|
||||
strprintf(prevs, "%02x%02x", prev_lo, prev_hi);
|
||||
int offset = t->parsed.size()+3;
|
||||
vendor_values["0215"] = { offset, DVEntry(offset, DifVifKey("0215"), MeasurementType::Instantaneous, 0x15, {}, 0, 0, 0, prevs) };
|
||||
Explanation pe(offset, 2, prevs, KindOfData::CONTENT, Understanding::FULL);
|
||||
t->explanations.push_back(pe);
|
||||
t->addMoreExplanation(offset, " energy used in previous billing period (%f KWH)", prev);
|
||||
|
||||
uchar curr_lo = content[7];
|
||||
uchar curr_hi = content[8];
|
||||
double curr = (256.0*curr_hi+curr_lo);
|
||||
|
||||
string currs;
|
||||
strprintf(currs, "%02x%02x", curr_lo, curr_hi);
|
||||
offset = t->parsed.size()+7;
|
||||
vendor_values["0215"] = { offset, DVEntry(offset, DifVifKey("0215"), MeasurementType::Instantaneous, 0x15, {}, 0, 0, 0, currs) };
|
||||
Explanation ce(offset, 2, currs, KindOfData::CONTENT, Understanding::FULL);
|
||||
t->explanations.push_back(ce);
|
||||
t->addMoreExplanation(offset, " energy used in current billing period (%f KWH)", curr);
|
||||
|
||||
total_energy_kwh_ = prev+curr;
|
||||
curr_energy_kwh_ = curr;
|
||||
prev_energy_kwh_ = prev;
|
||||
}
|
|
@ -28,11 +28,6 @@
|
|||
//
|
||||
#define METER_DETECTION \
|
||||
X(CCx01, MANUFACTURER_GSS, 0x02, 0x01) \
|
||||
X(COMPACT5, MANUFACTURER_TCH, 0x04, 0x45) \
|
||||
X(COMPACT5, MANUFACTURER_TCH, 0xc3, 0x45) \
|
||||
X(COMPACT5, MANUFACTURER_TCH, 0x43, 0x22) \
|
||||
X(COMPACT5, MANUFACTURER_TCH, 0x43, 0x45) \
|
||||
X(COMPACT5, MANUFACTURER_TCH, 0x43, 0x39) \
|
||||
X(DME_07, MANUFACTURER_DME, 0x07, 0x7b) \
|
||||
X(EBZWMBE, MANUFACTURER_EBZ, 0x37, 0x02) \
|
||||
X(EURISII, MANUFACTURER_INE, 0x08, 0x55) \
|
||||
|
|
|
@ -60,7 +60,6 @@ LIST_OF_METER_TYPES
|
|||
#define LIST_OF_METERS \
|
||||
X(auto, 0, AutoMeter, AUTO, Auto) \
|
||||
X(unknown, 0, UnknownMeter, UNKNOWN, Unknown) \
|
||||
X(compact5, T1_bit, HeatMeter, COMPACT5, Compact5) \
|
||||
X(dme_07, T1_bit, WaterMeter, DME_07, DME_07) \
|
||||
X(ebzwmbe, T1_bit, ElectricityMeter, EBZWMBE, EBZWMBE) \
|
||||
X(eurisii, T1_bit, HeatCostAllocationMeter, EURISII, EurisII) \
|
||||
|
|
Ładowanie…
Reference in New Issue