# 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. | System | Status | | ------------ |:-------------:| | Ubuntu | [![Build Ubuntu Status](https://github.com/weetmuts/wmbusmeters/workflows/Build%20Ubuntu/badge.svg)](https://github.com/weetmuts/wmbusmeters/actions)| | MacOSX | [![Build MacOSX Status](https://github.com/weetmuts/wmbusmeters/workflows/Build%20MacOSX/badge.svg)](https://github.com/weetmuts/wmbusmeters/actions)| |Docker |[![CircleCI>](https://circleci.com/gh/weetmuts/wmbusmeters.svg?style=shield)](https://circleci.com/gh/weetmuts/wmbusmeters)| |Snap |[![wmbusmeters](https://snapcraft.io//wmbusmeters/badge.svg)](https://snapcraft.io/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: ```shell dnf install wmbusmeters ``` Availability of **wmbusmeters** for other Linux distributions can be checked on [release-monitoring](https://release-monitoring.org/project/88654/) project page. # Docker Experimental docker containers are available here: https://hub.docker.com/r/weetmuts/wmbusmeters # Snap Experimental snaps are available here: https://snapcraft.io/wmbusmeters Read the wiki for more info on how to use the snap: https://weetmuts.github.io/wmbusmeterswiki/SNAP.html # Build from source and run as a daemon Building and installing from source is easy and recommended since the development progresses quickly. First remove the wmbus dongle (im871a,amb8465,cul,rc1180) or the generic rtlsdr dongle (RTL2832U) from your computer. Then do: `./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:t1` 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:t1` 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. For example: `auto:c1` or `im871a:c1,t1` or `im871a[457200101056]:t1` or `/dev/ttyUSB2:amb8465:c1,t1` Adding a device like auto or im871a will trigger an automatic probe of all serial ttys to auto find or to find on which tty the im871a resides. If you specify a full device path like `/dev/ttyUSB0:im871a:c1` or `rtlwmbus` or `rtl433` then it will not probe the serial devices. If you must be really sure that it will not probe something you can add `donotprobe=/dev/ttyUSB0` or `donotprobe=all`. You can specify combinations like: `device=rc1180:t1` `device=auto:c1` to set the rc1180 dongle to t1 but any other auto-detected dongle to c1. ```ini loglevel=normal # Search for a wmbus device and set it to c1. device=auto:c1 # But do not probe this serial tty. donotprobe=/dev/ttyACM2 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) ignoreduplicates=true ``` Then add a meter file in /etc/wmbusmeters.d/MyTapWater ```ini name=MyTapWater id=12345678 key=00112233445566778899AABBCCDDEEFF ``` Meter driver detection will be automatic. You can also provide an explicit driver name with: `driver=multical21:c1` or explicitly state that driver detection is automatic: `driver=auto`. 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 that either the binaries `/usr/bin/rtl_sdr` and `/usr/bin/rtl_wmbus` exists and are executable. Or that the executable `rtl_sdr/rtl_wmbus` binaries exists inside the same directory as the wmbusmeters executable. If not you will see the error message `(rtlwmbus) error: when starting as daemon, wmbusmeters looked for .../rtl_wmbus and /usr/bin/rtl_wmbus, but found neither!` 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: ```ini field_address=RoadenRd 456 field_city=Stockholm ``` If you add `field_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. (The old prefix json_ still works.) 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. Also when using the Raspberry PI it can get confused by the serial ports, in particular the bluetooth port might come and go as a serial tty depending on the config. Therefore it can be advantageous to use the auto device to find the proper tty (eg /dev/ttyUSB0) and then specify this tty device explicitly in the config file, instead of using auto. This assumes that you only have a single usb dongle otherwise the USB tty names can change depending on how and when the devices are unplugged/replugged and the pi restarted. If you have multiple devies with different antennas, then you should instead use donotprobe to avoid the ttys that can never have a wmbus dongle. If you specify `--meterfilesaction=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. The purpose of the alarm shell and timeout is to notify you about problems within wmbusmeters and the wmbus dongles, not the meters themselves. Thus the timeout is for a dongle to receive some telegram at all. It does not matter from which meter. # 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`. ```shell wmbusmeters --useconfig=/ ``` Or you can start wmbusmeters with your own config files: ```shell wmbusmeters --useconfig=/home/me/.config/wmbusmeters ``` If you already have config with a device specified, and you want to use the config with another device. You might have multiple meters in the config that you want to listen to. Then you can add `--device` to override the settings in the config. Like this: ```shell wmbusmeters --useconfig=/home/me/.config/wmbusmeters --device=rtlwmbus ``` You must have both `--useconfig=` and `--device=` for it to work. 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: 1.4.0 Usage: wmbusmeters {options} ( [meter_name] [meter_driver]{:} [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=