Skip to content

Latest commit

 

History

History
159 lines (111 loc) · 3.94 KB

README.md

File metadata and controls

159 lines (111 loc) · 3.94 KB

huecontroller

Lifecycle: experimental

huecontroller allows to easily control Philips Hue lights from R.

It has intuitive commands that make it easy to make common tasks such as turning lights on or off and changing brightness or light temperature.

It is functional and can be used to adjust lights at home.

It has a shiny app that allows for controlling light and temperature of lights, hue_shiny_controller() (you need to use hue_settings() with your settings first).

huecontroller can already be used for making video data visualisations, but sooner or later it will probably have a dedicated vignette and some more functions to make this easier.

Installation

You can install huecontroller with:

remotes::install_github("giocomai/huecontroller")

Basic use

First, you’ll need to get you username for the API’s detailed on the official website.

At the beginning of each session, set up parameters: actual ip of your bridge, and actual username as retrived via the instructions above.

library("huecontroller")


hue_settings(ip = "192.168.0.111",
             username = "actual_username_from_API")

With the following command, you will see all the names of your lights.

hue_get_lights_names()

In all huecontroller functions you will be able to refer to light indifferently using either their numeric id or their exact name.

Turn on and off.

hue_turn_light_on("Living Room 1")
hue_turn_light_off("Living Room 1")

Make light a bit brighter.

hue_set_light_brightness(id = "Living Room 1",
                         brightness = "+",
                         by = 10)

Set it to arbitrary birghtness (max = 254)

hue_set_light_brightness(id = "Living Room 1",
                         brightness = 254)

Make it warmer:

hue_set_light_temperature(id = "Living Room 1",
                          temperature = "+",
                          by = 10)

or colder:

hue_set_light_temperature(id = "Living Room 1",
                          temperature = "-",
                          by = 10)

or change colour completely:

hue_set_light_colour(id = "Living Room 1",
                     colour = "red")

Get and set anything available in the API for specific lights

The following command will output a list object with all available details shared by the APIs.

hue_get_light_state(id = "Living Room 1")

Details on the exact format of the lights API are available on the official website.

You can set any of them giving them as a list to hue_set_light_state(), e.g. like this:

hue_set_light_state(id = "Living Room 1",
                    params = list(on = TRUE,
                                  sat = 250, 
                                  bri = 250, 
                                  hue = 2000))

Keep in mind that if you want to identify lights by their numeric id, you should pass the argument as a numeric, not a character, e.g.

hue_set_light_state(id = 11, # not `id = "11"`
                    params = list(on = TRUE,
                                  sat = 250, 
                                  bri = 250, 
                                  hue = 2000))

You can achieve the same with groups:

hue_get_groups_names()

hue_set_group_state(id = 1, # not `id = "1"`
                    params = list(on = TRUE,
                                  sat = 250, 
                                  bri = 250, 
                                  hue = 2000))

Control all your lights from a browser with Shiny

hue_shiny_controller()