diff --git a/Makefile b/Makefile index 9595779..09311a1 100644 --- a/Makefile +++ b/Makefile @@ -124,6 +124,7 @@ METER_OBJS:=\ $(BUILD)/meter_hydrodigit.o \ $(BUILD)/meter_iperl.o \ $(BUILD)/meter_izar.o \ + $(BUILD)/meter_lansendw.o \ $(BUILD)/meter_lansensm.o \ $(BUILD)/meter_lansenth.o \ $(BUILD)/meter_mkradio3.o \ diff --git a/README.md b/README.md index 11fceb0..3593ca9 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,9 @@ Elvaco CMa12w Thermometer (cma12w) Supported smoke detectors: Lansen Smoke Detector (lansensm) +Supported door/window detectors: +Lansen Door/Window Detector (lansendw) + Supported electricity meters: Tauron Amiplus (amiplus) (includes vendor apator and echelon) EMH Metering (ehzp) diff --git a/simulations/simulation_t1.txt b/simulations/simulation_t1.txt index 3307858..f9ed2d3 100644 --- a/simulations/simulation_t1.txt +++ b/simulations/simulation_t1.txt @@ -64,6 +64,16 @@ telegram=|2e44333003020100071b7a634820252f2f0265840842658308820165950802fb1aae01 {"media":"room sensor","meter":"lansenth","name":"Tempoo","id":"00010203","current_temperature_c":21.8,"current_relative_humidity_rh":43,"average_temperature_1h_c":21.79,"average_relative_humidity_1h_rh":43,"average_temperature_24h_c":21.97,"average_relative_humidity_24h_rh":42.5,"timestamp":"1111-11-11T11:11:11Z"} |Tempoo;00010203;21.800000;43.000000;1111-11-11 11:11.11 +# Test Lansen door window telegram + +telegram=|2e44333005020100071d7ab54800002f2f02fd1b110002fd971d01000efd3a2200000000008e40fd3a000000000000| +{"media":"reserved","meter":"lansensm","name":"Dooro","id":"00010205","status":"CLOSED","timestamp":"1111-11-11T11:11:11Z"} +|Dooro;00010205;CLOSED;1111-11-11 11:11.11 + +telegram=|2e44333005020100071d7ab66800002f2f02fd1b550002fd971d01000efd3a2300000000008e40fd3a000000000000| +{"media":"reserved","meter":"lansensm","name":"Dooro","id":"00010205","status":"OPEN","timestamp":"1111-11-11T11:11:11Z"} +|Dooro;00010205;OPEN;1111-11-11 11:11.11 + # Test BMEters RFM-AMB Temperature Hygrometer telegram telegram=|5744b40988227711101b7ab20800000265a00842658f088201659f08226589081265a0086265510852652b0902fb1aba0142fb1ab0018201fb1abd0122fb1aa90112fb1aba0162fb1aa60152fb1af501066d3b3bb36b2a00| diff --git a/src/meter_lansendw.cc b/src/meter_lansendw.cc new file mode 100644 index 0000000..c4168a3 --- /dev/null +++ b/src/meter_lansendw.cc @@ -0,0 +1,136 @@ +/* + Copyright (C) 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 . +*/ + +#include"dvparser.h" +#include"meters.h" +#include"meters_common_implementation.h" +#include"wmbus.h" +#include"wmbus_utils.h" + +#define INFO_CODE_CLOSED 0x0011 +#define INFO_CODE_OPEN 0x0055 + +struct MeterLansenDW : public virtual DoorWindowDetector, public virtual MeterCommonImplementation { + MeterLansenDW(WMBus *bus, MeterInfo &mi); + + string status(); + bool open(); + +private: + + void processContent(Telegram *t); + + private: + + uint16_t info_codes_ {}; + +}; + +MeterLansenDW::MeterLansenDW(WMBus *bus, MeterInfo &mi) : + MeterCommonImplementation(bus, mi, MeterType::LANSENSM, MANUFACTURER_LAS) +{ + setExpectedTPLSecurityMode(TPLSecurityMode::AES_CBC_IV); + + addMedia(0x1d); + + addLinkMode(LinkMode::T1); + + addExpectedVersion(0x07); + + addPrint("status", Quantity::Text, + [&](){ return status(); }, + "The current status: OPEN or CLOSED.", + true, true); +} + +unique_ptr createLansenDW(WMBus *bus, MeterInfo &mi) +{ + return unique_ptr(new MeterLansenDW(bus, mi)); +} + +bool MeterLansenDW::open() +{ + return info_codes_ == INFO_CODE_OPEN; +} + +void MeterLansenDW::processContent(Telegram *t) +{ + /* + (wmbus) 11: 02 dif (16 Bit Integer/Binary Instantaneous value) + (wmbus) 12: FD vif (Second extension of VIF-codes) + (wmbus) 13: 1B vife (Digital Input (binary)) + (wmbus) 14: 1100 + (wmbus) 16: 02 dif (16 Bit Integer/Binary Instantaneous value) + (wmbus) 17: FD vif (Second extension of VIF-codes) + (wmbus) 18: 97 vife (Error flags (binary)) + (wmbus) 19: 1D vife (Response delay time [bittimes]) + (wmbus) 1a: 0100 + (wmbus) 1c: 0E dif (12 digit BCD Instantaneous value) + (wmbus) 1d: FD vif (Second extension of VIF-codes) + (wmbus) 1e: 3A vife (Dimensionless / no VIF) + (wmbus) 1f: 220000000000 + (wmbus) 25: 8E dif (12 digit BCD Instantaneous value) + (wmbus) 26: 40 dife (subunit=1 tariff=0 storagenr=0) + (wmbus) 27: FD vif (Second extension of VIF-codes) + (wmbus) 28: 3A vife (Dimensionless / no VIF) + (wmbus) 29: 000000000000 + */ + + /* + (wmbus) 11: 02 dif (16 Bit Integer/Binary Instantaneous value) + (wmbus) 12: FD vif (Second extension of VIF-codes) + (wmbus) 13: 1B vife (Digital Input (binary)) + (wmbus) 14: 5500 + (wmbus) 16: 02 dif (16 Bit Integer/Binary Instantaneous value) + (wmbus) 17: FD vif (Second extension of VIF-codes) + (wmbus) 18: 97 vife (Error flags (binary)) + (wmbus) 19: 1D vife (Response delay time [bittimes]) + (wmbus) 1a: 0100 + (wmbus) 1c: 0E dif (12 digit BCD Instantaneous value) + (wmbus) 1d: FD vif (Second extension of VIF-codes) + (wmbus) 1e: 3A vife (Dimensionless / no VIF) + (wmbus) 1f: 230000000000 + (wmbus) 25: 8E dif (12 digit BCD Instantaneous value) + (wmbus) 26: 40 dife (subunit=1 tariff=0 storagenr=0) + (wmbus) 27: FD vif (Second extension of VIF-codes) + (wmbus) 28: 3A vife (Dimensionless / no VIF) + (wmbus) 29: 000000000000 + */ + int offset; + + extractDVuint16(&t->values, "02FD1B", &offset, &info_codes_); + t->addMoreExplanation(offset, " info codes (%s)", status().c_str()); +} + +string MeterLansenDW::status() +{ + string s; + if (info_codes_ == INFO_CODE_OPEN) + { + s.append("OPEN"); + } + else if (info_codes_ == INFO_CODE_CLOSED) + { + s.append("CLOSED"); + } + else + { + s.append("ERR"); + } + + return s; +} diff --git a/src/meters.cc b/src/meters.cc index c596e5a..9835ba9 100644 --- a/src/meters.cc +++ b/src/meters.cc @@ -223,7 +223,7 @@ bool MeterCommonImplementation::isTelegramForMe(Telegram *t) } if (!media_match) { - warning("(meter) %s: probably not for me since media does not match\n", name_.c_str()); + warning("(meter) %s: probably not for me since received media 0x%02x does not match\n", name_.c_str(), t->dll_type); } debug("(meter) %s: yes for me\n", name_.c_str()); diff --git a/src/meters.h b/src/meters.h index 33929e5..fcff152 100644 --- a/src/meters.h +++ b/src/meters.h @@ -42,6 +42,7 @@ X(izar, T1_bit, Water, IZAR, Izar) \ X(lansensm, T1_bit, SmokeDetector, LANSENSM, LansenSM) \ X(lansenth, T1_bit, TempHygro, LANSENTH, LansenTH) \ + X(lansendw, T1_bit, DoorWindow, LANSENDW, LansenDW) \ X(mkradio3, T1_bit, Water, MKRADIO3, MKRadio3) \ X(multical21, C1_bit, Water, MULTICAL21, Multical21) \ X(multical302,C1_bit, Heat, MULTICAL302, Multical302) \ @@ -199,6 +200,12 @@ struct SmokeDetector : public virtual Meter virtual ~SmokeDetector() = default; }; +struct DoorWindowDetector : public virtual Meter +{ + virtual bool open() = 0; + virtual ~DoorWindowDetector() = default; +}; + struct GenericMeter : public virtual Meter { }; @@ -225,6 +232,7 @@ unique_ptr createEurisII(WMBus *bus, MeterInfo &m); unique_ptr createFHKVDataIII(WMBus *bus, MeterInfo &m); unique_ptr createLansenTH(WMBus *bus, MeterInfo &m); unique_ptr createLansenSM(WMBus *bus, MeterInfo &m); +unique_ptr createLansenDW(WMBus *bus, MeterInfo &m); unique_ptr createCMa12w(WMBus *bus, MeterInfo &m); unique_ptr createRfmAmb(WMBus *bus, MeterInfo &m); unique_ptr createRfmTX1(WMBus *bus, MeterInfo &m); diff --git a/tests/test_listen_to_all.sh b/tests/test_listen_to_all.sh index 59b27b0..3372482 100755 --- a/tests/test_listen_to_all.sh +++ b/tests/test_listen_to_all.sh @@ -57,6 +57,12 @@ Received telegram from: 00010204 Received telegram from: 00010203 manufacturer: (LAS) Lansen Systems, Sweden device type: Room sensor (eg temperature or humidity) +Received telegram from: 00010205 + manufacturer: (LAS) Lansen Systems, Sweden + device type: Reserved for sensors +Received telegram from: 00010205 + manufacturer: (LAS) Lansen Systems, Sweden + device type: Reserved for sensors Received telegram from: 11772288 manufacturer: (BMT) BMETERS, Italy device type: Room sensor (eg temperature or humidity) diff --git a/tests/test_t1_meters.sh b/tests/test_t1_meters.sh index 27cc1f7..4e0944a 100755 --- a/tests/test_t1_meters.sh +++ b/tests/test_t1_meters.sh @@ -19,6 +19,7 @@ METERS="MyWarmWater supercom587 12345678 NOKEY HeatMeter eurisii 88018801 NOKEY Smokeo lansensm 00010204 NOKEY Tempoo lansenth 00010203 NOKEY + Dooro lansendw 00010205 NOKEY Rummet rfmamb 11772288 NOKEY IzarWater izar 21242472 NOKEY IzarWater2 izar 66290778 NOKEY