lifx package¶
Submodules¶
lifx.color module¶
lifx.exception module¶
lifx.get_selectors module¶
-
lifx.get_selectors.
get_selectors
(session)[source]¶ List all the available selectors for a given session. See https://api.developer.lifx.com/v1/docs/selectors
- Return type
List
[str
]
lifx.model module¶
-
class
lifx.model.
Capabilities
(**data)[source]¶ Bases:
pydantic.main.BaseModel
-
has_chain
: bool = None¶
-
has_color
: bool = None¶
-
has_ir
: bool = None¶
-
has_matrix
: bool = None¶
-
has_multizone
: bool = None¶
-
has_variable_color_temp
: bool = None¶
-
max_kelvin
: int = None¶
-
min_kelvin
: int = None¶
-
-
class
lifx.model.
Color
(**data)[source]¶ Bases:
pydantic.main.BaseModel
-
brightness
: Optional[float] = None¶
-
hue
: Optional[int] = None¶
-
kelvin
: Optional[int] = None¶
-
saturation
: Optional[float] = None¶
-
-
class
lifx.model.
Group
(**data)[source]¶ Bases:
pydantic.main.BaseModel
-
id
: str = None¶
-
name
: str = None¶
-
-
class
lifx.model.
Light
(**data)[source]¶ Bases:
pydantic.main.BaseModel
-
brightness
: float = None¶
-
color
: Color = None¶
-
connected
: bool = None¶
-
effect
: str = None¶
-
group
: Group = None¶
-
id
: str = None¶
-
label
: str = None¶
-
last_seen
: datetime = None¶
-
location
: Location = None¶
-
power
: str = None¶
-
product
: Product = None¶
-
seconds_since_seen
: int = None¶
-
uuid
: UUID = None¶
-
-
class
lifx.model.
Location
(**data)[source]¶ Bases:
pydantic.main.BaseModel
-
id
: str = None¶
-
name
: str = None¶
-
-
class
lifx.model.
Product
(**data)[source]¶ Bases:
pydantic.main.BaseModel
-
capabilities
: Capabilities = None¶
-
company
: str = None¶
-
identifier
: str = None¶
-
name
: str = None¶
-
-
class
lifx.model.
Scene
(**data)[source]¶ Bases:
pydantic.main.BaseModel
-
name
: str = None¶
-
states
: List[State] = None¶
-
uuid
: UUID = None¶
-
-
class
lifx.model.
State
(**data)[source]¶ Bases:
pydantic.main.BaseModel
-
brightness
: Optional[float] = None¶
-
color
: Optional[Color] = None¶
-
duration
: Optional[float] = None¶
-
infrared
: Optional[float] = None¶
-
power
: Optional[str] = None¶
-
selector
: Optional[str] = None¶
-
-
class
lifx.model.
StateDelta
(**data)[source]¶ Bases:
pydantic.main.BaseModel
-
brightness
: Optional[float] = None¶
-
duration
: Optional[float] = None¶
-
hue
: Optional[float] = None¶
-
infrared
: Optional[float] = None¶
-
kelvin
: Optional[float] = None¶
-
power
: Optional[str] = None¶
-
saturation
: Optional[float] = None¶
-
lifx.scenes module¶
-
lifx.scenes.
activate_scene_by_id
(session, scene_id, ignore=None, duration=None, overrides=None, fast=None)[source]¶ Activate a scene by its id.
- Parameters
session (
Session
) – session object used to perform API callsscene_id (
UUID
) – UUID of a scene, can be accessed from a scene object by scene.uuidignore (
Optional
[List
[str
]]) – Any of “power”, “infrared”, “duration”, “intensity”, “hue”, “saturation”, “brightness” or “kelvin”, specifying that these properties should not be changed on devices when applying the scene.overrides (
Optional
[State
]) – A state object as per Set State specifying properties to apply to all devices in the scene, overriding those configured in the scene.fast (
Optional
[bool
]) – Execute the query fast, without initial state checks and wait for no results.
- Return type
None
lifx.selector module¶
-
class
lifx.selector.
Selector
(selector, session)[source]¶ Bases:
object
Class representing a single light or a group of lights that share a selector e.g. group, location etc. This class provides methods to alter the state of the whole group of lights.
- Parameters
selector (
str
) – string used to select lights e.g. group:bedroom or id:28sha2jn2 (possibe selectors can be listed using lifx.get_selectors)session (
Session
) – session object used to perform API calls
-
breathe_effect
(color=None, from_color=None, period=None, cycles=None, persist=None, power_on=None, peak=None)[source]¶ Apply the breathe effect to the selected lights See https://api.developer.lifx.com/docs/breathe-effect
- Parameters
color (
Optional
[str
]) – The color to use for the breathe effectfrom_color (
Optional
[str
]) – The color to start the effect from. If this parameter is omitted then the color the bulb is currently set to is used instead.period (
Optional
[float
]) – The time in seconds for one cycle of the effect.cycle – The number of times to repeat the effect.
persist (
Optional
[bool
]) – If false set the light back to its previous value when effect ends, if true leave the last effect color.power_off – If true, turn the bulb on if it is not already on.
peak (
Optional
[float
]) – Defines where in a period the target color is at its maximum. Minimum 0.0, maximum 1.0.
- Return type
None
-
cycle
(states=None, default=None, direction=None)[source]¶ Cycle selected lights through states See https://api.developer.lifx.com/docs/cycle
-
effects_off
(power_off=None)[source]¶ Turns off any running effects on the device. This includes any waveform (breathe or pulse) as well as Tile or Multizone firmware effects.
Also, if you specify power_off as true then the lights will also be powered off.
- Return type
None
-
flame_effect
(period=None, duration=None, power_on=None)[source]¶ Apply the flame effect to the selected lights See https://api.developer.lifx.com/docs/flame-effect
- Parameters
duration (
Optional
[float
]) – How long the animation lasts for in seconds. Not specifying a duration makes the animation never stop. Specifying 0 makes the animation stop. Note that there is a known bug where the tile remains in the animation once it has completed if duration is nonzero.period (
Optional
[float
]) – This controls how quickly the flame runs. It is measured in seconds. A lower number means the animation is fasterpower_off – If true, turn the bulb on if it is not already on.
- Return type
None
-
move
(direction, period, cycles, power_on)[source]¶ Apply the move effect to the selected lights See https://api.developer.lifx.com/docs/move-effect
- Parameters
direction (
Optional
[str
]) – Move direction, can be ‘forward’ or ‘backward’period (
Optional
[float
]) – The time in seconds for one cycle of the effect.cycle – The number of times to repeat the effect.
power_off – If true, turn the bulb on if it is not already on.
- Return type
None
-
pulse_effect
(color=None, from_color=None, period=None, cycles=None, persist=None, power_on=None)[source]¶ Apply the pulse effect to the selected lights See https://api.developer.lifx.com/docs/pulse-effect
- Parameters
color (
Optional
[str
]) – The color to use for the pulse effectfrom_color (
Optional
[str
]) – The color to start the effect from. If this parameter is omitted then the color the bulb is currently set to is used instead.period (
Optional
[float
]) – The time in seconds for one cycle of the effect.cycle – The number of times to repeat the effect.
persist (
Optional
[bool
]) – If false set the light back to its previous value when effect ends, if true leave the last effect color.power_off – If true, turn the bulb on if it is not already on.
- Return type
None
-
set_state
(state)[source]¶ Set the state of the selected lights
- Parameters
state (
State
) – state to be applied to the selected lights- Return type
None
-
state_delta
(state_delta)[source]¶ Change the state of the selected lights relative to their current states Example selector.state_delta(StateDelta(brightness=-0.5)) reduces the brightness of selected lights by 0.5
- Parameters
state_delta (
StateDelta
) – Change in state to be applied to selected lights- Return type
None
lifx.session module¶
-
class
lifx.session.
Session
(token)[source]¶ Bases:
object
Layer of abstraction between API Classes and the requests library. Handles the actual API calls and authentication.
- Parameters
token (
str
) – Lifx api authorization token
-
get
(path)[source]¶ Perform a GET reqeust to https://api.lifx.com/v1/{path}
- Parameters
path (
str
) – string containing path and any query string- Return type
dict
- Returns
serialized JSON dictionary of reponse from API
-
post
(path, body)[source]¶ Perform a POST reqeust to https://api.lifx.com/v1/{path}
- Parameters
path (
str
) – string containing path and any query stringbody (
dict
) – JSON serializable dict to send in request body
- Return type
dict
- Returns
serialized JSON dictionary of reponse from API
-
put
(path, body)[source]¶ Perform a PUT reqeust to https://api.lifx.com/v1/{path}
- Parameters
path (
str
) – string containing path and any query stringbody (
dict
) – JSON serializable dict to send in request body
- Return type
dict
- Returns
serialized JSON dictionary of reponse from API