Skip to content

Commit

Permalink
Improve cli documentation for bulbs and power strips (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Dec 9, 2020
1 parent a926ff5 commit 98b40b5
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ or the `parse_pcap.py` script contained inside the `devtools` directory.

* HS300
* KP303
* KP400

### Wall switches

Expand Down
19 changes: 12 additions & 7 deletions docs/source/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ Command-line usage
==================

The package is shipped with a console tool named kasa, please refer to ``kasa --help`` for detailed usage.
The device to which the commands are sent is chosen by `KASA_HOST` environment variable or passing ``--host <address>`` as an option.
The device to which the commands are sent is chosen by ``KASA_HOST`` environment variable or passing ``--host <address>`` as an option.
To see what is being sent to and received from the device, specify option ``--debug``.

To avoid discovering the devices when executing commands its type can be passed by specifying either ``--plug`` or ``--bulb``,
if no type is given its type will be discovered automatically with a small delay.
Some commands (such as reading energy meter values and setting color of bulbs) additional parameters are required,
which you can find by adding ``--help`` after the command, e.g. ``kasa emeter --help`` or ``kasa hsv --help``.
To avoid discovering the devices when executing commands its type can be passed as an option (e.g., ``--plug`` for plugs, ``--bulb`` for bulbs, ..).
If no type is manually given, its type will be discovered automatically which causes a short delay.

If no command is given, the ``state`` command will be executed to query the device state.

.. note::

Some commands (such as reading energy meter values, changing bulb settings, or accessing individual sockets on smart strips) additional parameters are required,
which you can find by adding ``--help`` after the command, e.g. ``kasa emeter --help`` or ``kasa hsv --help``.
Refer to the device type specific documentation for more details.


Provisioning
~~~~~~~~~~~~
************

You can provision your device without any extra apps by using the ``kasa wifi`` command:

Expand All @@ -23,6 +28,6 @@ You can provision your device without any extra apps by using the ``kasa wifi``
4. Join/change the network using ``kasa wifi join`` command, see ``--help`` for details.

``kasa --help``
~~~~~~~~~~~~~~~
***************

.. program-output:: kasa --help
3 changes: 3 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx.ext.todo",
"sphinxcontrib.programoutput",
]

Expand All @@ -55,6 +56,8 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

todo_include_todos = True


def setup(app):
# add copybutton to hide the >>> prompts, see https://github.com/readthedocs/sphinx_rtd_theme/issues/167
Expand Down
3 changes: 0 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
python-kasa documentation
=========================

.. mdinclude:: ../../README.md

.. toctree::
Expand Down
53 changes: 53 additions & 0 deletions docs/source/smartbulb.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
Bulbs
===========

Supported features
******************

* Turning on and off
* Setting brightness, color temperature, and color (in HSV)
* Querying emeter information
* Transitions

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.

.. code::
$ kasa --bulb --host <host> off --transition 15000
**Example:** Change the bulb to red with 20% brightness over 15 seconds:

.. code::
$ kasa --bulb --host <host> hsv 0 100 20 --transition 15000
API documentation
*****************

.. autoclass:: kasa.SmartBulb
:members:
:undoc-members:
4 changes: 4 additions & 0 deletions docs/source/smartdevice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Refer to device type specific classes for more examples:
* :class:`SmartDimmer`
* :class:`SmartLightStrip`


API documentation
~~~~~~~~~~~~~~~~~

.. autoclass:: kasa.SmartDevice
:members:
:undoc-members:
7 changes: 7 additions & 0 deletions docs/source/smartdimmer.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Dimmers
=======

.. note::

Feel free to open a pull request to improve the documentation!

API documentation
*****************

.. autoclass:: kasa.SmartDimmer
:members:
:undoc-members:
7 changes: 7 additions & 0 deletions docs/source/smartlightstrip.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Light strips
============

.. note::

Feel free to open a pull request to improve the documentation!

API documentation
*****************

.. autoclass:: kasa.SmartLightStrip
:members:
:undoc-members:
8 changes: 8 additions & 0 deletions docs/source/smartplug.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Plugs
=====

.. note::

Feel free to open a pull request to improve the documentation!


API documentation
*****************

.. autoclass:: kasa.SmartPlug
:members:
:undoc-members:
31 changes: 31 additions & 0 deletions docs/source/smartstrip.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
Smart strips
============


.. note::

The emeter feature is currently not implemented for smart strips. See https://github.com/python-kasa/python-kasa/issues/64 for details.

.. note::

Feel free to open a pull request to improve the documentation!

Command-line usage
******************

To command a single socket of a strip, you will need to specify it either by using ``--index`` or by using ``--name``.
If not specified, the commands will act on the parent device: turning the strip off will turn off all sockets.

**Example:** Turn off the first socket (the indexing starts from zero):

.. code::
$ kasa --strip --host <host> on --index 0
**Example:** Turn on the socket by name:

.. code::
$ kasa --strip --host <host> off --name "Maybe Kitchen"
API documentation
*****************

.. autoclass:: kasa.SmartStrip
:members:
:undoc-members:

0 comments on commit 98b40b5

Please sign in to comment.