kopia lustrzana https://github.com/weetmuts/wmbusmeters
Merge pull request #24 from FeatureExpert/master
Initial support for Techem Vario 4 heat meterspull/31/head
commit
19a0b1509a
1
Makefile
1
Makefile
|
@ -99,6 +99,7 @@ METER_OBJS:=\
|
|||
$(BUILD)/meter_apator162.o \
|
||||
$(BUILD)/meter_amiplus.o \
|
||||
$(BUILD)/meter_mkradio3.o \
|
||||
$(BUILD)/meter_vario451.o \
|
||||
$(BUILD)/printer.o \
|
||||
$(BUILD)/serial.o \
|
||||
$(BUILD)/shell.o \
|
||||
|
|
|
@ -134,6 +134,7 @@ Tauron Amiplus (amiplus) (includes vendor apator and echelon)
|
|||
Work in progress:
|
||||
Heat meter Kamstrup Multical 302 (multical302)
|
||||
Electricity meter Kamstrup Omnipower (omnipower)
|
||||
Techem Vario 4 Typ 4.5.1 (vario451)
|
||||
```
|
||||
|
||||
The wmbus dongles imst871a and amb8465 can only listen on one type of wmbus telegrams at a time.
|
||||
|
|
|
@ -30,3 +30,7 @@ telegram=|4E4401061010101002027A00004005|2F2F0E035040691500000B2B300300066D00790
|
|||
|
||||
telegram=|2F446850313233347462A2|069F255900B029310000000306060906030609070606050509050505050407040605070500|
|
||||
{"media":"warm water","meter":"mkradio3","name":"Duschen","id":"34333231","total_m3":13.800000,"target_m3":8.900000,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
|
||||
# Test vario451 T1 telegrams
|
||||
telegram=|374468506549235827C3A2|129F25383300A8622600008200800A2AF862115175552877A36F26C9AB1CB24400000004000000000004908002|
|
||||
{"media":"heat","meter":"vario451","name":"HeatMeter","id":"58234965","total_gj":22.938000,"current_gj":9.826000,"previous_gj":13.112000,"timestamp":"2019-05-01T15:06:31Z"}
|
||||
|
|
|
@ -291,6 +291,10 @@ void startUsingCommandline(Configuration *config)
|
|||
meters.push_back(createMultical302(wmbus.get(), m.name, m.id, m.key));
|
||||
verbose("(multical302) configured \"%s\" \"multical302\" \"%s\" %s\n", m.name.c_str(), m.id.c_str(), keymsg);
|
||||
break;
|
||||
case VARIO451_METER:
|
||||
meters.push_back(createVario451(wmbus.get(), m.name, m.id, m.key));
|
||||
verbose("(vario451) configured \"%s\" \"vario451\" \"%s\" %s\n", m.name.c_str(), m.id.c_str(), keymsg);
|
||||
break;
|
||||
case OMNIPOWER_METER:
|
||||
meters.push_back(createOmnipower(wmbus.get(), m.name, m.id, m.key));
|
||||
verbose("(omnipower) configured \"%s\" \"omnipower\" \"%s\" %s\n", m.name.c_str(), m.id.c_str(), keymsg);
|
||||
|
|
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
Copyright (C) 2018-2019 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"
|
||||
|
||||
#include<memory.h>
|
||||
#include<stdio.h>
|
||||
#include<string>
|
||||
#include<time.h>
|
||||
#include<vector>
|
||||
|
||||
struct MeterVario451 : public virtual TechemHeatMeter, public virtual MeterCommonImplementation {
|
||||
MeterVario451(WMBus *bus, string& name, string& id, string& key);
|
||||
|
||||
double totalEnergyConsumption();
|
||||
double currentEnergyConsumption();
|
||||
double previousEnergyConsumption();
|
||||
|
||||
void printMeter(Telegram *t,
|
||||
string *human_readable,
|
||||
string *fields, char separator,
|
||||
string *json,
|
||||
vector<string> *envs);
|
||||
|
||||
private:
|
||||
void handleTelegram(Telegram *t);
|
||||
void processContent(Telegram *t);
|
||||
|
||||
double total_energy_ {};
|
||||
double curr_energy_ {};
|
||||
double prev_energy_ {};
|
||||
};
|
||||
|
||||
MeterVario451::MeterVario451(WMBus *bus, string& name, string& id, string& key) :
|
||||
MeterCommonImplementation(bus, name, id, key, VARIO451_METER, MANUFACTURER_TCH, LinkMode::T1)
|
||||
{
|
||||
addMedia(0x04); // C telegrams
|
||||
addMedia(0xC3); // T telegrams
|
||||
MeterCommonImplementation::bus()->onTelegram(calll(this,handleTelegram,Telegram*));
|
||||
}
|
||||
|
||||
double MeterVario451::totalEnergyConsumption()
|
||||
{
|
||||
return total_energy_;
|
||||
}
|
||||
|
||||
double MeterVario451::currentEnergyConsumption()
|
||||
{
|
||||
return curr_energy_;
|
||||
}
|
||||
|
||||
double MeterVario451::previousEnergyConsumption()
|
||||
{
|
||||
return prev_energy_;
|
||||
}
|
||||
|
||||
|
||||
void MeterVario451::handleTelegram(Telegram *t) {
|
||||
|
||||
if (!isTelegramForMe(t)) {
|
||||
// This telegram is not intended for this meter.
|
||||
return;
|
||||
}
|
||||
|
||||
verbose("(vario451) %s %02x%02x%02x%02x ",
|
||||
name().c_str(),
|
||||
t->a_field_address[0], t->a_field_address[1], t->a_field_address[2],
|
||||
t->a_field_address[3]);
|
||||
|
||||
if (t->isEncrypted() && !useAes() && !t->isSimulated()) {
|
||||
|
||||
// This is ugly but I have no idea how to do this proper way :/
|
||||
// Techem Vario 4 Typ 4.5.1 sends T and also encrypted C telegrams
|
||||
// We are intrested in T only (for now)
|
||||
|
||||
//warning("(vario451) warning: telegram is encrypted but no key supplied!\n");
|
||||
return;
|
||||
}
|
||||
if (useAes()) {
|
||||
vector<uchar> aeskey = key();
|
||||
decryptMode1_AES_CTR(t, aeskey);
|
||||
} else {
|
||||
t->content = t->payload;
|
||||
}
|
||||
logTelegram("(vario451) log", t->parsed, t->content);
|
||||
int content_start = t->parsed.size();
|
||||
processContent(t);
|
||||
if (isDebugEnabled()) {
|
||||
t->explainParse("(vario451)", content_start);
|
||||
}
|
||||
triggerUpdate(t);
|
||||
}
|
||||
|
||||
void MeterVario451::processContent(Telegram *t) {
|
||||
map<string,pair<int,DVEntry>> vendor_values;
|
||||
|
||||
// Unfortunately, the Techem Vario 4 Typ 4.5.1 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.
|
||||
|
||||
uchar prev_lo = t->content[3];
|
||||
uchar prev_hi = t->content[4];
|
||||
double prev = (256.0*prev_hi+prev_lo)/1000;
|
||||
|
||||
string prevs;
|
||||
strprintf(prevs, "%02x%02x", prev_lo, prev_hi);
|
||||
int offset = t->parsed.size()+3;
|
||||
vendor_values["0215"] = { offset, DVEntry(0x15, 0, 0, 0, prevs) };
|
||||
t->explanations.push_back({ offset, prevs });
|
||||
t->addMoreExplanation(offset, " energy used in previous billing period (%f GJ)", prev);
|
||||
|
||||
uchar curr_lo = t->content[7];
|
||||
uchar curr_hi = t->content[8];
|
||||
double curr = (256.0*curr_hi+curr_lo)/1000;
|
||||
|
||||
string currs;
|
||||
strprintf(currs, "%02x%02x", curr_lo, curr_hi);
|
||||
offset = t->parsed.size()+7;
|
||||
vendor_values["0215"] = { offset, DVEntry(0x15, 0, 0, 0, currs) };
|
||||
t->explanations.push_back({ offset, currs });
|
||||
t->addMoreExplanation(offset, " energy used in current billing period (%f GJ)", curr);
|
||||
|
||||
total_energy_ = prev+curr;
|
||||
curr_energy_ = curr;
|
||||
prev_energy_ = prev;
|
||||
}
|
||||
|
||||
unique_ptr<TechemHeatMeter> createVario451(WMBus *bus, string& name, string& id, string& key) {
|
||||
return unique_ptr<TechemHeatMeter>(new MeterVario451(bus,name,id,key));
|
||||
}
|
||||
|
||||
void MeterVario451::printMeter(Telegram *t,
|
||||
string *human_readable,
|
||||
string *fields, char separator,
|
||||
string *json,
|
||||
vector<string> *envs)
|
||||
{
|
||||
char buf[65536];
|
||||
buf[65535] = 0;
|
||||
|
||||
snprintf(buf, sizeof(buf)-1,
|
||||
"%s\t"
|
||||
"%s\t"
|
||||
"% 3.3f GJ\t"
|
||||
"% 3.3f GJ\t"
|
||||
"% 3.3f GJ\t%s",
|
||||
name().c_str(),
|
||||
t->id.c_str(),
|
||||
totalEnergyConsumption(),
|
||||
currentEnergyConsumption(),
|
||||
previousEnergyConsumption(),
|
||||
datetimeOfUpdateHumanReadable().c_str());
|
||||
|
||||
*human_readable = buf;
|
||||
|
||||
snprintf(buf, sizeof(buf)-1,
|
||||
"%s%c"
|
||||
"%s%c"
|
||||
"%f%c"
|
||||
"%f%c"
|
||||
"%f%c"
|
||||
"%s",
|
||||
name().c_str(), separator,
|
||||
t->id.c_str(), separator,
|
||||
totalEnergyConsumption(), separator,
|
||||
currentEnergyConsumption(), separator,
|
||||
previousEnergyConsumption(), separator,
|
||||
datetimeOfUpdateRobot().c_str());
|
||||
|
||||
*fields = buf;
|
||||
|
||||
#define Q(x,y) "\""#x"\":"#y","
|
||||
#define QS(x,y) "\""#x"\":\""#y"\","
|
||||
#define QSE(x,y) "\""#x"\":\""#y"\""
|
||||
|
||||
snprintf(buf, sizeof(buf)-1, "{"
|
||||
QS(media,heat)
|
||||
QS(meter,vario451)
|
||||
QS(name,%s)
|
||||
QS(id,%s)
|
||||
Q(total_gj,%f)
|
||||
Q(current_gj,%f)
|
||||
Q(previous_gj,%f)
|
||||
QSE(timestamp,%s)
|
||||
"}",
|
||||
name().c_str(),
|
||||
t->id.c_str(),
|
||||
totalEnergyConsumption(),
|
||||
currentEnergyConsumption(),
|
||||
previousEnergyConsumption(),
|
||||
datetimeOfUpdateRobot().c_str());
|
||||
|
||||
*json = buf;
|
||||
|
||||
envs->push_back(string("METER_JSON=")+*json);
|
||||
envs->push_back(string("METER_TYPE=vario451"));
|
||||
envs->push_back(string("METER_ID=")+t->id);
|
||||
envs->push_back(string("METER_TOTAL_GJ=")+to_string(totalEnergyConsumption()));
|
||||
envs->push_back(string("METER_CURRENT_GJ=")+to_string(currentEnergyConsumption()));
|
||||
envs->push_back(string("METER_PREVIOUS_GJ=")+to_string(previousEnergyConsumption()));
|
||||
envs->push_back(string("METER_TIMESTAMP=")+datetimeOfUpdateRobot());
|
||||
}
|
|
@ -117,6 +117,7 @@ MeterType toMeterType(string& type)
|
|||
if (type == "qcaloric") return QCALORIC_METER;
|
||||
if (type == "apator162") return APATOR162_METER;
|
||||
if (type == "mkradio3") return MKRADIO3_METER;
|
||||
if (type == "vario451") return VARIO451_METER;
|
||||
return UNKNOWN_METER;
|
||||
}
|
||||
|
||||
|
@ -132,7 +133,7 @@ LinkMode toMeterLinkMode(string& type)
|
|||
if (type == "qcaloric") return LinkMode::C1;
|
||||
if (type == "apator162") return LinkMode::T1;
|
||||
if (type == "mkradio3") return LinkMode::T1;
|
||||
|
||||
if (type == "vario451") return LinkMode::T1;
|
||||
return LinkMode::UNKNOWN;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include<string>
|
||||
#include<vector>
|
||||
|
||||
#define LIST_OF_METERS X(MULTICAL21_METER)X(FLOWIQ3100_METER)X(MULTICAL302_METER)X(OMNIPOWER_METER)X(SUPERCOM587_METER)X(IPERL_METER)X(QCALORIC_METER)X(APATOR162_METER)X(AMIPLUS_METER)X(MKRADIO3_METER)X(UNKNOWN_METER)
|
||||
#define LIST_OF_METERS X(MULTICAL21_METER)X(FLOWIQ3100_METER)X(MULTICAL302_METER)X(OMNIPOWER_METER)X(SUPERCOM587_METER)X(IPERL_METER)X(QCALORIC_METER)X(APATOR162_METER)X(AMIPLUS_METER)X(MKRADIO3_METER)X(VARIO451_METER)X(UNKNOWN_METER)
|
||||
|
||||
enum MeterType {
|
||||
#define X(name) name,
|
||||
|
@ -94,6 +94,12 @@ struct HeatMeter : public virtual Meter {
|
|||
virtual double totalVolume() = 0; // m3
|
||||
};
|
||||
|
||||
struct TechemHeatMeter : public virtual Meter {
|
||||
virtual double totalEnergyConsumption() = 0; // GJ
|
||||
virtual double currentEnergyConsumption() = 0; // GJ
|
||||
virtual double previousEnergyConsumption() = 0; // GJ
|
||||
};
|
||||
|
||||
struct ElectricityMeter : public virtual Meter {
|
||||
virtual double totalEnergyConsumption() = 0; // kwh
|
||||
virtual double currentPowerConsumption() = 0; // kw
|
||||
|
@ -115,6 +121,7 @@ LinkMode toMeterLinkMode(string& type);
|
|||
unique_ptr<WaterMeter> createMultical21(WMBus *bus, string& name, string& id, string& key);
|
||||
unique_ptr<WaterMeter> createFlowIQ3100(WMBus *bus, string& name, string& id, string& key);
|
||||
unique_ptr<HeatMeter> createMultical302(WMBus *bus, string& name, string& id, string& key);
|
||||
unique_ptr<TechemHeatMeter> createVario451(WMBus *bus, string& name, string& id, string& key);
|
||||
unique_ptr<ElectricityMeter> createOmnipower(WMBus *bus, string& name, string& id, string& key);
|
||||
unique_ptr<ElectricityMeter> createAmiplus(WMBus *bus, string& name, string& id, string& key);
|
||||
unique_ptr<WaterMeter> createSupercom587(WMBus *bus, string& name, string& id, string& key);
|
||||
|
|
11
src/wmbus.cc
11
src/wmbus.cc
|
@ -202,6 +202,10 @@ string mediaType(int a_field_device_type) {
|
|||
// Techem MK Radio 3 manufacturer specific.
|
||||
case 0x62: return "Warm water"; // MKRadio3
|
||||
case 0x72: return "Cold water"; // MKRadio3
|
||||
|
||||
// Techem Vario 4 Typ 4.5.1 manufacturer specific.
|
||||
case 0xC3: return "Heat meter";
|
||||
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
@ -271,6 +275,10 @@ string mediaTypeJSON(int a_field_device_type)
|
|||
// Techem MK Radio 3 manufacturer specific codes:
|
||||
case 0x62: return "warm water";
|
||||
case 0x72: return "cold water";
|
||||
|
||||
// Techem Vario 4 Typ 4.5.1 manufacturer specific codes:
|
||||
case 0xC3: return "heat";
|
||||
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
@ -524,7 +532,8 @@ void Telegram::parse(vector<uchar> &frame)
|
|||
}
|
||||
else
|
||||
{
|
||||
warning("Unknown ci-field %02x\n", ci_field);
|
||||
// Removed because it logs warning for every telegram, even if not 'for me'
|
||||
//warning("Unknown ci-field %02x\n", ci_field);
|
||||
}
|
||||
|
||||
payload.clear();
|
||||
|
|
Ładowanie…
Reference in New Issue