2020-09-01 19:53:05 +00:00
|
|
|
/*
|
2022-02-12 14:28:17 +00:00
|
|
|
Copyright (C) 2017-2020 Fredrik Öhrström (gpl-3.0-or-later)
|
|
|
|
Copyright (C) 2020 Avandorp (gpl-3.0-or-later)
|
2020-09-01 19:53:05 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/*
|
|
|
|
AquaMetro / Integra water meter "TOPAS ES KR"
|
|
|
|
Models TOPAS ES KR 95077 95056 95345 95490 95373 95059 95065 95068 95071 95074 should be compatible. Only 95059 in one configuration tested.
|
|
|
|
Identifies itself with Manufacturer "AMT" and Version "f1"
|
|
|
|
Product leaflet and observation says the following values are sent:
|
|
|
|
Current total volume
|
|
|
|
Total volume at end of year-period day (that means: current total volume - total volume at end of year-period day = current year-periods volume up until now)
|
|
|
|
Total backward volume on end of year-period day or total backward volume in current year-period. Backward volume remains untested (luckily only 0 values encountered).
|
|
|
|
Date of end of last year-period day
|
|
|
|
Total volume at end of last month-period dateTime
|
|
|
|
DateTime of end of last month-period
|
|
|
|
Current flow rate
|
|
|
|
Battery life (days left)
|
|
|
|
Water temperature
|
|
|
|
|
|
|
|
Example telegram:
|
|
|
|
telegram=|4E44B40512345678F1077A310040052F2F|01FD08040C13991848004C1359423500CC101300000000CC201359423500426C7F2C0B3B00000002FD74DA10025AD300C4016D3B179F27CC011387124600|+2
|
|
|
|
*/
|
2021-12-31 15:47:29 +00:00
|
|
|
struct MeterTopasEsKr : public virtual MeterCommonImplementation {
|
2020-09-02 12:38:47 +00:00
|
|
|
MeterTopasEsKr(MeterInfo &mi);
|
2020-09-01 19:53:05 +00:00
|
|
|
|
|
|
|
double totalWaterConsumption(Unit u);
|
|
|
|
bool hasTotalWaterConsumption();
|
|
|
|
|
|
|
|
double flowTemperature(Unit u);
|
|
|
|
bool hasFlowTemperature();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void processContent(Telegram *t);
|
|
|
|
|
|
|
|
double total_water_consumption_m3_ {};
|
|
|
|
double flow_temperature_ {};
|
|
|
|
double current_flow_m3h_ {};
|
|
|
|
string battery_life_days_remaining_ {};
|
|
|
|
double volume_year_period_m3_ {};
|
|
|
|
double reverse_volume_year_period_m3_ {};
|
|
|
|
double volume_month_period_m3_ {};
|
|
|
|
string meter_yearly_period_date_;
|
|
|
|
string meter_month_period_datetime_;
|
|
|
|
};
|
|
|
|
|
2021-12-31 11:27:57 +00:00
|
|
|
shared_ptr<Meter> createTopasEsKr(MeterInfo &mi)
|
2020-09-01 19:53:05 +00:00
|
|
|
{
|
2021-12-31 15:47:29 +00:00
|
|
|
return shared_ptr<Meter>(new MeterTopasEsKr(mi));
|
2020-09-01 19:53:05 +00:00
|
|
|
}
|
|
|
|
|
2020-09-02 12:38:47 +00:00
|
|
|
MeterTopasEsKr::MeterTopasEsKr(MeterInfo &mi) :
|
2022-01-02 12:08:36 +00:00
|
|
|
MeterCommonImplementation(mi, "topaseskr")
|
2020-09-01 19:53:05 +00:00
|
|
|
{
|
2021-12-31 15:47:29 +00:00
|
|
|
setMeterType(MeterType::WaterMeter);
|
|
|
|
|
2020-09-01 19:53:05 +00:00
|
|
|
setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV);
|
|
|
|
|
2020-09-04 09:31:49 +00:00
|
|
|
// media 0x06 specified temperature range is 0°C to 50 °C, not sure it ever reports 0x06 for warm water, possibly configurable
|
|
|
|
// media 0x07 used
|
2020-09-01 19:53:05 +00:00
|
|
|
|
|
|
|
addLinkMode(LinkMode::T1);
|
|
|
|
|
|
|
|
addPrint("total", Quantity::Volume,
|
|
|
|
[&](Unit u){ return totalWaterConsumption(u); },
|
|
|
|
"The total water consumption recorded by this meter.",
|
2022-04-11 12:01:54 +00:00
|
|
|
PrintProperty::FIELD | PrintProperty::JSON);
|
2020-09-01 19:53:05 +00:00
|
|
|
addPrint("temperature", Quantity::Temperature,
|
|
|
|
[&](Unit u){ return flowTemperature(u); },
|
|
|
|
"Current water temperature recorded by this meter.",
|
2022-04-11 12:01:54 +00:00
|
|
|
PrintProperty::FIELD | PrintProperty::JSON);
|
2020-09-01 19:53:05 +00:00
|
|
|
addPrint("current_flow", Quantity::Flow,
|
|
|
|
[&](Unit u){ return current_flow_m3h_; },
|
|
|
|
"Current flow.",
|
2022-04-11 12:01:54 +00:00
|
|
|
PrintProperty::FIELD | PrintProperty::JSON);
|
2020-09-01 19:53:05 +00:00
|
|
|
addPrint("battery_life_days_remaining_remaining", Quantity::Text,
|
|
|
|
[&](){ return battery_life_days_remaining_; },
|
|
|
|
"Battery life [days remaining].",
|
2022-04-11 12:01:54 +00:00
|
|
|
PrintProperty::JSON);
|
2020-09-01 19:53:05 +00:00
|
|
|
addPrint("volume_year_period", Quantity::Volume,
|
|
|
|
[&](Unit u){ return volume_year_period_m3_; },
|
|
|
|
"Volume up to end of last year-period.",
|
2022-04-11 12:01:54 +00:00
|
|
|
PrintProperty::FIELD | PrintProperty::JSON);
|
2020-09-01 19:53:05 +00:00
|
|
|
addPrint("reverse_volume_year_period", Quantity::Volume,
|
|
|
|
[&](Unit u){ return reverse_volume_year_period_m3_; },
|
|
|
|
"Reverse volume in this year-period (?).",
|
2022-04-11 12:01:54 +00:00
|
|
|
PrintProperty::FIELD | PrintProperty::JSON);
|
2020-09-01 19:53:05 +00:00
|
|
|
addPrint("meter_year_period_start_date", Quantity::Text,
|
|
|
|
[&](){ return meter_yearly_period_date_; },
|
|
|
|
"Meter date for year-period start.",
|
2022-04-11 12:01:54 +00:00
|
|
|
PrintProperty::FIELD | PrintProperty::JSON);
|
2020-09-01 19:53:05 +00:00
|
|
|
addPrint("volume_month_period", Quantity::Volume,
|
|
|
|
[&](Unit u){ return volume_month_period_m3_; },
|
|
|
|
"Volume up to end of last month-period.",
|
2022-04-11 12:01:54 +00:00
|
|
|
PrintProperty::FIELD | PrintProperty::JSON);
|
2020-09-01 19:53:05 +00:00
|
|
|
addPrint("meter_month_period_start_datetime", Quantity::Text,
|
|
|
|
[&](){ return meter_month_period_datetime_; },
|
|
|
|
"Meter timestamp for month-period start.",
|
2022-04-11 12:01:54 +00:00
|
|
|
PrintProperty::FIELD | PrintProperty::JSON);
|
2020-09-01 19:53:05 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MeterTopasEsKr::processContent(Telegram *t)
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
string key;
|
|
|
|
|
2022-04-16 19:26:51 +00:00
|
|
|
if(findKey(MeasurementType::Unknown, VIFRange::Volume, 0, 0, &key, &t->dv_entries)) {
|
|
|
|
extractDVdouble(&t->dv_entries, key, &offset, &total_water_consumption_m3_);
|
2020-09-01 19:53:05 +00:00
|
|
|
t->addMoreExplanation(offset, " total consumption (%f m3)", total_water_consumption_m3_);
|
|
|
|
}
|
2022-04-16 19:26:51 +00:00
|
|
|
if(findKey(MeasurementType::Unknown, VIFRange::FlowTemperature, 0, 0, &key, &t->dv_entries)) {
|
|
|
|
extractDVdouble(&t->dv_entries, key, &offset, &flow_temperature_);
|
2020-09-01 19:53:05 +00:00
|
|
|
t->addMoreExplanation(offset, " water temperature (%f °C)", flow_temperature_);
|
|
|
|
}
|
2022-04-16 19:26:51 +00:00
|
|
|
if(findKey(MeasurementType::Unknown, VIFRange::VolumeFlow, 0, 0, &key, &t->dv_entries)) {
|
|
|
|
extractDVdouble(&t->dv_entries, key, &offset, ¤t_flow_m3h_);
|
2020-09-01 19:53:05 +00:00
|
|
|
t->addMoreExplanation(offset, " current flow (%f m3/h)", current_flow_m3h_);
|
|
|
|
}
|
|
|
|
|
2022-04-16 19:26:51 +00:00
|
|
|
extractDVdouble(&t->dv_entries, "4C13", &offset, &volume_year_period_m3_);
|
2020-09-01 19:53:05 +00:00
|
|
|
t->addMoreExplanation(offset, " volume up to end of last year-period (%f m3)", volume_year_period_m3_);
|
|
|
|
|
2022-04-16 19:26:51 +00:00
|
|
|
extractDVdouble(&t->dv_entries, "CC1013", &offset, &reverse_volume_year_period_m3_);
|
2020-09-01 19:53:05 +00:00
|
|
|
t->addMoreExplanation(offset, " reverse volume in this year-period (?) (%f m3)", reverse_volume_year_period_m3_);
|
|
|
|
|
|
|
|
struct tm date;
|
2022-04-16 19:26:51 +00:00
|
|
|
extractDVdate(&t->dv_entries, "426C", &offset, &date);
|
2020-09-01 19:53:05 +00:00
|
|
|
meter_yearly_period_date_ = strdate(&date);
|
|
|
|
t->addMoreExplanation(offset, " meter_start_year_period_date (%s)", meter_yearly_period_date_.c_str());
|
|
|
|
|
2022-04-16 19:26:51 +00:00
|
|
|
extractDVdouble(&t->dv_entries, "CC0113", &offset, &volume_month_period_m3_);
|
2020-09-01 19:53:05 +00:00
|
|
|
t->addMoreExplanation(offset, " volume up to end of last month-period (%f m3)", volume_month_period_m3_);
|
|
|
|
|
|
|
|
struct tm datetime;
|
2022-04-16 19:26:51 +00:00
|
|
|
extractDVdate(&t->dv_entries, "C4016D", &offset, &datetime);
|
2020-09-01 19:53:05 +00:00
|
|
|
meter_month_period_datetime_ = strdatetime(&datetime);
|
|
|
|
t->addMoreExplanation(offset, " meter_start_month_period_datetime (%s)", meter_month_period_datetime_.c_str());
|
|
|
|
|
|
|
|
uint16_t tmp16;
|
2022-04-16 19:26:51 +00:00
|
|
|
extractDVuint16(&t->dv_entries, "02FD74", &offset, &tmp16);
|
2020-09-01 19:53:05 +00:00
|
|
|
strprintf(battery_life_days_remaining_, "%u", (unsigned int)tmp16);
|
|
|
|
t->addMoreExplanation(offset, " battery life (%s days remaining)", battery_life_days_remaining_.c_str());
|
|
|
|
|
|
|
|
vector<uchar> data;
|
|
|
|
t->extractMfctData(&data);
|
|
|
|
}
|
|
|
|
|
|
|
|
double MeterTopasEsKr::totalWaterConsumption(Unit u)
|
|
|
|
{
|
|
|
|
assertQuantity(u, Quantity::Volume);
|
|
|
|
return convert(total_water_consumption_m3_, Unit::M3, u);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MeterTopasEsKr::hasTotalWaterConsumption()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
double MeterTopasEsKr::flowTemperature(Unit u)
|
|
|
|
{
|
|
|
|
assertQuantity(u, Quantity::Temperature);
|
|
|
|
return convert(flow_temperature_, Unit::C, u);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MeterTopasEsKr::hasFlowTemperature()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|