Learn R Programming

Open PhilipsHue documentation site

PhilipsHue: an R client for the Philips Hue API

The Philips Hue API provides fine-grained control over your Hue lighting system, and the PhilipsHue package for R aims to simplify making requests to the API and processing responses. The package provides wrappers for all V1 endpoints using local authentication; remote authentication is not supported.

Installation

Install directly from GitHub with:

devtools::install_github("fascinatingfingers/PhilipsHue")
library(PhilipsHue)

Getting started

To connect to your Hue Bridge, you'll need to discover the Bridge IP address and create a username. See vignette("local_authentication") for more detailed instructions. Once you have these values, you can use auth_local() to save them as environment variables.

auth_local(ip = "999.999.999.999", username = "<Philips Hue username>")

Here are some examples of what you can do once you've set your credentials.

# # Delete and re-add all lights (Warning!)
# purrr::map_lgl(names(get_lights()), delete_light)
# search_for_new_lights()
# get_new_lights()

# Rename a light
rename_light("1", "Table lamp")

# Create a room
group_id <- create_group(
    name = "Living room",
    type = "Room",
    class = "Living room",
    lights = as.character(1:4)
)

# Define a scene
scene_id <- create_scene("Default", as.character(1:4))
purrr::map_lgl(
    as.character(1:4),
    set_scene_lightstate, scene_id = scene_id,
    on = TRUE, bri = 134, ct = 316
)

# Configure a switch to turn on the scene
sensor_id <- 42
create_rule(
    name = "Living room - Default",
    conditions = list(
        condition(sprintf("/sensors/%s/state/buttonevent", sensor_id), "eq", "1002"),
        condition(sprintf("/sensors/%s/state/lastupdated", sensor_id), "dx")
    ),
    actions = list(
        action(sprintf("/groups/%s/action", group_id), "PUT", scene = scene_id)
    )
)

Copy Link

Version

Install

install.packages('PhilipsHue')

Monthly Downloads

101

Version

1.0.0

License

GPL (>= 3)

Maintainer

Last Published

May 6th, 2022

Functions in PhilipsHue (1.0.0)

capabilities

Hue API: capabilities endpoints
configure_daylight_sensor

Configure Built-In Daylight Sensor
schedules

Hue API: schedules endpoints
configs

Hue API: configuration endpoints
scenes

Hue API: scenes endpoints
create_user

Create local user
sensors

Hue API: sensors endpoints
groups

Hue API: groups endpoints
rule_helpers

Rule Helpers
rules

Hue API: rules endpoints
resourcelinks

Hue API: resourcelinks endpoints
lights

Hue API: lights endpoints
auth_helpers

Authentication helpers
PhilipsHue-package

PhilipsHue: R Interface to the Philips Hue API
auth_local

Authentication -- local