Skip to content

Commit

Permalink
Basic functionality is working.
Browse files Browse the repository at this point in the history
  • Loading branch information
orium committed Dec 18, 2023
1 parent 48f4e26 commit 09e6cce
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 16 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@

<!-- cargo-rdme start -->

TODO
Brewfatherlog is a small tool to synchronize the temperatures of your Grainfather fermenters to Brewfather.

## Instalation

Brewfatherlog can be installed via `cargo` with:

```bash
cargo install brewfatherlog
```

You can also get a binary from the [releases page](https://github.com/orium/brewfatherlog/releases/).

### Configuration

On the first run Brewfatherlog will create a configuration file in your configuration directory (in POSIX systems
that should be in `~/.config/`). You will need to edit that file to configure authentication for both Grainfather
and Brewfather.

WIP! talk about enabling streaming logging in brewfather.

### Systemd daemon

WIP!

<!-- cargo-rdme end -->
3 changes: 3 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Release notes

## 0.0.0

* Basic implementation of the functionality.
1 change: 1 addition & 0 deletions src/default-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ email = ""
password = ""

[brewfather]
# WIP! explain here how to setup brewfather.
logging_id = ""
57 changes: 42 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,66 @@

#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

//! TODO
//! Brewfatherlog is a small tool to synchronize the temperatures of your Grainfather fermenters to Brewfather.
//!
//! # Instalation
//!
//! Brewfatherlog can be installed via `cargo` with:
//!
//! ```bash
//! cargo install brewfatherlog
//! ```
//!
//! You can also get a binary from the [releases page](https://github.com/orium/brewfatherlog/releases/).
//!
//! ## Configuration
//!
//! On the first run Brewfatherlog will create a configuration file in your configuration directory (in POSIX systems
//! that should be in `~/.config/`). You will need to edit that file to configure authentication for both Grainfather
//! and Brewfather.
//!
//! WIP! talk about enabling streaming logging in brewfather.
//!
//! ## Systemd daemon
//!
//! WIP!
mod config;

use crate::config::Config;
use brewfatherlog::brewfather::{Brewfather, BrewfatherLoggingEvent};
use brewfatherlog::grainfather::Grainfather;
use std::time::Duration;
use tokio::time::sleep;

#[tokio::main]
async fn main() {
Config::create_file_if_nonexistent();
// WIP! if the file did not exist we should print a nice message telling the user to edit the file and exit.

let config: Config = Config::from_config_file();

if false {
let brewfather = Brewfather::new(config.brewfather.logging_id);
let brewfather = Brewfather::new(config.brewfather.logging_id);

let event = BrewfatherLoggingEvent { name: "Ferm 1".to_owned(), temp: 21.1 };
loop {
let grainfather =
Grainfather::new(&config.grainfather.auth.email, &config.grainfather.auth.password)
.await
.unwrap();

let r = brewfather.log(event).await;
let ferms = grainfather.list_fermenters().await.unwrap();

println!("result: {:?}", r);
}
for ferm in ferms {
let temp = grainfather.get_fermenter_temperature(ferm.id).await.unwrap().unwrap();

println!("{} {} C", ferm.name, temp.temperature);

let grainfather =
Grainfather::new(&config.grainfather.auth.email, &config.grainfather.auth.password)
.await
.unwrap();
let event = BrewfatherLoggingEvent { name: ferm.name, temp: temp.temperature };

let ferms = grainfather.list_fermenters().await.unwrap();
let r = brewfather.log(event).await;
println!(" log result: {:?}", r);
}

for ferm in ferms {
let temp = grainfather.get_fermenter_temperature(ferm.id).await.unwrap().unwrap();
println!("{} {} C", ferm.name, temp.temperature);
sleep(Duration::from_secs(15 * 60 + 1)).await;
}
}

0 comments on commit 09e6cce

Please sign in to comment.