This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Smooth transition on (smooth_transition_on): 2 (range: 0-60)
Smooth transition off (smooth_transition_off): 20 (range: 0-60)
== Debug ==
Device ID (device_id): someuniqueidentifier
RSSI (rssi): -50
SSID (ssid): SecretNetwork
Current firmware version (current_firmware_version): 1.1.6 Build 240130 Rel.173828
Available firmware version (available_firmware_version): None
Time (time): 2024-06-21 15:09:35+02:00
== Modules ==
+ <Module Schedule (smartlife.iot.common.schedule) for 192.168.xx.xx>
+ <Module Usage (smartlife.iot.common.schedule) for 192.168.xx.xx>
+ <Module Antitheft (smartlife.iot.common.anti_theft) for 192.168.xx.xx>
+ <Module Time (smartlife.iot.common.timesetting) for 192.168.xx.xx>
+ <Module Emeter (smartlife.iot.common.emeter) for 192.168.xx.xx>
- <Module Countdown (countdown) for 192.168.xx.xx>
+ <Module Cloud (smartlife.iot.common.cloud) for 192.168.xx.xx>
+ <Module Brightness (brightness) for 192.0.2.123>
+ <Module Cloud (cloud_connect) for 192.0.2.123>
+ <Module Color (color) for 192.0.2.123>
+ <Module ColorTemperature (color_temperature) for 192.0.2.123>
+ <Module DeviceModule (device) for 192.0.2.123>
+ <Module Firmware (firmware) for 192.0.2.123>
+ <Module LightEffect (light_effect) for 192.0.2.123>
+ <Module LightPreset (preset) for 192.0.2.123>
+ <Module LightTransition (on_off_gradually) for 192.0.2.123>
+ <Module Time (time) for 192.0.2.123>
+ <Module Light (light) for 192.0.2.123>
```
If your device requires authentication to control it,
you need to pass the credentials using `--username` and `--password` options.
## Basic functionalities
## Command line usage
All devices support a variety of common commands, including:
All devices support a variety of common commands (like `on`, `off`, and `state`).
The syntax to control device is `kasa --host <host> <command>`:
* `state` which returns state information
* `on` and `off` for turning the device on or off
* `emeter` (where applicable) to return energy consumption information
* `sysinfo` to return raw system information
```
$ kasa --host 192.0.2.123 on
```
The syntax to control device is `kasa --host <ip address> <command>`.
Use `kasa --help` ([or consult the documentation](https://python-kasa.readthedocs.io/en/latest/cli.html#kasa-help)) to get a list of all available commands and options.
Some examples of available options include JSON output (`--json`), defining timeouts (`--timeout` and `--discovery-timeout`).
Refer [the documentation](https://python-kasa.readthedocs.io/en/latest/cli.html) for more details.
Each individual command may also have additional options, which are shown when called with the `--help` option.
For example, `--transition` on bulbs requests a smooth state change, while `--name` and `--index` are used on power strips to select the socket to act on:
> [!NOTE]
> Each individual command may also have additional options, which are shown when called with the `--help` option.
```
$ kasa on --help
Usage: kasa on [OPTIONS]
### Feature interface
Turn the device on.
All devices are also controllable through a generic feature-based interface.
The available features differ from device to device
Options:
--index INTEGER
--name TEXT
--transition INTEGER
--help Show this message and exit.
```
$ kasa --host 192.0.2.123 feature
No --type or --device-family and --encrypt-type defined, discovering for 5 seconds..
== Features ==
### Bulbs
Common commands for bulbs and light strips include:
* `brightness` to control the brightness
* `hsv` to control the colors
* `temperature` to control the color temperatures
When executed without parameters, these commands will report the current state.
Device ID (device_id): someuniqueidentifier
State (state): False
Signal Level (signal_level): 3
RSSI (rssi): -49
SSID (ssid): SecretNetwork
Overheated (overheated): False
Brightness (brightness): 11 (range: 0-100)
Cloud connection (cloud_connection): False
HSV (hsv): HSV(hue=35, saturation=70, value=11)
Color temperature (color_temperature): 0 (range: 2500-6500)
Auto update enabled (auto_update_enabled): False
Update available (update_available): None
Current firmware version (current_firmware_version): 1.1.6 Build 240130 Rel.173828
Available firmware version (available_firmware_version): None
No --type or --device-family and --encrypt-type defined, discovering for 5 seconds..
Changing color_temperature from 0 to 2500
New state: 2500
```
See `--help` for additional options and [the documentation](https://python-kasa.readthedocs.io/en/latest/smartbulb.html) for more details about supported features and limitations.
> [!NOTE]
> When controlling hub-connected devices, you need to pass the device ID of the connected device as an option: `kasa --host 192.0.2.200 feature --child someuniqueidentifier target_temperature 21`
### Power strips
Each individual socket can be controlled separately by passing `--index` or `--name` to the command.
If neither option is defined, the commands act on the whole power strip.
## Library usage
For example:
```
$ kasa --host <addr> off # turns off all sockets
$ kasa --host <addr> off --name 'Socket1' # turns off socket named 'Socket1'
```
See `--help` for additional options and [the documentation](https://python-kasa.readthedocs.io/en/latest/smartstrip.html) for more details about supported features and limitations.
import asyncio
from kasa import Discover
## Energy meter
async def main():
dev = await Discover.discover_single("192.0.2.123", username="un@example.com", password="pw")
await dev.turn_on()
await dev.update()
Running `kasa emeter` command will return the current consumption.
Possible options include `--year` and `--month` for retrieving historical state,
and reseting the counters can be done with `--erase`.
```
$ kasa emeter
== Emeter ==
Current state: {'total': 133.105, 'power': 108.223577, 'current': 0.54463, 'voltage': 225.296283}
if __name__ == "__main__":
asyncio.run(main())
```
# Library usage
If you want to use this library in your own project, a good starting point is [the tutorial in the documentation](https://python-kasa.readthedocs.io/en/latest/tutorial.html).
You can find several code examples in the API documentation [How to guides](https://python-kasa.readthedocs.io/en/latest/guides.html).
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update README to be more approachable for new users #994
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Update README to be more approachable for new users #994
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing