-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from heubeck/feature/MySqlSupport
feat(backend): Add MySql support
- Loading branch information
Showing
12 changed files
with
1,600 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# SaMLer | ||
|
||
The SaMLer is reading SML messages produced by a smart meter from a serial device and publishes it to InfluxDB. | ||
The SaMLer is reading SML messages produced by a smart meter from a serial device and publishes it to a backend like InfluxDB or MySQL. | ||
|
||
## Dependencies | ||
|
||
|
@@ -17,28 +17,45 @@ SaMLer is configured using environment variables, just run it, to let it print i | |
|
||
```shell | ||
> ./samler.amd64 | ||
SaMLer; configure via ENV: | ||
SAMLER_INFLUX_TOKEN (default: ) | ||
SAMLER_INFLUX_ORG (default: ) | ||
SAMLER_INFLUX_MEASUREMENT (default: power) | ||
SAMLER_CACHE_PATH (default: /home/heubeck/.samler) | ||
SaMLer v0.3.0 Copyright (C) 2022 Florian Heubeck | ||
This program comes with ABSOLUTELY NO WARRANTY. | ||
This is free software, and you are welcome to redistribute it under certain conditions. | ||
|
||
# Configuration options, set them as ENV: | ||
SAMLER_MYSQL_DSN (default: -) | ||
SAMLER_DEVICE_BAUD_RATE (default: 9600) | ||
SAMLER_DEVICE_MODE (default: 8-N-1) | ||
SAMLER_DEBUG (default: false) | ||
SAMLER_INFLUX_URL (default: ) | ||
SAMLER_INFLUX_URL (default: -) | ||
SAMLER_INFLUX_TOKEN (default: -) | ||
SAMLER_INFLUX_BUCKET (default: home) | ||
SAMLER_INFLUX_MEASUREMENT (default: power) | ||
SAMLER_MYSQL_TABLE (default: home_power) | ||
SAMLER_DEVICE (default: /dev/ttyUSB0) | ||
SAMLER_DEBUG (default: false) | ||
SAMLER_CACHE_PATH (default: /home/heubeck/.samler) | ||
SAMLER_BACKEND (options: influx, mysql) | ||
SAMLER_INFLUX_ORG (default: -) | ||
|
||
Please set all values without default depending on the chosen backend | ||
``` | ||
|
||
A minimalistic run script using [Influx Cloud](https://cloud2.influxdata.com/) may look like: | ||
|
||
```shell | ||
#!/bin/bash | ||
SAMLER_BACKEND=influx \ | ||
SAMLER_INFLUX_URL=https://region.provider.cloud2.influxdata.com \ | ||
SAMLER_INFLUX_TOKEN=thisIsVerySecret== \ | ||
[email protected] \ | ||
/opt/samler.arm-v7 | ||
``` | ||
|
||
export SAMLER_INFLUX_URL=https://region.provider.cloud2.influxdata.com | ||
export SAMLER_INFLUX_TOKEN=thisIsVerySecret== | ||
export [email protected] | ||
With MySQL the script can look like, the target table is created automatically if it doesn't exist: | ||
|
||
```shell | ||
#!/bin/bash | ||
SAMLER_BACKEND=mysql \ | ||
SAMLER_MYSQL_DSN=user:password@tcp(your-database-host:3306)/samler \ | ||
/opt/samler.arm-v7 | ||
``` | ||
|
||
|
@@ -65,11 +82,11 @@ WantedBy=multi-user.target | |
* By now, there's only a single serial mode supported what's reflected in the configuration defaults: | ||
_Baud rate `9600` and mode `8-N-1` (8 data bits, 1 stop bit, none parity)_ | ||
That needs to be generalized. | ||
* Smart Meter data is properitary to electric power meter, as that's the only one I have running SaMLer right now. | ||
* Smart Meter data may be properitary to electric power meter, as that's the only one I have tested SaMLer with right now. | ||
Please file [issues](https://github.com/heubeck/samler/issues) with devices you'd like to read. | ||
* Timing values are hard coded and should made configurable on demand. | ||
* My C and Go skills are only rudimentary, don't hesitate to point out improvements. | ||
* The only supported backend is InfluxDB by now, but it's prepared to support more in the future, just file an [issues](https://github.com/heubeck/samler/issues). | ||
* The only supported backends are InfluxDB and MySQL by now, but it's prepared to support more, just file an [issues](https://github.com/heubeck/samler/issues). | ||
|
||
## Contribution | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.