edits
This commit is contained in:
parent
d9e7c626e3
commit
9ea39018ee
@ -3,7 +3,11 @@ library(tidyverse)
|
|||||||
library(influxdbclient)
|
library(influxdbclient)
|
||||||
library(rmarkdown)
|
library(rmarkdown)
|
||||||
|
|
||||||
|
if(test) {
|
||||||
|
setwd("~/Documents/dataProjects/laundry_status")
|
||||||
|
} else {
|
||||||
setwd("/laundry_status")
|
setwd("/laundry_status")
|
||||||
|
}
|
||||||
Sys.setenv(TZ='America/Chicago')
|
Sys.setenv(TZ='America/Chicago')
|
||||||
# parameters needed to make connection to Database
|
# parameters needed to make connection to Database
|
||||||
token <- substr(read_file("data/api_key"), 1, 88)
|
token <- substr(read_file("data/api_key"), 1, 88)
|
||||||
@ -33,6 +37,9 @@ update_data <- function(){
|
|||||||
|
|
||||||
washer_last_on <- values %>% filter(entity_id == entities$entity_id[1], value > 5) %>% tail(1) %>% pull(time)
|
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)
|
washer_last_off <- values %>% filter(entity_id == entities$entity_id[1], value < 5) %>% tail(1) %>% pull(time)
|
||||||
|
|
||||||
|
dryer_last_on <- values %>% filter(entity_id == entities$entity_id[2], value > 5) %>% tail(1) %>% pull(time)
|
||||||
|
dryer_last_off <- values %>% filter(entity_id == entities$entity_id[2], value < 5) %>% tail(1) %>% pull(time)
|
||||||
# ---- generate html
|
# ---- generate html
|
||||||
current_status <- as.list(NULL)
|
current_status <- as.list(NULL)
|
||||||
for (entity in entities$entity_id){
|
for (entity in entities$entity_id){
|
||||||
|
@ -10,14 +10,20 @@ this site updates every `r update_interval` minutes
|
|||||||
## The washing machine is currently: `r current_status[["lamp_a_power"]]`
|
## 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 ifelse(current_status$lamp_a_power=="on", strftime(washer_last_off, format = "%A %I:%M %p", tz = "America/Chicago"), strftime(washer_last_on, format = "%A %I:%M %p", tz = "America/Chicago"))`
|
The washer `r ifelse(current_status$lamp_a_power=="on", "started", "ended")` its most recent cycle at `r ifelse(current_status$lamp_a_power=="on", strftime(washer_last_off, format = "%A %I:%M %p", tz = "America/Chicago"), strftime(washer_last_on, format = "%A %I:%M %p", tz = "America/Chicago"))`
|
||||||
:
|
:
|
||||||
`r ifelse(current_status$lamp_a_power=="on", difftime(Sys.Time(), washer_last_on), difftime(Sys.Time(), washer_last_off)`
|
`r ifelse(current_status$lamp_a_power=="on", round(difftime(Sys.time(), washer_last_off, unit = "mins"),0), round(difftime(Sys.time(), washer_last_on, units = "mins"),0))`
|
||||||
ago
|
minutes ago
|
||||||
|
|
||||||
|
|
||||||
## The dryer is currently: `r current_status[["lamp_b_power"]]`
|
## The dryer is currently: `r current_status[["lamp_b_power"]]`
|
||||||
|
|
||||||
|
|
||||||
|
The dryer `r ifelse(current_status$lamp_b_power=="on", "started", "ended")` its most recent cycle at `r ifelse(current_status$lamp_b_power=="on", strftime(dryer_last_off, format = "%A %I:%M %p", tz = "America/Chicago"), strftime(dryer_last_on, format = "%A %I:%M %p", tz = "America/Chicago"))`
|
||||||
|
:
|
||||||
|
`r ifelse(current_status$lamp_b_power=="on", round(difftime(Sys.time(), dryer_last_off, unit = "mins"),0), round(difftime(Sys.time(), dryer_last_on, units = "mins"),0))`
|
||||||
|
minutes ago
|
||||||
|
|
||||||
--------
|
--------
|
||||||
```{r setup, include=FALSE}
|
```{r setup, include=FALSE}
|
||||||
knitr::opts_chunk$set(echo = TRUE)
|
knitr::opts_chunk$set(echo = TRUE)
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user