From a603b650f610663e79cdcd97c9a919fd9c8e69ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20=C3=96hrstr=C3=B6m?= Date: Wed, 18 Jan 2023 16:45:16 +0100 Subject: [PATCH] Add watertech driver. --- CHANGES | 2 ++ README.md | 1 + src/driver_watertech.cc | 76 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 src/driver_watertech.cc diff --git a/CHANGES b/CHANGES index 6516035..7468b08 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,6 @@ +Added the watertech meter. + George Hopkins improved the fhkvdataiii driver to infer the current year and the rtlwmbus driver to propagate the timestamp from rtlwmbus input into the final json timestamp. Thanks George! diff --git a/README.md b/README.md index 4787a7c..bface19 100644 --- a/README.md +++ b/README.md @@ -569,6 +569,7 @@ Sontex Supercom 587 (supercom587) Sensus iPERL (iperl) Techem MK Radio 3 and 4 (mkradio3,mkradio4) (non-standard protocols) Waterstar M (waterstarm) +Watertech (watertech) Zenner Minomess (minomess) Supported heat cost allocators: diff --git a/src/driver_watertech.cc b/src/driver_watertech.cc new file mode 100644 index 0000000..8114647 --- /dev/null +++ b/src/driver_watertech.cc @@ -0,0 +1,76 @@ +/* + Copyright (C) 2020-2023 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 . +*/ + +#include"meters_common_implementation.h" + +namespace +{ + struct Driver : public virtual MeterCommonImplementation + { + Driver(MeterInfo &mi, DriverInfo &di); + }; + + static bool ok = registerDriver([](DriverInfo&di) + { + di.setName("watertech"); + di.setDefaultFields("name,id,status,total_m3,timestamp"); + di.setMeterType(MeterType::WaterMeter); + di.addLinkMode(LinkMode::T1); + di.addDetection(MANUFACTURER_WTT, 0x07, 0x59); + di.setConstructor([](MeterInfo& mi, DriverInfo& di){ return shared_ptr(new Driver(mi, di)); }); + }); + + Driver::Driver(MeterInfo &mi, DriverInfo &di) : MeterCommonImplementation(mi, di) + { + addOptionalCommonFields("software_version,meter_datetime"); + + addStringFieldWithExtractorAndLookup( + "status", + "Status and error flags.", + DEFAULT_PRINT_PROPERTIES | PrintProperty::INCLUDE_TPL_STATUS | PrintProperty::STATUS, + FieldMatcher::build() + .set(VIFRange::ErrorFlags), + { + { + { + "ERROR_FLAGS", + Translate::Type::BitToString, + AlwaysTrigger, MaskBits(0xffff), + "OK", + { + } + }, + }, + }); + + addNumericFieldWithExtractor( + "total", + "The total water consumption recorded by this meter.", + DEFAULT_PRINT_PROPERTIES, + Quantity::Volume, + VifScaling::Auto, + FieldMatcher::build() + .set(MeasurementType::Instantaneous) + .set(VIFRange::Volume) + ); + } +} + +// Test: wtt watertech 38383838 NOKEY +// telegram=|3144945E3838383859078C20007A010020252F2F_066D1C1F0EF021000413B91E000002FD17000002FD0F4C2B2F2F2F2F2F2F| +// {"media": "water","meter": "watertech","name": "wtt","id": "38383838","software_version" :"+L","meter_datetime": "2023-01-16 14:31:28","status": "OK","total_m3": 7.865, "timestamp":"1111-11-11T11:11:11Z"} +// |wtt;38383838;OK;7.865;1111-11-11 11:11.11