Huex

Elixir client for Philips Hue connected light bulbs.

Query functions return the response from the API.

Command functions return a Bridge struct in order to be pipeline friendly.

Read more on the GitHub page.

Summary

Types

Tuple containing respectively the hue (0-65535), staturation (0-255) and value/brillance (0-255) components

Light identifier can be either a numberic or a binary (e.g. “1”)

Possible status of a Bridge

Tuple containing the x and y component of the color

Functions

Requests authorization for the given username on the given bridge. Returns an “authorized” connection

Creates a connection with the bridge available on the given host or IP address. Requires the connection to be authorized

Fetches all informations available in the bridge

Fetches all informations available about the given light connected to the bridge. Requires the connection to be authorized

Lists the lights connected to the given bridge. Requires the connection to be authorized

Sets the brigthness of the given light (a value between 0 and 1). Requires the connection to be authorized

Sets the brigthness of the given light (a value between 0 and 1) using the given transition time (in ms). Requires the connection to be authorized

Sets the color of the given light using Philips’ proprietary bi-dimensional color space. Requires the connection to be authorized

Sets the color of the given light using Philips’ proprietary bi-dimensional color space using the given transition time (in ms). Requires the connection to be authorized

Sets the state of the given light. For a list of accepted keys, look at the state object in the response of light_info Requires the connection to be authorized

Turns the given light off. Requires the connection to be authorized

Turns the given light off using the given transition time (in ms). Requires the connection to be authorized

Turns the given light on. Requires the connection to be authorized

Turns the given light on using the given transition time (in ms). Requires the connection to be authorized

Types

bridge :: Bridge.t
hsv_color :: {non_neg_integer, non_neg_integer, non_neg_integer}

Tuple containing respectively the hue (0-65535), staturation (0-255) and value/brillance (0-255) components

light :: non_neg_integer | binary

Light identifier can be either a numberic or a binary (e.g. “1”)

status :: nil | :ok | :error

Possible status of a Bridge

xy_color :: {float, float}

Tuple containing the x and y component of the color

Functions

authorize(bridge, username)

Specs

authorize(bridge, binary) :: bridge

Requests authorization for the given username on the given bridge. Returns an “authorized” connection.

The authorization process is as follow:

  1. Call authorize once, it will return an error
  2. Press the link button on top of your bridge device
  3. Call authorize again with the same parameters, it should succeed
connect(host, username \\ nil)

Specs

connect(binary, binary) :: bridge

Creates a connection with the bridge available on the given host or IP address. Requires the connection to be authorized.

info(bridge)

Specs

info(bridge) :: Map.t

Fetches all informations available in the bridge.

light_info(bridge, light)

Specs

light_info(bridge, light) :: Map.t

Fetches all informations available about the given light connected to the bridge. Requires the connection to be authorized.

lights(bridge)

Specs

lights(bridge) :: Map.t

Lists the lights connected to the given bridge. Requires the connection to be authorized.

set_brightness(bridge, light, brightness)

Specs

set_brightness(bridge, light, float) :: bridge

Sets the brigthness of the given light (a value between 0 and 1). Requires the connection to be authorized.

set_brightness(bridge, light, brightness, transition_time_ms)

Specs

set_brightness(bridge, light, float, non_neg_integer) :: bridge

Sets the brigthness of the given light (a value between 0 and 1) using the given transition time (in ms). Requires the connection to be authorized.

set_color(bridge, light, arg)

Specs

set_color(bridge, light, xy_color) :: bridge
set_color(bridge, light, hsv_color) :: bridge

Sets the color of the given light using Philips’ proprietary bi-dimensional color space. Requires the connection to be authorized.

set_color(bridge, light, arg, transition_time_ms)

Specs

set_color(bridge, light, xy_color, non_neg_integer) :: bridge
set_color(bridge, light, hsv_color, non_neg_integer) :: bridge

Sets the color of the given light using Philips’ proprietary bi-dimensional color space using the given transition time (in ms). Requires the connection to be authorized.

set_state(bridge, light, new_state)

Specs

set_state(bridge, light, Map.t) :: bridge

Sets the state of the given light. For a list of accepted keys, look at the state object in the response of light_info Requires the connection to be authorized.

turn_off(bridge, light)

Specs

turn_off(bridge, light) :: bridge

Turns the given light off. Requires the connection to be authorized.

turn_off(bridge, light, transition_time_ms)

Specs

turn_off(bridge, light, non_neg_integer) :: bridge

Turns the given light off using the given transition time (in ms). Requires the connection to be authorized.

turn_on(bridge, light)

Specs

turn_on(bridge, light) :: bridge

Turns the given light on. Requires the connection to be authorized.

turn_on(bridge, light, transition_time_ms)

Specs

turn_on(bridge, light, non_neg_integer) :: bridge

Turns the given light on using the given transition time (in ms). Requires the connection to be authorized.