kopia lustrzana https://github.com/weetmuts/wmbusmeters
Updated README and small fixes.
rodzic
b69b27707c
commit
b4092bcdff
6
CHANGES
6
CHANGES
|
@ -1,7 +1,11 @@
|
|||
|
||||
Version 0.9.0: 2019-02-24
|
||||
Version 0.9.0: 2019-02-26
|
||||
|
||||
Reading the meter settings from config files
|
||||
in /etc is now supported.
|
||||
Running wmbusmeters as daemon is now supported.
|
||||
Using rtl_wmbus to receive wmbus messages from
|
||||
rtl_sdr is work in progress.
|
||||
Updated README
|
||||
|
||||
Version 0.8.4: 2019-02-23
|
||||
|
|
57
README.md
57
README.md
|
@ -2,7 +2,7 @@
|
|||
The program receives and decodes C1 or T1 telegrams
|
||||
(using the wireless mbus protocol) to acquire
|
||||
utility meter readings. The readings can then be published using
|
||||
MQTT, inserted into a database or stored in a log file.
|
||||
MQTT, curled to a REST api, inserted into a database or stored in a log file.
|
||||
|
||||
The program runs on GNU/Linux (standard x86) and Raspberry Pi (arm).
|
||||
|
||||
|
@ -15,8 +15,56 @@ The program runs on GNU/Linux (standard x86) and Raspberry Pi (arm).
|
|||
|Linux G++| [](https://scan.coverity.com/projects/weetmuts-wmbusmeters) |
|
||||
|
||||
|
||||
# Run as a daemon
|
||||
|
||||
Remove the wmbus dongle (im871a or amb8465) from your computer.
|
||||
|
||||
`sudo make install` will install wmbusmeters as a daemon that starts
|
||||
automatically when an appropriate wmbus usb dongle is inserted in the computer.
|
||||
|
||||
Check the config file /etc/wmbusmeters.conf:
|
||||
```
|
||||
wmbusmeters version: 0.8
|
||||
loglevel=normal
|
||||
device=auto
|
||||
logtelegrams=false
|
||||
meterfilesdir=/var/log/wmbusmeters/meter_readings
|
||||
logfile=/var/log/wmbusmeters/wmbusmeters.log
|
||||
shell=/usr/bin/mosquitto_pub -h localhost -t wmbusmeters -m "$METER_JSON"
|
||||
```
|
||||
|
||||
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`
|
||||
|
||||
The latest reading of the meter can also be found here: /var/log/wmbusmeters/meter_readings/MyTapWater
|
||||
|
||||
# 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
|
||||
```
|
||||
|
||||
The files/dir should then be located here:
|
||||
`/home/me/.config/wmbusmeters/etc/wmbusmeters.conf` and
|
||||
`/home/me/.config/wmbusmeters/etc/wmbusmeters.d`
|
||||
|
||||
|
||||
```
|
||||
wmbusmeters version: 0.9
|
||||
Usage: wmbusmeters {options} (auto | /dev/ttyUSBx)] { [meter_name] [meter_type] [meter_id] [meter_key] }*
|
||||
|
||||
Add more meter quadruplets to listen to more meters.
|
||||
|
@ -32,12 +80,17 @@ Add --verbose for detailed debug information.
|
|||
--shell=cmd invokes cmd with env variables containing the latest reading.
|
||||
--shellenvs list the env variables available for the meter.
|
||||
--oneshot wait for an update from each meter, then quit.
|
||||
--useconfig=dir look for configuration file in dir/etc/wmbusmeters.conf and
|
||||
dir/etc/wmbusmeters.d
|
||||
--useconfig defaults to the root /etc
|
||||
--exitafter=20h program exits after running for twenty hours,
|
||||
or 10m for ten minutes or 5s for five seconds.
|
||||
|
||||
Specifying auto as the device will automatically look for usb
|
||||
wmbus dongles on /dev/im871a and /dev/amb8465.
|
||||
|
||||
You can specify the device rtlwmbus to have wmbusmeters spawn rtl_sdr|rtlwmbus
|
||||
|
||||
Supported water meters:
|
||||
Kamstrup Multical 21 (multical21)
|
||||
Kamstrup flowIQ 3100 (flowiq3100)
|
||||
|
|
|
@ -84,12 +84,29 @@ unique_ptr<Configuration> parseCommandLine(int argc, char **argv) {
|
|||
i++;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "--useconfig")) {
|
||||
c->useconfig = true;
|
||||
if (!strncmp(argv[i], "--useconfig", 11)) {
|
||||
if (strlen(argv[i]) == 11)
|
||||
{
|
||||
c->useconfig = true;
|
||||
c->config_root = "";
|
||||
return unique_ptr<Configuration>(c);
|
||||
}
|
||||
else if (strlen(argv[i]) > 12 && argv[i][11] == '=')
|
||||
{
|
||||
size_t len = strlen(argv[i]) - 12;
|
||||
c->useconfig = true;
|
||||
c->config_root = string(argv[i]+12, len);
|
||||
return unique_ptr<Configuration>(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("You must supply a directory to --useconfig=dir\n");
|
||||
}
|
||||
i++;
|
||||
if (i > 1 || argc > 2) {
|
||||
error("Usage error: --useconfig implies no other arguments on the command line.\n");
|
||||
}
|
||||
return unique_ptr<Configuration>(c);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "--reload")) {
|
||||
c->reload = true;
|
||||
|
|
|
@ -187,10 +187,15 @@ unique_ptr<Configuration> loadConfiguration(string root)
|
|||
{
|
||||
Configuration *c = new Configuration;
|
||||
|
||||
// JSon is default when configuring from config files.
|
||||
c->json = true;
|
||||
|
||||
vector<char> global_conf;
|
||||
loadFile(root+"/etc/wmbusmeters.conf", &global_conf);
|
||||
bool ok = loadFile(root+"/etc/wmbusmeters.conf", &global_conf);
|
||||
global_conf.push_back('\n');
|
||||
|
||||
if (!ok) exit(1);
|
||||
|
||||
auto i = global_conf.begin();
|
||||
|
||||
for (;;) {
|
||||
|
|
|
@ -47,6 +47,7 @@ struct Configuration {
|
|||
bool daemon {};
|
||||
std::string pid_file;
|
||||
bool useconfig {};
|
||||
std::string config_root;
|
||||
bool reload {};
|
||||
bool need_help {};
|
||||
bool silence {};
|
||||
|
|
16
src/main.cc
16
src/main.cc
|
@ -60,7 +60,10 @@ int main(int argc, char **argv)
|
|||
printf(" --meterfiles defaults dir to /tmp.\n");
|
||||
printf(" --shell=cmd invokes cmd with env variables containing the latest reading.\n");
|
||||
printf(" --shellenvs list the env variables available for the meter.\n");
|
||||
printf(" --oneshot wait for an update from each meter, then quit.\n\n");
|
||||
printf(" --oneshot wait for an update from each meter, then quit.\n");
|
||||
printf(" --useconfig=dir look for configuration file in dir/etc/wmbusmeters.conf and\n");
|
||||
printf(" dir/etc/wmbusmeters.d\n");
|
||||
printf(" --useconfig defaults to the root /etc\n");
|
||||
printf(" --exitafter=20h program exits after running for twenty hoursh\n"
|
||||
" or 10m for ten minutes or 5s for five seconds.\n");
|
||||
printf(" --useconfig read from /etc/wmbusmeters.conf and /etc/wmbusmeters.d\n");
|
||||
|
@ -70,6 +73,9 @@ int main(int argc, char **argv)
|
|||
|
||||
printf("Specifying auto as the device will automatically look for usb\n");
|
||||
printf("wmbus dongles on /dev/im871a and /dev/amb8465\n\n");
|
||||
|
||||
printf("You can specify the device rtlwmbus to have wmbusmeters spawn rtl_sdr|rtlwmbus\n\n");
|
||||
|
||||
printf("The meter types: multical21,flowiq3100,supercom587,iperl (water meters) are supported.\n"
|
||||
"The meter types: multical302 (heat) and omnipower (electricity) qcaloric (heat cost)\n"
|
||||
"are work in progress.\n\n");
|
||||
|
@ -81,13 +87,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
else
|
||||
if (cmdline->useconfig) {
|
||||
// This is primarily used for testing.
|
||||
const char *r = getenv("WMBUSMETERS_CONFIG_ROOT");
|
||||
string root = "";
|
||||
if (r != NULL) {
|
||||
root = r;
|
||||
}
|
||||
startUsingConfigFiles(root, false);
|
||||
startUsingConfigFiles(cmdline->config_root, false);
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -563,6 +563,7 @@ bool loadFile(string file, vector<char> *buf)
|
|||
|
||||
int fd = open(file.c_str(), O_RDONLY);
|
||||
if (fd == -1) {
|
||||
warning("Could not open file %s errno=%d\n", file.c_str(), errno);
|
||||
return false;
|
||||
}
|
||||
while (true) {
|
||||
|
|
|
@ -6,7 +6,7 @@ mkdir -p $TEST
|
|||
|
||||
cat simulations/simulation_c1.txt | grep '^{' > $TEST/test_expected.txt
|
||||
|
||||
WMBUSMETERS_CONFIG_ROOT=tests/config1 $PROG --useconfig > $TEST/test_output.txt
|
||||
$PROG --useconfig=tests/config1 > $TEST/test_output.txt
|
||||
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
|
|
|
@ -6,7 +6,7 @@ rm -f $TEST/thelog2.txt
|
|||
rm -rf $TEST/meter_readings2
|
||||
mkdir -p $TEST/meter_readings2
|
||||
|
||||
WMBUSMETERS_CONFIG_ROOT=tests/config2 $PROG --useconfig
|
||||
$PROG --useconfig=tests/config2
|
||||
|
||||
ERRORS=false
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue