diff --git a/laundry_status.R b/laundry_status.R index 619a7ec..97af877 100644 --- a/laundry_status.R +++ b/laundry_status.R @@ -31,7 +31,8 @@ update_data <- function(){ status = ifelse(value > 1, "on", "off")) %>% mutate(end_time = time + minutes(1)) - + washer_last_on <- values %>% filter(entity_id == entities$entity_id[1], value > 5) %>% tail(1) %>% pull(time) + washer_last_off <- values %>% filter(entity_id == entities$entity_id[1], value < 5) %>% tail(1) %>% pull(time) # ---- generate html current_status <- as.list(NULL) for (entity in entities$entity_id){ diff --git a/laundry_status.Rmd b/laundry_status.Rmd index de4c2b3..14bd2a1 100644 --- a/laundry_status.Rmd +++ b/laundry_status.Rmd @@ -8,7 +8,7 @@ updated: `r format(Sys.time(), format = "%A %I:%M %p", tz = "America/Chicago")` this site updates every `r update_interval` minutes ## The washing machine is currently: `r current_status[["lamp_a_power"]]` - +The washing machine `r ifelse(current_status$lamp_a_power=="on", "started", "ended")` its most recent cycle at `r format(ifelse(current_status$lamp_a_power=="on", washer_last_on, washer_last_off), format = "%A %I:%M %p", tz = "America/Chicago")` ## The dryer is currently: `r current_status[["lamp_b_power"]]` --------