-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define MQTT and sensor configuration separately from implementation
The data logger uses a YAML file now, for example like `etc/mois.yaml`. You will then invoke it like: ds18b20-datalogger run etc/mois.yaml
- Loading branch information
Showing
11 changed files
with
300 additions
and
214 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,8 +1,10 @@ | ||
# Backlog for ds18b20-datalogger | ||
|
||
## Iteration +1 | ||
- Improve documentation | ||
- Publish to PyPI | ||
|
||
## Done | ||
- Better software tests | ||
- Break out sensor mapping configuration from code | ||
to make it re-usable across different setups | ||
- Improve documentation | ||
- Publish to PyPI |
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,7 +1,22 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
from ds18b20_datalogger.core import read_ds18b20_sensor_matrix, send_measurement_mqtt | ||
from ds18b20_datalogger.model import Settings | ||
|
||
|
||
def main(): | ||
reading = read_ds18b20_sensor_matrix() | ||
send_measurement_mqtt(reading) | ||
# print(strftime("%Y-%m-%d %H:%M:%S", time.localtime())," Done sending. Going to sleep for 15min.") # noqa: ERA001 | ||
if not sys.argv[1:]: | ||
raise ValueError("Program needs a subcommand") | ||
subcommand = sys.argv[1] | ||
if subcommand == "run": | ||
if not sys.argv[2:]: | ||
raise ValueError("Program needs a configuration file") | ||
configfile = Path(sys.argv[2]) | ||
if not configfile.exists(): | ||
raise ValueError(f"Configuration file does not exist: {configfile}") | ||
settings = Settings.from_file(configfile) | ||
reading = read_ds18b20_sensor_matrix(settings.devicemap) | ||
send_measurement_mqtt(settings.mqtt, reading) | ||
else: | ||
raise ValueError(f"Subcommand unknown: {subcommand}") |
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.