# library(lubridate)
# library(dplyr)
# library(dygraphs)
# reticulate::use_python('/usr/bin/python3', required = T)
# devtools::load_all()
#
#
#
# # Sys.setenv('PYTHON3_PATH' = Sys.which('python'))
#
# # Data preparation --------------------------------------------------------
#
# # Data parameters
# tzone <- 'Europe/Amsterdam' # Already in this timezone
# dates <- unique(date(solar$datetime))
# time_interval <- 15 # In minutes
#
# # Optimization parameters
# window_start_hour <- 6 # Optimization from 6am-6am
# window_length_hours <- 24# hours
# window_length <- 60/time_interval*window_length_hours
# n_windows <- length(dates) - 1
# start_day <- dates[1]
# start_time <- force_tz(as_datetime(start_day), tzone) + hours(window_start_hour)
# end_time <- start_time + hours(window_length_hours*n_windows) - minutes(time_interval)
# # Resting a time interval to give a multiple length of the window size to the datetime_seq vector
# datetime_seq <- seq.POSIXt(from = start_time, to = end_time, by = paste(time_interval, "min"))
# window <- c(0, length(datetime_seq)) %>% as.integer
#
# # Get demand
# demand <- get_demand(sessions, datetime_seq)
#
#
#
# solar <- solar %>% mutate(solar = solar*3)
#
# # Optimization setup
# opt_weights <- tibble(
# profile = c('Pillow', 'Home', 'Worktime', 'Visit'),
# w1 = c(1, 1, 1, 1),
# w2 = c(0, 0, 0, 0)
# )
# responsive <- list(Pillow = 1, Home = 1, Worktime = 1, Visit = 1)
#
#
# # Smart Charging
# results <- smart_charging(sessions, solar, datetime_seq, window_length, opt_weights, responsive, power_th=1)
# setpoints <- results$setpoints
# opt_demand <- get_demand(results$sessions, datetime_seq)
#
# tibble(
# datetime = datetime_seq,
# solar = rowSums(solar[solar$datetime %in% datetime_seq, -1]),
# setpoints = rowSums(setpoints[-1]),
# demand = rowSums(demand[-1]),
# opt_demand = rowSums(opt_demand[-1])
# ) %>%
# df_to_ts() %>%
# dygraph() %>%
# dyOptions(fillGraph = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.