kopia lustrzana https://github.com/weetmuts/wmbusmeters
Refactor fhkvdataiii and fhkvdataiv.
rodzic
e52c2ce3f6
commit
b4d99dcfb2
3
CHANGES
3
CHANGES
|
@ -1,4 +1,7 @@
|
|||
|
||||
ATTENTION! The fhkvdataiv driver has been refactored to the new driver format.
|
||||
The field consumption_at_set_date_17 was wrong and has been renamed to field consumption_at_set_date_8.
|
||||
|
||||
ATTENTION! Bug in historical data for sensostar driver. Only the most recent month was correct.
|
||||
|
||||
ATTENTION! The topaseskr driver has been refactored to the new driver format.
|
||||
|
|
|
@ -73,8 +73,8 @@ telegram=|33446850341211119480A2_0F9F292D005024040011BD0838090400000007000000000
|
|||
|
||||
# Test FHKV data IV
|
||||
telegram=|4E4468507620541494087AAD004005089D86B62A329B3439873999738F82461ABDE3C7AC78692B363F3B41EB68607F9C9160F550769B065B6EA00A2E44346E29FF5DC5CB86283C69324AD33D137F6F|
|
||||
{"media":"heat cost allocation","meter":"fhkvdataiv","name":"Rooom","id":"14542076","current_consumption_hca":2,"set_date":"2020-12-31","consumption_at_set_date_hca":25,"set_date_1":"2020-12-31","consumption_at_set_date_1_hca":25,"set_date_17":"2019-10-31","consumption_at_set_date_8_hca":0,"error_date":"","device_date_time":"","timestamp":"1111-11-11T11:11:11Z"}
|
||||
|Rooom;14542076;2.000000;2020-12-31;25.000000;1111-11-11 11:11.11
|
||||
{"media":"heat cost allocation","meter":"fhkvdataiv","name":"Rooom","id":"14542076","status":OK","current_consumption_hca":2,"set_date":"2020-12-31","consumption_at_set_date_hca":25,"set_date_1":"2020-12-31","consumption_at_set_date_1_hca":25,"set_date_8":"2019-10-31","consumption_at_set_date_8_hca":0,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
|Rooom;14542076;2;2020-12-31;25;1111-11-11 11:11.11
|
||||
|
||||
# Test EurisII T1 telegrams
|
||||
|
||||
|
|
|
@ -0,0 +1,239 @@
|
|||
/*
|
||||
Copyright (C) 2019-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 currentPeriodEnergyConsumption(Unit u);
|
||||
string currentPeriodDate();
|
||||
double previousPeriodEnergyConsumption(Unit u);
|
||||
string previousPeriodDate();
|
||||
double currentRoomTemperature(Unit u);
|
||||
double currentRadiatorTemperature(Unit u);
|
||||
|
||||
string leadingZeroString(int num);
|
||||
|
||||
double curr_energy_hca_ {};
|
||||
string curr_energy_hca_date {};
|
||||
double prev_energy_hca_ {};
|
||||
string prev_energy_hca_date {};
|
||||
double temp_room_ {};
|
||||
double temp_radiator_ {};
|
||||
};
|
||||
|
||||
static bool ok = registerDriver([](DriverInfo&di)
|
||||
{
|
||||
di.setName("fhkvdataiii");
|
||||
di.setMeterType(MeterType::HeatCostAllocationMeter);
|
||||
di.addLinkMode(LinkMode::T1);
|
||||
di.addDetection(MANUFACTURER_TCH, 0x80, 0x69);
|
||||
di.addDetection(MANUFACTURER_TCH, 0x80, 0x94);
|
||||
|
||||
di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr<Meter>(new Driver(mi, di)); });
|
||||
});
|
||||
|
||||
Driver::Driver(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di)
|
||||
{
|
||||
addPrint("current", Quantity::HCA,
|
||||
[&](Unit u){ return currentPeriodEnergyConsumption(u); },
|
||||
"Energy consumption so far in this billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("current_date", Quantity::Text,
|
||||
[&](){ return currentPeriodDate(); },
|
||||
"Date of current billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("previous", Quantity::HCA,
|
||||
[&](Unit u){ return previousPeriodEnergyConsumption(u); },
|
||||
"Energy consumption in previous billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("previous_date", Quantity::Text,
|
||||
[&](){ return previousPeriodDate(); },
|
||||
"Date of last billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("temp_room", Quantity::Temperature,
|
||||
[&](Unit u){ return currentRoomTemperature(u); },
|
||||
"Current room temperature.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("temp_radiator", Quantity::Temperature,
|
||||
[&](Unit u){ return currentRadiatorTemperature(u); },
|
||||
"Current radiator temperature.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
}
|
||||
|
||||
double Driver::currentPeriodEnergyConsumption(Unit u)
|
||||
{
|
||||
return curr_energy_hca_;
|
||||
}
|
||||
|
||||
string Driver::currentPeriodDate()
|
||||
{
|
||||
return curr_energy_hca_date;
|
||||
}
|
||||
|
||||
double Driver::previousPeriodEnergyConsumption(Unit u)
|
||||
{
|
||||
return prev_energy_hca_;
|
||||
}
|
||||
|
||||
string Driver::previousPeriodDate()
|
||||
{
|
||||
return prev_energy_hca_date;
|
||||
}
|
||||
|
||||
double Driver::currentRoomTemperature(Unit u)
|
||||
{
|
||||
assertQuantity(u, Quantity::Temperature);
|
||||
return convert(temp_room_, Unit::C, u);
|
||||
}
|
||||
|
||||
double Driver::currentRadiatorTemperature(Unit u)
|
||||
{
|
||||
assertQuantity(u, Quantity::Temperature);
|
||||
return convert(temp_radiator_, Unit::C, u);
|
||||
}
|
||||
|
||||
void Driver::processContent(Telegram *t)
|
||||
{
|
||||
// Unfortunately, the Techem FHKV data ii/iii is mostly a proprieatary protocol
|
||||
// simple wrapped inside a wmbus telegram since the ci-field is 0xa0.
|
||||
// Which means that the entire payload is manufacturer specific.
|
||||
|
||||
vector<uchar> content;
|
||||
|
||||
t->extractPayload(&content);
|
||||
|
||||
if (content.size() < 14)
|
||||
{
|
||||
// Not enough data.
|
||||
debugPayload("(fhkvdataiii) not enough data", content);
|
||||
return;
|
||||
}
|
||||
// Consumption
|
||||
// Previous Consumption
|
||||
uchar prev_lo = content[3];
|
||||
uchar prev_hi = content[4];
|
||||
double prev = (256.0*prev_hi+prev_lo);
|
||||
prev_energy_hca_ = prev;
|
||||
|
||||
string prevs;
|
||||
strprintf(&prevs, "%02x%02x", prev_lo, prev_hi);
|
||||
//t->addMoreExplanation(14, " energy used in previous billing period (%f HCA)", prevs);
|
||||
|
||||
// Previous Date
|
||||
uchar date_prev_lo = content[1];
|
||||
uchar date_prev_hi = content[2];
|
||||
int date_prev = (256.0*date_prev_hi+date_prev_lo);
|
||||
|
||||
int day_prev = (date_prev >> 0) & 0x1F;
|
||||
int month_prev = (date_prev >> 5) & 0x0F;
|
||||
int year_prev = (date_prev >> 9) & 0x3F;
|
||||
prev_energy_hca_date = std::to_string((year_prev + 2000)) + "-" + leadingZeroString(month_prev) + "-" + leadingZeroString(day_prev) + "T02:00:00Z";
|
||||
|
||||
//t->addMoreExplanation(offset, " last date of previous billing period (%s)", prev_energy_hca_date);
|
||||
|
||||
// Current Consumption
|
||||
uchar curr_lo = content[7];
|
||||
uchar curr_hi = content[8];
|
||||
double curr = (256.0*curr_hi+curr_lo);
|
||||
curr_energy_hca_ = curr;
|
||||
|
||||
string currs;
|
||||
strprintf(&currs, "%02x%02x", curr_lo, curr_hi);
|
||||
//t->addMoreExplanation(offset, " energy used in current billing period (%f HCA)", currs);
|
||||
|
||||
// Current Date
|
||||
uchar date_curr_lo = content[5];
|
||||
uchar date_curr_hi = content[6];
|
||||
int date_curr = (256.0*date_curr_hi+date_curr_lo);
|
||||
|
||||
time_t now = time(0);
|
||||
tm *ltm = localtime(&now);
|
||||
int year_curr = 1900 + ltm->tm_year;
|
||||
|
||||
int day_curr = (date_curr >> 4) & 0x1F;
|
||||
if (day_curr <= 0) day_curr = 1;
|
||||
int month_curr = (date_curr >> 9) & 0x0F;
|
||||
if (month_curr <= 0) month_curr = 12;
|
||||
curr_energy_hca_date = to_string(year_curr) + "-" + leadingZeroString(month_curr) + "-" + leadingZeroString(day_curr) + "T02:00:00Z";
|
||||
|
||||
// t->addMoreExplanation(offset, " last date of current billing period (%s)", curr_energy_hca_date);
|
||||
|
||||
// Temperature
|
||||
uchar room_tlo;
|
||||
uchar room_thi;
|
||||
uchar radiator_tlo;
|
||||
uchar radiator_thi;
|
||||
if(t->dll_version == 0x94)
|
||||
{
|
||||
room_tlo = content[10];
|
||||
room_thi = content[11];
|
||||
radiator_tlo = content[12];
|
||||
radiator_thi = content[13];
|
||||
} else
|
||||
{
|
||||
room_tlo = content[9];
|
||||
room_thi = content[10];
|
||||
radiator_tlo = content[11];
|
||||
radiator_thi = content[12];
|
||||
}
|
||||
|
||||
// Room Temperature
|
||||
double room_t = (256.0*room_thi+room_tlo)/100;
|
||||
temp_room_ = room_t;
|
||||
|
||||
string room_ts;
|
||||
strprintf(&room_ts, "%02x%02x", room_tlo, room_thi);
|
||||
// t->addMoreExplanation(offset, " current room temparature (%f °C)", room_ts);
|
||||
|
||||
// Radiator Temperature
|
||||
double radiator_t = (256.0*radiator_thi+radiator_tlo)/100;
|
||||
temp_radiator_ = radiator_t;
|
||||
|
||||
string radiator_ts;
|
||||
strprintf(&radiator_ts, "%02x%02x", radiator_tlo, radiator_thi);
|
||||
// t->addMoreExplanation(offset, " current radiator temparature (%f °C)", radiator_ts);
|
||||
}
|
||||
|
||||
string Driver::leadingZeroString(int num) {
|
||||
string new_num = (num < 10 ? "0": "") + std::to_string(num);
|
||||
return new_num;
|
||||
}
|
||||
}
|
||||
|
||||
// Test: Room fhkvdataiii 11776622 NOKEY
|
||||
// Comment: There is a problem in the decoding here, the data stored inside the telegram does not seem to properly encode/decode the year.... We should not report a current_date with a full year, if the year is actually not part of the telegram.
|
||||
// telegram=|31446850226677116980A0119F27020480048300C408F709143C003D341A2B0B2A0707000000000000062D114457563D71A1850000|
|
||||
// {"media":"heat cost allocator","meter":"fhkvdataiii","name":"Room","id":"11776622","current_hca":131,"current_date":"2022-02-08T02:00:00Z","previous_hca":1026,"previous_date":"2019-12-31T02:00:00Z","temp_room_c":22.44,"temp_radiator_c":25.51,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
// |Room;11776622;131.000000;2022-02-08T02:00:00Z;1026.000000;2019-12-31T02:00:00Z;22.440000;25.510000;1111-11-11 11:11.11
|
||||
|
||||
// Test: Rooom fhkvdataiii 11111234 NOKEY
|
||||
// Comment: FHKV radio 4 / EHKV vario 4 There is a problem in the decoding here, the data stored inside the telegram does not seem to properly encode/decode the year.... We should not report a current_date with a full year, if the year is actually not part of the telegram.
|
||||
// telegram=|33446850341211119480A2_0F9F292D005024040011BD08380904000000070000000000000000000000000001000000000003140E|
|
||||
// {"media":"heat cost allocator","meter":"fhkvdataiii","name":"Rooom","id":"11111234","current_hca":4,"current_date":"2022-02-05T02:00:00Z","previous_hca":45,"previous_date":"2020-12-31T02:00:00Z","temp_room_c":22.37,"temp_radiator_c":23.6,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
// |Rooom;11111234;4.000000;2022-02-05T02:00:00Z;45.000000;2020-12-31T02:00:00Z;22.370000;23.600000;1111-11-11 11:11.11
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
Copyright (C) 2019-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);
|
||||
};
|
||||
|
||||
static bool ok = registerDriver([](DriverInfo&di)
|
||||
{
|
||||
di.setName("fhkvdataiv");
|
||||
di.setDefaultFields("name,id,current_consumption_hca,set_date,consumption_at_set_date_hca,timestamp");
|
||||
di.setMeterType(MeterType::HeatCostAllocationMeter);
|
||||
di.addLinkMode(LinkMode::T1);
|
||||
di.addDetection(MANUFACTURER_TCH, 0x08, 0x69);
|
||||
di.addDetection(MANUFACTURER_TCH, 0x08, 0x94);
|
||||
|
||||
di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr<Meter>(new Driver(mi, di)); });
|
||||
});
|
||||
|
||||
Driver::Driver(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di)
|
||||
{
|
||||
addStringField(
|
||||
"status",
|
||||
"Meter status from tpl status field.",
|
||||
PrintProperty::JSON | PrintProperty::IMPORTANT |
|
||||
PrintProperty::STATUS | PrintProperty::JOIN_TPL_STATUS);
|
||||
|
||||
addNumericFieldWithExtractor(
|
||||
"current_consumption",
|
||||
"The current heat cost allocation.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON,
|
||||
Quantity::HCA,
|
||||
VifScaling::Auto,
|
||||
FieldMatcher::build()
|
||||
.set(MeasurementType::Instantaneous)
|
||||
);
|
||||
|
||||
addStringFieldWithExtractor(
|
||||
"set_date",
|
||||
"The most recent billing period date.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON,
|
||||
FieldMatcher::build()
|
||||
.set(MeasurementType::Instantaneous)
|
||||
.set(VIFRange::Date)
|
||||
.set(StorageNr(1)));
|
||||
|
||||
addNumericFieldWithExtractor(
|
||||
"consumption_at_set_date",
|
||||
"Heat cost allocation at the most recent billing period date.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON,
|
||||
Quantity::HCA,
|
||||
VifScaling::Auto,
|
||||
FieldMatcher::build()
|
||||
.set(MeasurementType::Instantaneous)
|
||||
.set(StorageNr(1))
|
||||
);
|
||||
|
||||
addStringFieldWithExtractor(
|
||||
"set_date_1",
|
||||
"The most recent billing period date.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON,
|
||||
FieldMatcher::build()
|
||||
.set(MeasurementType::Instantaneous)
|
||||
.set(VIFRange::Date)
|
||||
.set(StorageNr(1)));
|
||||
|
||||
addNumericFieldWithExtractor(
|
||||
"consumption_at_set_date_1",
|
||||
"Heat cost allocation at the most recent billing period date.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON,
|
||||
Quantity::HCA,
|
||||
VifScaling::Auto,
|
||||
FieldMatcher::build()
|
||||
.set(MeasurementType::Instantaneous)
|
||||
.set(StorageNr(1))
|
||||
);
|
||||
|
||||
addStringFieldWithExtractor(
|
||||
"set_date_8",
|
||||
"The 8 billing period date.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON,
|
||||
FieldMatcher::build()
|
||||
.set(MeasurementType::Instantaneous)
|
||||
.set(VIFRange::Date)
|
||||
.set(StorageNr(8)));
|
||||
|
||||
addNumericFieldWithExtractor(
|
||||
"consumption_at_set_date_8",
|
||||
"Heat cost allocation at the 8 billing period date.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON,
|
||||
Quantity::HCA,
|
||||
VifScaling::Auto,
|
||||
FieldMatcher::build()
|
||||
.set(MeasurementType::Instantaneous)
|
||||
.set(StorageNr(8))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Test: Rooom fhkvdataiv 14542076 FCF41938F63432975B52505F547FCEDF
|
||||
// telegram=|4E4468507620541494087AAD004005089D86B62A329B3439873999738F82461ABDE3C7AC78692B363F3B41EB68607F9C9160F550769B065B6EA00A2E44346E29FF5DC5CB86283C69324AD33D137F6F|
|
||||
// {"media":"heat cost allocation","meter":"fhkvdataiv","name":"Rooom","id":"14542076","status":"OK","current_consumption_hca":2,"set_date":"2020-12-31","consumption_at_set_date_hca":25,"set_date_1":"2020-12-31","consumption_at_set_date_1_hca":25,"set_date_8":"2019-10-31","consumption_at_set_date_8_hca":0,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
// |Rooom;14542076;2;2020-12-31;25;1111-11-11 11:11.11
|
|
@ -30,10 +30,6 @@
|
|||
X(CCx01, MANUFACTURER_GSS, 0x02, 0x01) \
|
||||
X(EURISII, MANUFACTURER_INE, 0x08, 0x55) \
|
||||
X(EVO868, MANUFACTURER_MAD, 0x07, 0x50) \
|
||||
X(FHKVDATAIII,MANUFACTURER_TCH, 0x80, 0x69) \
|
||||
X(FHKVDATAIII,MANUFACTURER_TCH, 0x80, 0x94) \
|
||||
X(FHKVDATAIV,MANUFACTURER_TCH, 0x08, 0x69) \
|
||||
X(FHKVDATAIV,MANUFACTURER_TCH, 0x08, 0x94) \
|
||||
X(HYDROCALM3,MANUFACTURER_BMT, 0x0d, 0x0b) \
|
||||
X(HYDRODIGIT,MANUFACTURER_BMT, 0x06, 0x13) \
|
||||
X(HYDRODIGIT,MANUFACTURER_BMT, 0x07, 0x13) \
|
||||
|
|
|
@ -1,234 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2019-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"
|
||||
#include <ctime>
|
||||
|
||||
struct MeterFHKVDataIII : public virtual MeterCommonImplementation
|
||||
{
|
||||
MeterFHKVDataIII(MeterInfo &mi);
|
||||
|
||||
double currentPeriodEnergyConsumption(Unit u);
|
||||
string currentPeriodDate();
|
||||
double previousPeriodEnergyConsumption(Unit u);
|
||||
string previousPeriodDate();
|
||||
double currentRoomTemperature(Unit u);
|
||||
double currentRadiatorTemperature(Unit u);
|
||||
|
||||
private:
|
||||
|
||||
void processContent(Telegram *t);
|
||||
|
||||
string leadingZeroString(int num);
|
||||
|
||||
double curr_energy_hca_ {};
|
||||
string curr_energy_hca_date {};
|
||||
double prev_energy_hca_ {};
|
||||
string prev_energy_hca_date {};
|
||||
double temp_room_ {};
|
||||
double temp_radiator_ {};
|
||||
};
|
||||
|
||||
shared_ptr<Meter> createFHKVDataIII(MeterInfo &mi)
|
||||
{
|
||||
return shared_ptr<Meter>(new MeterFHKVDataIII(mi));
|
||||
}
|
||||
|
||||
|
||||
MeterFHKVDataIII::MeterFHKVDataIII(MeterInfo &mi) :
|
||||
MeterCommonImplementation(mi, "fhkvdataiii")
|
||||
{
|
||||
setMeterType(MeterType::HeatCostAllocationMeter);
|
||||
|
||||
// media 0x80 T telegrams
|
||||
addLinkMode(LinkMode::T1);
|
||||
|
||||
addPrint("current", Quantity::HCA,
|
||||
[&](Unit u){ return currentPeriodEnergyConsumption(u); },
|
||||
"Energy consumption so far in this billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("current_date", Quantity::Text,
|
||||
[&](){ return currentPeriodDate(); },
|
||||
"Date of current billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("previous", Quantity::HCA,
|
||||
[&](Unit u){ return previousPeriodEnergyConsumption(u); },
|
||||
"Energy consumption in previous billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("previous_date", Quantity::Text,
|
||||
[&](){ return previousPeriodDate(); },
|
||||
"Date of last billing period.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("temp_room", Quantity::Temperature,
|
||||
[&](Unit u){ return currentRoomTemperature(u); },
|
||||
"Current room temperature.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("temp_radiator", Quantity::Temperature,
|
||||
[&](Unit u){ return currentRadiatorTemperature(u); },
|
||||
"Current radiator temperature.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
}
|
||||
|
||||
double MeterFHKVDataIII::currentPeriodEnergyConsumption(Unit u)
|
||||
{
|
||||
return curr_energy_hca_;
|
||||
}
|
||||
|
||||
string MeterFHKVDataIII::currentPeriodDate()
|
||||
{
|
||||
return curr_energy_hca_date;
|
||||
}
|
||||
|
||||
double MeterFHKVDataIII::previousPeriodEnergyConsumption(Unit u)
|
||||
{
|
||||
return prev_energy_hca_;
|
||||
}
|
||||
|
||||
string MeterFHKVDataIII::previousPeriodDate()
|
||||
{
|
||||
return prev_energy_hca_date;
|
||||
}
|
||||
|
||||
double MeterFHKVDataIII::currentRoomTemperature(Unit u)
|
||||
{
|
||||
assertQuantity(u, Quantity::Temperature);
|
||||
return convert(temp_room_, Unit::C, u);
|
||||
}
|
||||
|
||||
double MeterFHKVDataIII::currentRadiatorTemperature(Unit u)
|
||||
{
|
||||
assertQuantity(u, Quantity::Temperature);
|
||||
return convert(temp_radiator_, Unit::C, u);
|
||||
}
|
||||
|
||||
void MeterFHKVDataIII::processContent(Telegram *t)
|
||||
{
|
||||
// Unfortunately, the Techem FHKV data ii/iii is mostly a proprieatary protocol
|
||||
// simple wrapped inside a wmbus telegram since the ci-field is 0xa0.
|
||||
// Which means that the entire payload is manufacturer specific.
|
||||
|
||||
vector<uchar> content;
|
||||
|
||||
t->extractPayload(&content);
|
||||
|
||||
if (content.size() < 14)
|
||||
{
|
||||
// Not enough data.
|
||||
debugPayload("(fhkvdataiii) not enough data", content);
|
||||
return;
|
||||
}
|
||||
// Consumption
|
||||
// Previous Consumption
|
||||
uchar prev_lo = content[3];
|
||||
uchar prev_hi = content[4];
|
||||
double prev = (256.0*prev_hi+prev_lo);
|
||||
prev_energy_hca_ = prev;
|
||||
|
||||
string prevs;
|
||||
strprintf(&prevs, "%02x%02x", prev_lo, prev_hi);
|
||||
//t->addMoreExplanation(14, " energy used in previous billing period (%f HCA)", prevs);
|
||||
|
||||
// Previous Date
|
||||
uchar date_prev_lo = content[1];
|
||||
uchar date_prev_hi = content[2];
|
||||
int date_prev = (256.0*date_prev_hi+date_prev_lo);
|
||||
|
||||
int day_prev = (date_prev >> 0) & 0x1F;
|
||||
int month_prev = (date_prev >> 5) & 0x0F;
|
||||
int year_prev = (date_prev >> 9) & 0x3F;
|
||||
prev_energy_hca_date = std::to_string((year_prev + 2000)) + "-" + leadingZeroString(month_prev) + "-" + leadingZeroString(day_prev) + "T02:00:00Z";
|
||||
|
||||
//t->addMoreExplanation(offset, " last date of previous billing period (%s)", prev_energy_hca_date);
|
||||
|
||||
// Current Consumption
|
||||
uchar curr_lo = content[7];
|
||||
uchar curr_hi = content[8];
|
||||
double curr = (256.0*curr_hi+curr_lo);
|
||||
curr_energy_hca_ = curr;
|
||||
|
||||
string currs;
|
||||
strprintf(&currs, "%02x%02x", curr_lo, curr_hi);
|
||||
//t->addMoreExplanation(offset, " energy used in current billing period (%f HCA)", currs);
|
||||
|
||||
// Current Date
|
||||
uchar date_curr_lo = content[5];
|
||||
uchar date_curr_hi = content[6];
|
||||
int date_curr = (256.0*date_curr_hi+date_curr_lo);
|
||||
|
||||
time_t now = time(0);
|
||||
tm *ltm = localtime(&now);
|
||||
int year_curr = 1900 + ltm->tm_year;
|
||||
|
||||
int day_curr = (date_curr >> 4) & 0x1F;
|
||||
if (day_curr <= 0) day_curr = 1;
|
||||
int month_curr = (date_curr >> 9) & 0x0F;
|
||||
if (month_curr <= 0) month_curr = 12;
|
||||
curr_energy_hca_date = to_string(year_curr) + "-" + leadingZeroString(month_curr) + "-" + leadingZeroString(day_curr) + "T02:00:00Z";
|
||||
|
||||
// t->addMoreExplanation(offset, " last date of current billing period (%s)", curr_energy_hca_date);
|
||||
|
||||
// Temperature
|
||||
uchar room_tlo;
|
||||
uchar room_thi;
|
||||
uchar radiator_tlo;
|
||||
uchar radiator_thi;
|
||||
if(t->dll_version == 0x94)
|
||||
{
|
||||
room_tlo = content[10];
|
||||
room_thi = content[11];
|
||||
radiator_tlo = content[12];
|
||||
radiator_thi = content[13];
|
||||
} else
|
||||
{
|
||||
room_tlo = content[9];
|
||||
room_thi = content[10];
|
||||
radiator_tlo = content[11];
|
||||
radiator_thi = content[12];
|
||||
}
|
||||
|
||||
// Room Temperature
|
||||
double room_t = (256.0*room_thi+room_tlo)/100;
|
||||
temp_room_ = room_t;
|
||||
|
||||
string room_ts;
|
||||
strprintf(&room_ts, "%02x%02x", room_tlo, room_thi);
|
||||
// t->addMoreExplanation(offset, " current room temparature (%f °C)", room_ts);
|
||||
|
||||
// Radiator Temperature
|
||||
double radiator_t = (256.0*radiator_thi+radiator_tlo)/100;
|
||||
temp_radiator_ = radiator_t;
|
||||
|
||||
string radiator_ts;
|
||||
strprintf(&radiator_ts, "%02x%02x", radiator_tlo, radiator_thi);
|
||||
// t->addMoreExplanation(offset, " current radiator temparature (%f °C)", radiator_ts);
|
||||
}
|
||||
|
||||
string MeterFHKVDataIII::leadingZeroString(int num) {
|
||||
string new_num = (num < 10 ? "0": "") + std::to_string(num);
|
||||
return new_num;
|
||||
}
|
|
@ -1,208 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2019-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"
|
||||
|
||||
struct MeterFHKVDataIV : public virtual MeterCommonImplementation {
|
||||
MeterFHKVDataIV(MeterInfo &mi);
|
||||
|
||||
double currentConsumption(Unit u);
|
||||
string setDate();
|
||||
double consumptionAtSetDate(Unit u);
|
||||
|
||||
private:
|
||||
|
||||
void processContent(Telegram *t);
|
||||
|
||||
// Telegram type 1
|
||||
double current_consumption_hca_ {};
|
||||
string set_date_;
|
||||
double consumption_at_set_date_hca_ {};
|
||||
string set_date_8_;
|
||||
double consumption_at_set_date_8_hca_ {};
|
||||
string error_date_;
|
||||
|
||||
// Telegram type 2
|
||||
string vendor_proprietary_data_;
|
||||
string device_date_time_;
|
||||
};
|
||||
|
||||
MeterFHKVDataIV::MeterFHKVDataIV(MeterInfo &mi) :
|
||||
MeterCommonImplementation(mi, "fhkvdataiv")
|
||||
{
|
||||
setMeterType(MeterType::HeatCostAllocationMeter);
|
||||
|
||||
setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
|
||||
|
||||
addLinkMode(LinkMode::C1);
|
||||
|
||||
addPrint("current_consumption", Quantity::HCA,
|
||||
[&](Unit u){ return currentConsumption(u); },
|
||||
"The current heat cost allocation.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("set_date", Quantity::Text,
|
||||
[&](){ return setDate(); },
|
||||
"The most recent billing period date.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("consumption_at_set_date", Quantity::HCA,
|
||||
[&](Unit u){ return consumptionAtSetDate(u); },
|
||||
"Heat cost allocation at the most recent billing period date.",
|
||||
PrintProperty::FIELD | PrintProperty::JSON);
|
||||
|
||||
addPrint("set_date_1", Quantity::Text,
|
||||
[&](){ return setDate(); },
|
||||
"The 1 billing period date.",
|
||||
PrintProperty::JSON);
|
||||
|
||||
addPrint("consumption_at_set_date_1", Quantity::HCA,
|
||||
[&](Unit u){ return consumptionAtSetDate(u); },
|
||||
"Heat cost allocation at the 1 billing period date.",
|
||||
PrintProperty::JSON);
|
||||
|
||||
addPrint("set_date_17", Quantity::Text,
|
||||
[&](){ return set_date_8_; },
|
||||
"The 8 billing period date.",
|
||||
PrintProperty::JSON);
|
||||
|
||||
addPrint("consumption_at_set_date_8", Quantity::HCA,
|
||||
[&](Unit u){ return consumption_at_set_date_8_hca_; },
|
||||
"Heat cost allocation at the 8 billing period date.",
|
||||
PrintProperty::JSON);
|
||||
|
||||
addPrint("error_date", Quantity::Text,
|
||||
[&](){ return error_date_; },
|
||||
"Error date.",
|
||||
PrintProperty::JSON);
|
||||
|
||||
addPrint("device_date_time", Quantity::Text,
|
||||
[&](){ return device_date_time_; },
|
||||
"Device date time.",
|
||||
PrintProperty::JSON);
|
||||
}
|
||||
|
||||
shared_ptr<Meter> createFHKVDataIV(MeterInfo &mi)
|
||||
{
|
||||
return shared_ptr<Meter>(new MeterFHKVDataIV(mi));
|
||||
}
|
||||
|
||||
double MeterFHKVDataIV::currentConsumption(Unit u)
|
||||
{
|
||||
return current_consumption_hca_;
|
||||
}
|
||||
|
||||
string MeterFHKVDataIV::setDate()
|
||||
{
|
||||
return set_date_;
|
||||
}
|
||||
|
||||
double MeterFHKVDataIV::consumptionAtSetDate(Unit u)
|
||||
{
|
||||
return consumption_at_set_date_hca_;
|
||||
}
|
||||
|
||||
void MeterFHKVDataIV::processContent(Telegram *t)
|
||||
{
|
||||
/*
|
||||
(fhkvdataiv) 0f: 2f2f decrypt check bytes
|
||||
(fhkvdataiv) 11: 03 dif (24 Bit Integer/Binary Instantaneous value)
|
||||
(fhkvdataiv) 12: 6E vif (Units for H.C.A.)
|
||||
(fhkvdataiv) 13: * 020000 current consumption (2.000000 hca)
|
||||
(fhkvdataiv) 16: 43 dif (24 Bit Integer/Binary Instantaneous value storagenr=1)
|
||||
(fhkvdataiv) 17: 6E vif (Units for H.C.A.)
|
||||
(fhkvdataiv) 18: * 190000 consumption at set date (25.000000 hca)
|
||||
(fhkvdataiv) 1b: 42 dif (16 Bit Integer/Binary Instantaneous value storagenr=1)
|
||||
(fhkvdataiv) 1c: 6C vif (Date type G)
|
||||
(fhkvdataiv) 1d: * 9F2C set date (2020-12-31)
|
||||
(fhkvdataiv) 1f: 83 dif (24 Bit Integer/Binary Instantaneous value)
|
||||
(fhkvdataiv) 20: 04 dife (subunit=0 tariff=0 storagenr=8)
|
||||
(fhkvdataiv) 21: 6E vif (Units for H.C.A.)
|
||||
(fhkvdataiv) 22: * 000000 consumption at set date 8 (0.000000 hca)
|
||||
(fhkvdataiv) 25: 82 dif (16 Bit Integer/Binary Instantaneous value)
|
||||
(fhkvdataiv) 26: 04 dife (subunit=0 tariff=0 storagenr=8)
|
||||
(fhkvdataiv) 27: 6C vif (Date type G)
|
||||
(fhkvdataiv) 28: * 7F2A set date 8 (2019-10-31)
|
||||
(fhkvdataiv) 2a: 8D dif (variable length Instantaneous value)
|
||||
(fhkvdataiv) 2b: 04 dife (subunit=0 tariff=0 storagenr=8)
|
||||
(fhkvdataiv) 2c: EE vif (Units for H.C.A.)
|
||||
(fhkvdataiv) 2d: 1F vife (Compact profile without register)
|
||||
(fhkvdataiv) 2e: 1E varlen=30
|
||||
(fhkvdataiv) 2f: 72FE00000000000000000000000000000000000000000000000003001600
|
||||
(fhkvdataiv) 4d: 2F skip
|
||||
(fhkvdataiv) 4e: 2F skip
|
||||
*/
|
||||
|
||||
int offset;
|
||||
string key;
|
||||
|
||||
if (findKey(MeasurementType::Instantaneous, VIFRange::HeatCostAllocation, 0, 0, &key, &t->dv_entries)) {
|
||||
extractDVdouble(&t->dv_entries, key, &offset, ¤t_consumption_hca_);
|
||||
t->addMoreExplanation(offset, " current consumption (%f hca)", current_consumption_hca_);
|
||||
}
|
||||
|
||||
if (findKey(MeasurementType::Instantaneous, VIFRange::Date, 1, 0, &key, &t->dv_entries)) {
|
||||
struct tm date;
|
||||
extractDVdate(&t->dv_entries, key, &offset, &date);
|
||||
set_date_ = strdate(&date);
|
||||
t->addMoreExplanation(offset, " set date (%s)", set_date_.c_str());
|
||||
}
|
||||
|
||||
if (findKey(MeasurementType::Instantaneous, VIFRange::HeatCostAllocation, 1, 0, &key, &t->dv_entries)) {
|
||||
extractDVdouble(&t->dv_entries, key, &offset, &consumption_at_set_date_hca_);
|
||||
t->addMoreExplanation(offset, " consumption at set date (%f hca)", consumption_at_set_date_hca_);
|
||||
}
|
||||
|
||||
if (findKey(MeasurementType::Instantaneous, VIFRange::HeatCostAllocation, 8, 0, &key, &t->dv_entries)) {
|
||||
extractDVdouble(&t->dv_entries, key, &offset, &consumption_at_set_date_8_hca_);
|
||||
t->addMoreExplanation(offset, " consumption at set date 8 (%f hca)", consumption_at_set_date_8_hca_);
|
||||
}
|
||||
|
||||
if (findKey(MeasurementType::Instantaneous, VIFRange::Date, 8, 0, &key, &t->dv_entries)) {
|
||||
struct tm date;
|
||||
extractDVdate(&t->dv_entries, key, &offset, &date);
|
||||
set_date_8_ = strdate(&date);
|
||||
t->addMoreExplanation(offset, " set date 8 (%s)", set_date_8_.c_str());
|
||||
}
|
||||
|
||||
key = "326C";
|
||||
if (hasKey(&t->dv_entries, key)) {
|
||||
struct tm date;
|
||||
extractDVdate(&t->dv_entries, key, &offset, &date);
|
||||
error_date_ = strdate(&date);
|
||||
t->addMoreExplanation(offset, " error date (%s)", error_date_.c_str());
|
||||
}
|
||||
|
||||
if (findKey(MeasurementType::Instantaneous, VIFRange::DateTime, 0, 0, &key, &t->dv_entries)) {
|
||||
struct tm datetime;
|
||||
extractDVdate(&t->dv_entries, key, &offset, &datetime);
|
||||
device_date_time_ = strdatetime(&datetime);
|
||||
t->addMoreExplanation(offset, " device datetime (%s)", device_date_time_.c_str());
|
||||
}
|
||||
|
||||
key = "0DFF5F";
|
||||
if (hasKey(&t->dv_entries, key)) {
|
||||
string hex;
|
||||
extractDVHexString(&t->dv_entries, key, &offset, &hex);
|
||||
t->addMoreExplanation(offset, " vendor extension data");
|
||||
// This is not stored anywhere yet, we need to understand it, if necessary.
|
||||
}
|
||||
}
|
|
@ -63,8 +63,6 @@ LIST_OF_METER_TYPES
|
|||
X(unknown, 0, UnknownMeter, UNKNOWN, Unknown) \
|
||||
X(eurisii, T1_bit, HeatCostAllocationMeter, EURISII, EurisII) \
|
||||
X(evo868, T1_bit, WaterMeter, EVO868, EVO868) \
|
||||
X(fhkvdataiii,T1_bit, HeatCostAllocationMeter, FHKVDATAIII, FHKVDataIII) \
|
||||
X(fhkvdataiv, T1_bit, HeatCostAllocationMeter, FHKVDATAIV, FHKVDataIV) \
|
||||
X(gransystems,T1_bit, ElectricityMeter, CCx01, CCx01) \
|
||||
X(hydrocalm3, T1_bit, HeatMeter, HYDROCALM3, HydrocalM3) \
|
||||
X(hydrodigit, T1_bit, WaterMeter, HYDRODIGIT, Hydrodigit) \
|
||||
|
|
Ładowanie…
Reference in New Issue