# wmbusmeters The program receives and decodes C1,T1 or S1 telegrams (using the wireless mbus protocol) to acquire utility meter readings. The readings can then be published using MQTT, curled to a REST api, inserted into a database or stored in a log file. [FAQ/WIKI/MANUAL pages](https://weetmuts.github.io/wmbusmeterswiki/) The program runs on GNU/Linux, MacOSX, FreeBSD, and Raspberry Pi. | OS | Status | | ------------ |:-------------:| |GNU/Linux & MacOSX| [![Build Status](https://travis-ci.org/weetmuts/wmbusmeters.svg?branch=master)](https://travis-ci.org/weetmuts/wmbusmeters) | |Docker build status|[![CircleCI>](https://circleci.com/gh/weetmuts/wmbusmeters.svg?style=shield)](https://circleci.com/gh/weetmuts/wmbusmeters)| |Snap status|[![wmbusmeters](https://snapcraft.io//wmbusmeters/badge.svg)](https://snapcraft.io/wmbusmeters)| | Static Scan | Status | | ------------- |:-------------:| |Linux G++| [![Build Status](https://scan.coverity.com/projects/14774/badge.svg)](https://scan.coverity.com/projects/weetmuts-wmbusmeters) | # Distributions **wmbusmeters** package is available on [Fedora](https://src.fedoraproject.org/rpms/wmbusmeters) _(version 31 or newer)_ and can be simply installed by using: ``` # dnf install wmbusmeters ``` Availability of **wmbusmeters** for other Linux distributions can be checked on [release-monitoring](https://release-monitoring.org/project/88654/) project page. # Run as a daemon Remove the wmbus dongle (im871a,amb8465,cul,rc1180,rfmrx2,d1tc) or the generic rtlsdr dongle (RTL2838) from your computer. `./configure; make; sudo make install` will install wmbusmeters as a daemon. Check the contents of your `/etc/wmbusmeters.conf` file, assuming it has `device=auto:c1` and you are using a im871a,amb8465,rc1180 or cul device, then you can now start the daemon with `sudo systemctl start wmbusmeters` or you can try it from the command line `wmbusmeters auto:c1` Wmbusmeters will scan for wmbus devices every few seconds and detect whenever a device is plugged in or removed. To have the wmbusmeters daemon start automatically when the computer boots do: `sudo systemctl enable wmbusmeters` You can trigger a reload of the config files with `sudo killall -HUP wmbusmetersd` (Note! make install only works for GNU/Linux. For MacOSX try to start `wmbusmetersd /tmp/thepidfile` from a script instead.) Check the config file /etc/wmbusmeters.conf and edit the device to point to your dongle or use auto ``` loglevel=normal device=/dev/ttyUSB0:im871a logtelegrams=false format=json meterfiles=/var/log/wmbusmeters/meter_readings meterfilesaction=overwrite meterfilesnaming=name meterfilestimestamp=day logfile=/var/log/wmbusmeters/wmbusmeters.log shell=/usr/bin/mosquitto_pub -h localhost -t wmbusmeters/$METER_ID -m "$METER_JSON" alarmshell=/usr/bin/mosquitto_pub -h localhost -t wmbusmeters_alarm -m "$ALARM_TYPE $ALARM_MESSAGE" alarmtimeout=1h alarmexpectedactivity=mon-sun(00-23) ``` Then add a meter file in /etc/wmbusmeters.d/MyTapWater ``` name=MyTapWater type=multical21 id=12345678 key=00112233445566778899AABBCCDDEEFF ``` Now plugin your wmbus dongle. Wmbusmeters should start automatically, check with `tail -f /var/log/syslog` and `tail -f /var/log/wmbusmeters/wmbusmeters.log` (If you are using an rtlsdr dongle, then make sure the binaries /usr/bin/rtl_sdr and /usr/bin/rtl_wmbus exists and are executable. If not you will see the error message `(rtlwmbus) error: when starting as daemon, wmbusmeters expects /usr/bin/rtl_sdr to exist!` and the daemon will refuse to start.) The latest reading of the meter can also be found here: /var/log/wmbusmeters/meter_readings/MyTapWater You can use several ids using `id=1111111,2222222,3333333` or you can listen to all meters of a certain type `id=*` or you can suffix with star `id=8765*` to match all meters with a given prefix. If you supply at least one positive match rule, then you can add negative match rules as well. For example `id=*,!2222*` which will match all meter ids, except those that begin with 2222. You can add the static json data "address":"RoadenRd 456","city":"Stockholm" to every json message with the wmbusmeters.conf setting: ``` json_address=RoadenRd 456 json_city=Stockholm ``` If you add `json_floor=5` to the meter file MyTapWater, then you can have the meter tailored static json "floor":"5" added to telegrams handled by that particular meter. If you are running on a Raspberry PI with flash storage and you relay the data to another computer using a shell command (mosquitto_pub or curl or similar) then you might want to remove `meterfiles` and `meterfilesaction` to minimize the writes to the local flash file system. If you specify --metefilesaction=append --meterfilestimestamp=day then wmbusmeters will append all todays received telegrams in for example the file Water_2019-12-11, the day after the telegrams will be recorded in Water_2019-12-12. You can change the resolution to day,hour,minute and micros. Micros means that every telegram gets their own file. # Run using config files If you cannot install as a daemon, then you can also start wmbusmeters in your terminal using the config files in /etc/wmbusmeters. ``` wmbusmeters --useconfig=/ ``` Or you can start wmbusmeters with your own config files: ``` wmbusmeters --useconfig=/home/me/.config/wmbusmeters ``` You can add --device to override the settings in the config. Like this: ``` wmbusmeters --useconfig=/home/me/.config/wmbusmeters --device=rtlwmbus ``` The files/dir should then be located here: `/home/me/.config/wmbusmeters/etc/wmbusmeters.conf` and `/home/me/.config/wmbusmeters/etc/wmbusmeters.d` When running using config files then you can trigger a reload of the config files using `sudo killall -HUP wmbusmetersd` or `killall -HUP wmbusmeters` depending on if you are running as a daemon or not. # Running without config files, good for experimentation and test. ``` wmbusmeters version: 0.9.36 Usage: wmbusmeters {options} ( [meter_name] [meter_type]{:} [meter_id] [meter_key] )* As you can use: --addconversions=+ add conversion to these units to json and meter env variables (GJ) --alarmexpectedactivity=mon-fri(08-17),sat-sun(09-12) Specify when the timeout is tested, default is mon-sun(00-23) --alarmshell= invokes cmdline when an alarm triggers --alarmtimeout=