Bulbs
Supported features
Turning on and off
Setting brightness, color temperature, and color (in HSV)
Querying emeter information
Transitions
Presets
Currently unsupported
Setting the default transitions
Timers
Note
Feel free to open a pull request to add support for more features!
Transitions
All commands changing the bulb state can be accompanied with a transition, e.g., to slowly fade the light off. The transition time is in milliseconds, 0 means immediate change. If no transition value is given, the default setting as configured for the bulb will be used.
Note
Accepted values are command (and potentially bulb) specific, feel free to improve the documentation on accepted values.
Example: While KL130 allows at least up to 15 second transitions for smooth turning off transitions, turning it on will not be so smooth.
Command-line usage
All command-line commands can be used with transition period for smooth changes.
Example: Turn the bulb off over a 15 second time period.
$ kasa --type bulb --host <host> off --transition 15000
Example: Change the bulb to red with 20% brightness over 15 seconds:
$ kasa --type bulb --host <host> hsv 0 100 20 --transition 15000
API documentation
- kasa.SmartBulb
alias of
IotBulb
- kasa.SmartBulbPreset
alias of
IotLightPreset
- class kasa.iot.iotbulb.BehaviorMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Enum to present type of turn on behavior.
- Circadian = 'circadian'
Circadian
- Last = 'last_status'
Return to the last state known state.
- Preset = 'customize_preset'
Use chosen preset.
- class kasa.iot.iotbulb.TurnOnBehaviors(soft: Annotated[TurnOnBehavior, Alias(name='soft_on')], hard: Annotated[TurnOnBehavior, Alias(name='hard_on')])[source]
Model to contain turn on behaviors.
- hard: Annotated[TurnOnBehavior, Alias(name='hard_on')]
The behavior when the bulb has been off from mains power.
- soft: Annotated[TurnOnBehavior, Alias(name='soft_on')]
The behavior when the bulb is turned on programmatically.
- class kasa.iot.iotbulb.TurnOnBehavior(mode: BehaviorMode, preset: Annotated[int | None, Alias(name='index')] = None, brightness: int | None = None, color_temp: int | None = None, hue: int | None = None, saturation: int | None = None)[source]
Model to present a single turn on behavior.
- Parameters:
preset (int) – the index number of wanted preset.
mode (BehaviorMode) – last status or preset mode. If you are changing existing settings, you should not set this manually.
To change the behavior, it is only necessary to change the
preset
field to contain either the preset index, orNone
for the last known state.- class Config[source]
Serialization config.
- omit_none: bool | Literal[Sentinel.MISSING] = True
- serialize_by_alias: bool | Literal[Sentinel.MISSING] = True
- brightness: int | None = None
- color_temp: int | None = None
- classmethod from_dict(d, *, dialect=None)
- hue: int | None = None
- mode: BehaviorMode
Wanted behavior
- preset: Annotated[int | None, Alias(name='index')] = None
Index of preset to use, or
None
for the last known state.
- saturation: int | None = None
- to_dict()