light.hue

class platypush.plugins.light.hue.LightHuePlugin(bridge, lights=None, groups=None)[source]

Bases: LightPlugin

Philips Hue lights plugin.

Requires:

  • phue (pip install phue)

Triggers:

class Animation(value)[source]

Bases: Enum

An enumeration.

__init__(bridge, lights=None, groups=None)[source]
Parameters:
  • bridge (str) – Bridge address or hostname

  • lights (list[str]) – Default lights to be controlled (default: all)

  • (default (groups Default groups to be controlled) – all)

animate(animation, duration=None, hue_range=None, sat_range=None, bri_range=None, lights=None, groups=None, hue_step=1000, sat_step=2, bri_step=1, transition_seconds=1.0)[source]

Run a lights animation.

Parameters:
  • animation (str) – Animation name. Supported types: color_transition and blink

  • duration (float) – Animation duration in seconds (default: None, i.e. continue until stop)

  • hue_range (list[int]) – If you selected a color_transition, this will specify the hue range of your color color_transition. Default: [0, 65535]

  • sat_range (list[int]) – If you selected a color color_transition, this will specify the saturation range of your color color_transition. Default: [0, 255]

  • bri_range – If you selected a color color_transition, this will specify the brightness range of your color color_transition. Default: [254, 255] :type bri_range: list[int]

  • lights – Lights to control (names, IDs or light objects). Default: plugin default lights

  • groups – Groups to control (names, IDs or group objects). Default: plugin default groups

  • hue_step – If you selected a color color_transition, this will specify by how much the color hue will change between iterations. Default: 1000 :type hue_step: int

  • sat_step – If you selected a color color_transition, this will specify by how much the saturation will change between iterations. Default: 2 :type sat_step: int

  • bri_step – If you selected a color color_transition, this will specify by how much the brightness will change between iterations. Default: 1 :type bri_step: int

  • transition_seconds (float) – Time between two transitions or blinks in seconds. Default: 1.0

bri(value, lights=None, groups=None, **kwargs)[source]

Set lights/groups brightness.

Parameters:
  • lights – Lights to control (names or light objects). Default: plugin default lights

  • groups – Groups to control (names or group objects). Default: plugin default groups

  • value – Brightness value (range: 0-255)

connect()[source]

Connect to the configured Hue bridge. If the device hasn’t been paired yet, uncomment the .connect() and .get_api() lines and retry after clicking the pairing button on your bridge.

ct(value, lights=None, groups=None, **kwargs)[source]

Set lights/groups color temperature.

Parameters:
  • value (int) – Temperature value (range: 0-255)

  • lights – List of lights.

  • groups – List of groups.

delta_bri(delta, lights=None, groups=None, **kwargs)[source]

Change lights/groups brightness by a delta [-100, 100] compared to the current state.

Parameters:
  • lights – Lights to control (names or light objects). Default: plugin default lights

  • groups – Groups to control (names or group objects). Default: plugin default groups

  • delta – Brightness delta value (range: -100, 100)

delta_hue(delta, lights=None, groups=None, **kwargs)[source]

Change lights/groups hue by a delta [-100, 100] compared to the current state.

Parameters:
  • lights – Lights to control (names or light objects). Default: plugin default lights

  • groups – Groups to control (names or group objects). Default: plugin default groups

  • delta – Hue delta value (range: -100, 100)

delta_sat(delta, lights=None, groups=None, **kwargs)[source]

Change lights/groups saturation by a delta [-100, 100] compared to the current state.

Parameters:
  • lights – Lights to control (names or light objects). Default: plugin default lights

  • groups – Groups to control (names or group objects). Default: plugin default groups

  • delta – Saturation delta value (range: -100, 100)

get_animations()[source]

Get the list of running light animations.

Returns:

dict.

Structure:

{
    "groups": {
        "id_1": {
            "type": "color_transition",
            "hue_range": [0,65535],
            "sat_range": [0,255],
            "bri_range": [0,255],
            "hue_step": 10,
            "sat_step": 10,
            "bri_step": 2,
            "transition_seconds": 2

        }

    },

    "lights": {
        "id_1": {}

    }

}
get_groups()[source]

Get the list of configured light groups.

Returns:

List of configured light groups as id->dict.

Example:

{
    "1": {
        "name": "Living Room",
        "lights": [
            "16",
            "13",
            "12",
            "11",
            "10",
            "9",
            "1",
            "3"
        ],

        "type": "Room",
        "state": {
            "all_on": true,
            "any_on": true
        },

        "class": "Living room",
        "action": {
            "on": true,
            "bri": 241,
            "hue": 37947,
            "sat": 221,
            "effect": "none",
            "xy": [
                0.2844,
                0.2609
            ],

            "ct": 153,
            "alert": "none",
            "colormode": "hs"
        }
    }
}
get_lights()[source]

Get the configured lights.

Returns:

List of available lights as id->dict.

Example:

{
    "1": {
        "state": {
            "on": true,
            "bri": 254,
            "hue": 1532,
            "sat": 215,
            "effect": "none",
            "xy": [
                0.6163,
                0.3403
            ],

            "ct": 153,
            "alert": "none",
            "colormode": "hs",
            "reachable": true
        },

        "type": "Extended color light",
        "name": "Lightbulb 1",
        "modelid": "LCT001",
        "manufacturername": "Philips",
        "uniqueid": "00:11:22:33:44:55:66:77-88",
        "swversion": "5.105.0.21169"
    }
}
get_scenes()[source]

Get the available scenes on the devices.

Returns:

The scenes configured on the bridge.

Example output:

{
    "scene-id-1": {
        "name": "Scene 1",
        "lights": [
            "1",
            "3"
        ],

        "owner": "owner-id",
        "recycle": true,
        "locked": false,
        "appdata": {},
        "picture": "",
        "lastupdated": "2018-06-01T00:00:00",
        "version": 1
    }
}
hue(value, lights=None, groups=None, **kwargs)[source]

Set lights/groups color hue.

Parameters:
  • lights – Lights to control (names or light objects). Default: plugin default lights

  • groups – Groups to control (names or group objects). Default: plugin default groups

  • value – Hue value (range: 0-65535)

is_animation_running()[source]
Returns:

True if there is an animation running, false otherwise.

off(lights=None, groups=None, **kwargs)[source]

Turn lights/groups off.

Parameters:
  • lights – Lights to turn off (names or light objects). Default: plugin default lights

  • groups – Groups to turn off (names or group objects). Default: plugin default groups

on(lights=None, groups=None, **kwargs)[source]

Turn lights/groups on.

Parameters:
  • lights – Lights to turn on (names or light objects). Default: plugin default lights

  • groups – Groups to turn on (names or group objects). Default: plugin default groups

sat(value, lights=None, groups=None, **kwargs)[source]

Set lights/groups saturation.

Parameters:
  • lights – Lights to control (names or light objects). Default: plugin default lights

  • groups – Groups to control (names or group objects). Default: plugin default groups

  • value – Saturation value (range: 0-255)

scene(name, lights=None, groups=None, **kwargs)[source]

Set a scene by name.

Parameters:
  • lights – Lights to control (names or light objects). Default: plugin default lights

  • groups – Groups to control (names or group objects). Default: plugin default groups

  • name – Name of the scene

set_group(group, **kwargs)[source]

Set a group (or groups) property.

Parameters:
  • group – Group or groups to set. Can be a string representing the group name, a group object, a list of strings, or a list of group objects.

  • kwargs – key-value list of parameters to set.

Example call:

{
    "type": "request",
    "target": "hostname",
    "action": "light.hue.set_group",
    "args": {
        "light": "Living Room",
        "sat": 255
    }
}
set_light(light, **kwargs)[source]

Set a light (or lights) property.

Parameters:
  • light – Light or lights to set. Can be a string representing the light name, a light object, a list of string, or a list of light objects.

  • kwargs – key-value list of parameters to set.

Example call:

{
    "type": "request",
    "target": "hostname",
    "action": "light.hue.set_light",
    "args": {
        "light": "Bulb 1",
        "sat": 255
    }
}
stop_animation()[source]

Stop a running animation.

property switches: List[dict]
Returns:

Implements platypush.plugins.switch.SwitchPlugin.switches() and returns the status of the configured lights. Example:

[
    {
        "id": "3",
        "name": "Lightbulb 1",
        "on": true,
        "bri": 254,
        "hue": 1532,
        "sat": 215,
        "effect": "none",
        "xy": [
            0.6163,
            0.3403
        ],
        "ct": 153,
        "alert": "none",
        "colormode": "hs",
        "reachable": true
        "type": "Extended color light",
        "modelid": "LCT001",
        "manufacturername": "Philips",
        "uniqueid": "00:11:22:33:44:55:66:77-88",
        "swversion": "5.105.0.21169"
    }
]

toggle(lights=None, groups=None, **kwargs)[source]

Toggle lights/groups on/off.

Parameters:
  • lights – Lights to turn off (names or light objects). Default: plugin default lights

  • groups – Groups to turn off (names or group objects). Default: plugin default groups

xy(value, lights=None, groups=None, **kwargs)[source]

Set lights/groups XY colors.

Parameters:
  • value (list[float] containing the two values) – xY value

  • lights – List of lights.

  • groups – List of groups.