Merge pull request #186 from cinemarene/master

Add new Techem water meter MKRadio4
pull/187/head
Fredrik Öhrström 2020-11-25 10:54:13 +01:00 zatwierdzone przez GitHub
commit fe2f6e87e1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 139 dodań i 7 usunięć

Wyświetl plik

@ -135,6 +135,7 @@ METER_OBJS:=\
$(BUILD)/meter_lansenth.o \
$(BUILD)/meter_lansenpu.o \
$(BUILD)/meter_mkradio3.o \
$(BUILD)/meter_mkradio4.o \
$(BUILD)/meter_multical21.o \
$(BUILD)/meter_multical302.o \
$(BUILD)/meter_multical403.o \

Wyświetl plik

@ -38,6 +38,12 @@ telegram=|2F446850313233347462A2|069F255900B029310000000306060906030609070606050
{"media":"warm water","meter":"mkradio3","name":"Duschen","id":"34333231","total_m3":13.8,"target_m3":8.9,"timestamp":"1111-11-11T11:11:11Z"}
|Duschen;34333231;13.800000;8.900000;1111-11-11 11:11.11
# Test MKRadio4 T1 telegrams
telegram=|2F446850200141029562A2|06702901006017030004000300000000000000000000000000000000000000000000000000|
{"media":"warm water","meter":"mkradio4","name":"Duschen","id":"02410120","total_m3":0.4,"target_m3":0.1,"timestamp":"1111-11-11T11:11:11Z"}
|Duschen;02410120;0.400000;0.100000;1111-11-11 11:11.11
# Test vario451 T1 telegrams
telegram=|374468506549235827C3A2|129F25383300A8622600008200800A2AF862115175552877A36F26C9AB1CB24400000004000000000004908002|
{"media":"heat","meter":"vario451","name":"HeatMeter","id":"58234965","total_kwh":6371.666667,"current_kwh":2729.444444,"previous_kwh":3642.222222,"timestamp":"1111-11-11T11:11:11Z"}

Wyświetl plik

@ -0,0 +1,122 @@
/*
Copyright (C) 2019-2020 Fredrik Öhrström
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"util.h"
using namespace std;
struct MKRadio4 : public virtual WaterMeter, public virtual MeterCommonImplementation
{
MKRadio4(MeterInfo &mi);
double totalWaterConsumption(Unit u);
bool hasTotalWaterConsumption();
double targetWaterConsumption(Unit u);
bool hasTargetWaterConsumption();
private:
void processContent(Telegram *t);
double total_water_consumption_m3_ {};
double target_water_consumption_m3_ {};
};
MKRadio4::MKRadio4(MeterInfo &mi) :
MeterCommonImplementation(mi, MeterType::MKRADIO4)
{
setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
addLinkMode(LinkMode::T1);
addPrint("total", Quantity::Volume,
[&](Unit u){ return totalWaterConsumption(u); },
"The total water consumption recorded by this meter.",
true, true);
addPrint("target", Quantity::Volume,
[&](Unit u){ return targetWaterConsumption(u); },
"The total water consumption recorded at the beginning of this month.",
true, true);
}
shared_ptr<WaterMeter> createMKRadio4(MeterInfo &mi)
{
return shared_ptr<WaterMeter>(new MKRadio4(mi));
}
void MKRadio4::processContent(Telegram *t)
{
// Unfortunately, the MK Radio 4 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);
uchar prev_lo = content[3];
uchar prev_hi = content[4];
double prev = (256.0*prev_hi+prev_lo)/10.0;
string prevs;
strprintf(prevs, "%02x%02x", prev_lo, prev_hi);
int offset = t->parsed.size()+3;
vendor_values["0215"] = { offset, DVEntry(MeasurementType::Instantaneous, 0x15, 0, 0, 0, prevs) };
t->explanations.push_back({ offset, prevs });
t->addMoreExplanation(offset, " prev consumption (%f m3)", prev);
uchar curr_lo = content[7];
uchar curr_hi = content[8];
double curr = (256.0*curr_hi+curr_lo)/10.0;
string currs;
strprintf(currs, "%02x%02x", curr_lo, curr_hi);
offset = t->parsed.size()+7;
vendor_values["0215"] = { offset, DVEntry(MeasurementType::Instantaneous, 0x15, 0, 0, 0, currs) };
t->explanations.push_back({ offset, currs });
t->addMoreExplanation(offset, " curr consumption (%f m3)", curr);
total_water_consumption_m3_ = prev+curr;
target_water_consumption_m3_ = prev;
}
double MKRadio4::totalWaterConsumption(Unit u)
{
assertQuantity(u, Quantity::Volume);
return convert(total_water_consumption_m3_, Unit::M3, u);
}
bool MKRadio4::hasTotalWaterConsumption()
{
return true;
}
double MKRadio4::targetWaterConsumption(Unit u)
{
return target_water_consumption_m3_;
}
bool MKRadio4::hasTargetWaterConsumption()
{
return true;
}

Wyświetl plik

@ -52,6 +52,7 @@
X(lansendw, T1_bit, DoorWindowDetector, LANSENDW, LansenDW) \
X(lansenpu, T1_bit, PulseCounter, LANSENPU, LansenPU) \
X(mkradio3, T1_bit, WaterMeter, MKRADIO3, MKRadio3) \
X(mkradio4, T1_bit, WaterMeter, MKRADIO4, MKRadio4) \
X(multical21, C1_bit|T1_bit, WaterMeter, MULTICAL21, Multical21) \
X(multical302,C1_bit, HeatMeter, MULTICAL302, Multical302) \
X(multical403,C1_bit, HeatMeter, MULTICAL403, Multical403) \
@ -124,6 +125,8 @@
X(LANSENPU, MANUFACTURER_LAS, 0x00, 0x0b) \
X(MKRADIO3, MANUFACTURER_TCH, 0x62, 0x74) \
X(MKRADIO3, MANUFACTURER_TCH, 0x72, 0x74) \
X(MKRADIO4, MANUFACTURER_TCH, 0x62, 0x95) \
X(MKRADIO4, MANUFACTURER_TCH, 0x72, 0x95) \
X(MULTICAL21, MANUFACTURER_KAM, 0x06, 0x1b) \
X(MULTICAL21, MANUFACTURER_KAM, 0x16, 0x1b) \
X(MULTICAL302,MANUFACTURER_KAM, 0x04, 0x30) \

Wyświetl plik

@ -439,9 +439,9 @@ string mediaType(int a_field_device_type) {
case 0x3E: return "Reserved for system devices";
case 0x3F: return "Reserved for system devices";
// Techem MK Radio 3 manufacturer specific.
case 0x62: return "Warm water"; // MKRadio3
case 0x72: return "Cold water"; // MKRadio3
// Techem MK Radio 3/4 manufacturer specific.
case 0x62: return "Warm water"; // MKRadio3/MKRadio4
case 0x72: return "Cold water"; // MKRadio3/MKRadio4
// Techem FHKV.
case 0x80: return "Heat Cost Allocator"; // FHKV data ii/iii
@ -515,12 +515,12 @@ string mediaTypeJSON(int a_field_device_type)
case 0x3E: return "reserved";
case 0x3F: return "reserved";
// Techem MK Radio 3 manufacturer specific codes:
case 0x62: return "warm water";
case 0x72: return "cold water";
// Techem MK Radio 3/4 manufacturer specific.
case 0x62: return "warm water"; // MKRadio3/MKRadio4
case 0x72: return "cold water"; // MKRadio3/MKRadio4
// Techem FHKV.
case 0x80: return "Heat Cost Allocator"; // FHKV data ii/iii
case 0x80: return "heat cost allocator"; // FHKV data ii/iii
// Techem Vario 4 Typ 4.5.1 manufacturer specific codes:
case 0xC3: return "heat";