#' Check if given id is valid
#'
#' @param id If numeric, numeric id of light. If character, name of light. You can check id and names with `hue_get_lights_names()`
#'
#' @return Always return an integer corresponding to a given light.
#' @export
#'
#' @examples
hue_output_id <- function(id) {
if (is.numeric(id) == TRUE) {
return(id)
} else {
id_number <- which(hue_get_lights_names() == id)
if (length(id_number) == 0) {
usethis::ui_stop("id must either be an integer or the exact name of an existing light.")
} else {
return(as.numeric(names(id_number)))
}
}
}
#' Check if given id is valid
#'
#' @param id If numeric, numeric id of light. If character, name of light. You can check id and names with `hue_get_lights_names()`
#'
#' @return Always return an integer corresponding to a given light.
#' @export
#'
#' @examples
hue_output_group_id <- function(id) {
if (is.numeric(id) == TRUE) {
return(id)
} else {
id_number <- which(hue_get_groups_names() == id)
if (length(id_number) == 0) {
usethis::ui_stop("id must either be an integer or the exact name of an existing group.")
} else {
return(as.numeric(names(id_number)))
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.