added time x day chart
This commit is contained in:
parent
7d537bb4f1
commit
0e49a2686e
@ -70,12 +70,13 @@ update_data <- function(){
|
||||
|
||||
dryer_last_on <- values %>% filter(entity_id == entities$entity_id[2], value > power_threshhold) %>% tail(1) %>% pull(end_time)
|
||||
dryer_last_off <- values %>% filter(entity_id == entities$entity_id[2], value < power_threshhold) %>% tail(1) %>% pull(end_time)
|
||||
# ---- generate html
|
||||
|
||||
current_status <- as.list(NULL)
|
||||
for (entity in entities$entity_id){
|
||||
current_status[[entity]] <- ifelse(values %>% filter(entity_id %in% entity) %>% tail(1) %>% pull(value) > power_threshhold, "on", "off")
|
||||
}
|
||||
|
||||
# ---- make plots
|
||||
plot_1day <- ggplot(data = values %>% filter(time >= max(values$end_time) - hours(24))) +
|
||||
geom_tile(aes(x = time + seconds(round(as.numeric(difftime(end_time, time, unit = "secs")))/2),
|
||||
y = entity_id,
|
||||
@ -104,7 +105,26 @@ update_data <- function(){
|
||||
y = NULL,
|
||||
fill = NULL)
|
||||
|
||||
plot_1week_days <- ggplot(data = values %>%
|
||||
filter(as.Date(time, tz = "America/Chicago") == as.Date(end_time, tz = "America/Chicago")) %>%
|
||||
mutate(date = as.Date(time, tz = "America/Chicago")) %>%
|
||||
left_join(. , entities, by = join_by(entity_id)) %>%
|
||||
mutate(name = factor(name, levels = c("washing machine", "dryer")))) +
|
||||
geom_rect(aes(xmin = date - hours(8),
|
||||
xmax = date + hours(8),
|
||||
ymin = ymd_hms(paste("2023-01-01", strftime(time, format = "%H:%M:%S"))),
|
||||
ymax = ymd_hms(paste("2023-01-01", strftime(end_time, format = "%H:%M:%S"))),
|
||||
fill = status)) +
|
||||
facet_grid(name ~ .) +
|
||||
scale_y_datetime(date_breaks = "4 hours", date_labels = '%I:%M %p', minor_breaks = "2 hours", expand = expansion(mult = 0)) +
|
||||
scale_x_datetime(date_breaks = "1 day", date_labels = '%A', minor_breaks = NULL) +
|
||||
theme(axis.text.x = element_text(angle = 30, vjust = 0.5)) +
|
||||
labs(title = "The past week",
|
||||
x = "Day",
|
||||
y = "Time of Day",
|
||||
fill = NULL)
|
||||
|
||||
# ---- generate html
|
||||
render("laundry_status.Rmd",
|
||||
output_dir = "html",
|
||||
output_file = "index.html")
|
||||
|
@ -39,4 +39,7 @@ plot(plot_1day)
|
||||
plot(plot_1week)
|
||||
```
|
||||
|
||||
If you have any issues or questions, please email `admin@dendroalsia.net`
|
||||
```{r plot_1week_days, echo=FALSE}
|
||||
plot(plot_1week_days)
|
||||
```
|
||||
If you have any issues or questions, please email `ben@dendroalsia.net`
|
||||
|
Loading…
x
Reference in New Issue
Block a user