Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Ping module to information output; added Status for Battery #113

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/bat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use tokio::time::interval;

use crate::nextcloud::NextcloudChat;
use crate::nextcloud::NextcloudEvent;
use crate::nextcloud::NextcloudStatus;
use crate::types::ModuleError;

const START_CAPACITY_THRESHOLD: u8 = 50;
Expand All @@ -24,7 +25,7 @@ pub struct Bat {
impl Bat {
pub fn new() -> Self {
Self {
capacity: 0,
capacity: 100,
capacity_threshold: START_CAPACITY_THRESHOLD,
}
}
Expand All @@ -48,6 +49,12 @@ impl Bat {
if new_capacity != self.capacity {
self.capacity = new_capacity;
if self.capacity < self.capacity_threshold {
nextcloud_sender
.send(NextcloudEvent::Status(
NextcloudStatus::Online,
gettext!("🪫 ON {}", self.capacity),
))
.await?;
nextcloud_sender
.send(NextcloudEvent::Chat(
NextcloudChat::Default,
Expand All @@ -65,6 +72,12 @@ impl Bat {
}
} else if self.capacity == 100 {
self.capacity_threshold = START_CAPACITY_THRESHOLD;
nextcloud_sender
.send(NextcloudEvent::Status(
NextcloudStatus::Online,
gettext!("🔋 ON {}", self.capacity),
))
.await?;
nextcloud_sender
.send(NextcloudEvent::Chat(
NextcloudChat::Default,
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ async fn main() -> Result<(), ModuleError> {

nextcloud_sender.send(
NextcloudEvent::Chat(NextcloudChat::Default,
gettext!("Enabled Modules: \nButtons: {}\n, Garage: {}\n, Sensors: {}\n, ModIR: {}\n, Environment: {}\n, Weatherstation: {}\n, Battery: {}\n, Watchdog: {}\n",
gettext!("Enabled Modules: \nButtons: {},\n Garage: {},\n Sensors: {},\n ModIR: {},\n Environment: {},\n Weatherstation: {},\n Battery: {},\n Watchdog: {},\n Ping: {}\n",
buttons_enabled,
garage_enabled,
sensors_enabled,
Expand All @@ -237,6 +237,7 @@ async fn main() -> Result<(), ModuleError> {
weatherstation_enabled,
bat_enabled,
watchdog_enabled,
ping_enabled,
))).await?;

join_all(tasks).await;
Expand Down