light.hue
#
- class platypush.plugins.light.hue.LightHuePlugin(*_, **__)[source]#
Bases:
RunnablePlugin
,LightEntityManager
Philips Hue lights plugin.
Requires:
phue (
pip install phue
)
Triggers:
platypush.message.event.light.LightAnimationStartedEvent
when an animation is started.platypush.message.event.light.LightAnimationStoppedEvent
when an animation is stopped.platypush.message.event.light.LightStatusChangeEvent
when the status of a lightbulb changes.
- class Animation(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
Inner class to model light animations.
- 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 colorcolor_transition
. Default: [0, 65535]sat_range (list[int]) – If you selected a color
color_transition
, this will specify the saturation range of your colorcolor_transition
. Default: [0, 255]bri_range (list[int]) – If you selected a color
color_transition
, this will specify the brightness range of your colorcolor_transition
. Default: [254, 255]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 (int) – If you selected a color
color_transition
, this will specify by how much the color hue will change between iterations. Default: 1000sat_step (int) – If you selected a color
color_transition
, this will specify by how much the saturation will change between iterations. Default: 2bri_step (int) – If you selected a color
color_transition
, this will specify by how much the brightness will change between iterations. Default: 1transition_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: 154-500)
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)
- 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", "action": "light.hue.set_group", "args": { "light": "Living Room", "sat": 255 } }
- set_lights(lights, *_, **kwargs)[source]#
Set a set of properties on a set of lights.
- Parameters:
light – List of lights to set. Each item can represent a light name or ID.
kwargs – key-value list of the parameters to set.
Example call:
{ "type": "request", "action": "light.hue.set_lights", "args": { "lights": ["Bulb 1", "Bulb 2"], "sat": 255 } }
- status(*_, **__) Iterable[Light] [source]#
All derived classes should implement this method.
At the very least, this method should refresh the current state of the integration’s entities and call
publish_entities()
.It should also return the current state of the entities as a list of serialized entities, if possible.
- 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
- transform_entities(entities: Iterable[dict | Entity] | Mapping[Any, dict]) Collection[Entity] [source]#
This method takes a list of entities in any (plugin-specific) format and converts them into a standardized collection of Entity objects. Since this method is called by
publish_entities()
before entity updates are published, you may usually want to extend it to pre-process the entities managed by your extension into the standard format before they are stored and published to all the consumers.