mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
mass rename to (python-)kasa (#1)
This commit is contained in:
parent
624c44c27f
commit
3ef5086ffb
@ -19,7 +19,6 @@ repos:
|
||||
rev: stable
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.7
|
||||
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.3.0
|
||||
|
@ -20,8 +20,8 @@ RUN apk update && \
|
||||
###################################################
|
||||
# Create somewhere to put the files #
|
||||
###################################################
|
||||
RUN mkdir -p /opt/pyHS100
|
||||
WORKDIR /opt/pyHS100
|
||||
RUN mkdir -p /opt/python-kasa
|
||||
WORKDIR /opt/python-kasa
|
||||
|
||||
###################################################
|
||||
# Requirements file first to help cache #
|
||||
|
28
README.md
28
README.md
@ -1,8 +1,8 @@
|
||||
# pyHS100
|
||||
# python-kasa
|
||||
|
||||
[![PyPI version](https://badge.fury.io/py/pyHS100.svg)](https://badge.fury.io/py/pyHS100)
|
||||
[![PyPI version](https://badge.fury.io/py/python-kasa.svg)](https://badge.fury.io/py/python-kasa)
|
||||
[![Build Status](https://dev.azure.com/python-tplink-kasa/python-kasa/_apis/build/status/python-tplink-kasa.python-kasa?branchName=master)](https://dev.azure.com/python-tplink-kasa/python-kasa/_build/latest?definitionId=1&branchName=master)
|
||||
[![Coverage Status](https://coveralls.io/repos/github/GadgetReactor/pyHS100/badge.svg?branch=master)](https://coveralls.io/github/GadgetReactor/pyHS100?branch=master)
|
||||
[![Coverage Status](https://coveralls.io/repos/github/python-kasa/python-kasa/badge.svg?branch=master)](https://coveralls.io/github/python-kasa/python-kasa?branch=master)
|
||||
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
|
||||
|
||||
Python Library to control TPLink smart plugs/switches and smart bulbs.
|
||||
@ -32,25 +32,25 @@ Python Library to control TPLink smart plugs/switches and smart bulbs.
|
||||
|
||||
# Usage
|
||||
|
||||
The package is shipped with a console tool named pyhs100, please refer to ```pyhs100 --help``` for detailed usage.
|
||||
The device to which the commands are sent is chosen by `PYHS100_HOST` environment variable or passing `--host <address>` as an option.
|
||||
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.
|
||||
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. `pyhs100 emeter --help` or `pyhs100 hsv --help`.
|
||||
which you can find by adding `--help` after the command, e.g. `kasa emeter --help` or `kasa hsv --help`.
|
||||
|
||||
If no command is given, the `state` command will be executed to query the device state.
|
||||
|
||||
|
||||
## Discovering devices
|
||||
|
||||
The devices can be discovered either by using `pyhs100 discover` or by calling `pyhs100` without any parameters.
|
||||
The devices can be discovered either by using `kasa discover` or by calling `kasa` without any parameters.
|
||||
In both cases supported devices are discovered from the same broadcast domain, and their current state will be queried and printed out.
|
||||
|
||||
```
|
||||
$ pyhs100
|
||||
$ kasa
|
||||
No --bulb nor --plug given, discovering..
|
||||
Discovering devices for 3 seconds
|
||||
== My Smart Plug - HS110(EU) ==
|
||||
@ -83,7 +83,7 @@ Possible options include `--year` and `--month` for retrieving historical state,
|
||||
and reseting the counters is done with `--erase`.
|
||||
|
||||
```
|
||||
$ pyhs100 emeter
|
||||
$ kasa emeter
|
||||
== Emeter ==
|
||||
Current state: {'total': 133.105, 'power': 108.223577, 'current': 0.54463, 'voltage': 225.296283}
|
||||
```
|
||||
@ -97,9 +97,9 @@ At the moment only switching the state of the LED is implemented.
|
||||
`led` command can be used to control whether the LED light on front of the plug is on or off.
|
||||
|
||||
```
|
||||
$ pyhs100 --plug led
|
||||
$ kasa --plug led
|
||||
LED state: False
|
||||
$ pyhs100 --plug led 1
|
||||
$ kasa --plug led 1
|
||||
Turning led to True
|
||||
```
|
||||
|
||||
@ -122,7 +122,7 @@ which returns a dictionary keyed with the IP address whose value hold a ready-to
|
||||
|
||||
Example:
|
||||
```python
|
||||
from pyHS100 import Discover
|
||||
from kasa import Discover
|
||||
|
||||
for dev in Discover.discover().values():
|
||||
print(dev)
|
||||
@ -138,7 +138,7 @@ $ python3 example.py
|
||||
If you want to avoid unnecessary communication with the device please use `get_sysinfo` and handle parsing of information by yourself.*
|
||||
|
||||
```python
|
||||
from pyHS100 import SmartPlug, SmartBulb
|
||||
from kasa import SmartPlug, SmartBulb
|
||||
from pprint import pformat as pf
|
||||
|
||||
plug = SmartPlug("192.168.XXX.XXX")
|
||||
@ -231,5 +231,5 @@ The following assumes you have a working installation of Docker.
|
||||
Set up the environment and run the tests on demand.
|
||||
|
||||
```shell
|
||||
docker build . -t pyhs100 && docker run -v $(PWD)/pyHS100/tests:/opt/pyHS100/pyHS100/tests pyhs100 pytest
|
||||
docker build . -t kasa && docker run -v $(PWD)/kasa/tests:/opt/python-kasa/kasa/tests kasa pytest
|
||||
```
|
||||
|
@ -71,5 +71,5 @@ steps:
|
||||
displayName: 'Order of imports (isort)'
|
||||
|
||||
- script: |
|
||||
pytest --cov pyHS100 --cov-report html
|
||||
pytest --cov kasa --cov-report html
|
||||
displayName: 'Tests'
|
||||
|
@ -11,17 +11,12 @@ For device type specific actions `SmartBulb`, `SmartPlug`, or `SmartStrip`
|
||||
Module-specific errors are raised as `SmartDeviceException` and are expected
|
||||
to be handled by the user of the library.
|
||||
"""
|
||||
from pyHS100.discover import Discover
|
||||
from pyHS100.protocol import TPLinkSmartHomeProtocol
|
||||
from pyHS100.smartbulb import SmartBulb
|
||||
from pyHS100.smartdevice import (
|
||||
DeviceType,
|
||||
EmeterStatus,
|
||||
SmartDevice,
|
||||
SmartDeviceException,
|
||||
)
|
||||
from pyHS100.smartplug import SmartPlug
|
||||
from pyHS100.smartstrip import SmartStrip
|
||||
from kasa.discover import Discover
|
||||
from kasa.protocol import TPLinkSmartHomeProtocol
|
||||
from kasa.smartbulb import SmartBulb
|
||||
from kasa.smartdevice import DeviceType, EmeterStatus, SmartDevice, SmartDeviceException
|
||||
from kasa.smartplug import SmartPlug
|
||||
from kasa.smartstrip import SmartStrip
|
||||
|
||||
__all__ = [
|
||||
"Discover",
|
@ -1,4 +1,4 @@
|
||||
"""pyHS100 cli tool."""
|
||||
"""python-kasa cli tool."""
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
@ -6,9 +6,9 @@ from pprint import pformat as pf
|
||||
|
||||
import click
|
||||
|
||||
from pyHS100 import Discover, SmartBulb, SmartDevice, SmartStrip
|
||||
from kasa import Discover, SmartBulb, SmartDevice, SmartStrip
|
||||
|
||||
from pyHS100 import SmartPlug # noqa: E402; noqa: E402
|
||||
from kasa import SmartPlug # noqa: E402; noqa: E402
|
||||
|
||||
if sys.version_info < (3, 6):
|
||||
print("To use this script you need Python 3.6 or newer! got %s" % sys.version_info)
|
||||
@ -21,7 +21,7 @@ pass_dev = click.make_pass_decorator(SmartDevice)
|
||||
@click.group(invoke_without_command=True)
|
||||
@click.option(
|
||||
"--ip",
|
||||
envvar="PYHS100_IP",
|
||||
envvar="KASA_IP",
|
||||
required=False,
|
||||
help="The IP address of the device to connect to. This option "
|
||||
"is deprecated and will be removed in the future; use --host "
|
||||
@ -29,13 +29,13 @@ pass_dev = click.make_pass_decorator(SmartDevice)
|
||||
)
|
||||
@click.option(
|
||||
"--host",
|
||||
envvar="PYHS100_HOST",
|
||||
envvar="KASA_HOST",
|
||||
required=False,
|
||||
help="The host name or IP address of the device to connect to.",
|
||||
)
|
||||
@click.option(
|
||||
"--alias",
|
||||
envvar="PYHS100_NAME",
|
||||
envvar="KASA_NAME",
|
||||
required=False,
|
||||
help="The device name, or alias, of the device to connect to.",
|
||||
)
|
@ -4,11 +4,11 @@ import logging
|
||||
import socket
|
||||
from typing import Dict, Optional, Type
|
||||
|
||||
from pyHS100.protocol import TPLinkSmartHomeProtocol
|
||||
from pyHS100.smartbulb import SmartBulb
|
||||
from pyHS100.smartdevice import SmartDevice, SmartDeviceException
|
||||
from pyHS100.smartplug import SmartPlug
|
||||
from pyHS100.smartstrip import SmartStrip
|
||||
from kasa.protocol import TPLinkSmartHomeProtocol
|
||||
from kasa.smartbulb import SmartBulb
|
||||
from kasa.smartdevice import SmartDevice, SmartDeviceException
|
||||
from kasa.smartplug import SmartPlug
|
||||
from kasa.smartstrip import SmartStrip
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -2,8 +2,8 @@
|
||||
import re
|
||||
from typing import Any, Dict, Optional, Tuple
|
||||
|
||||
from pyHS100.protocol import TPLinkSmartHomeProtocol
|
||||
from pyHS100.smartdevice import (
|
||||
from kasa.protocol import TPLinkSmartHomeProtocol
|
||||
from kasa.smartdevice import (
|
||||
DeviceType,
|
||||
SmartDevice,
|
||||
SmartDeviceException,
|
@ -20,7 +20,7 @@ from datetime import datetime, timedelta
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from pyHS100.protocol import TPLinkSmartHomeProtocol
|
||||
from kasa.protocol import TPLinkSmartHomeProtocol
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -3,8 +3,8 @@ import datetime
|
||||
import logging
|
||||
from typing import Any, Dict
|
||||
|
||||
from pyHS100.protocol import TPLinkSmartHomeProtocol
|
||||
from pyHS100.smartdevice import (
|
||||
from kasa.protocol import TPLinkSmartHomeProtocol
|
||||
from kasa.smartdevice import (
|
||||
DeviceType,
|
||||
SmartDevice,
|
||||
SmartDeviceException,
|
@ -7,9 +7,9 @@ import logging
|
||||
from collections import defaultdict
|
||||
from typing import Any, DefaultDict, Dict, List
|
||||
|
||||
from pyHS100.protocol import TPLinkSmartHomeProtocol
|
||||
from pyHS100.smartdevice import DeviceType, requires_update
|
||||
from pyHS100.smartplug import SmartPlug
|
||||
from kasa.protocol import TPLinkSmartHomeProtocol
|
||||
from kasa.smartdevice import DeviceType, requires_update
|
||||
from kasa.smartplug import SmartPlug
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -6,7 +6,7 @@ from os.path import basename
|
||||
|
||||
import pytest
|
||||
|
||||
from pyHS100 import Discover, SmartBulb, SmartPlug, SmartStrip
|
||||
from kasa import Discover, SmartBulb, SmartPlug, SmartStrip
|
||||
|
||||
from .newfakes import FakeTransportProtocol
|
||||
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from pyHS100 import DeviceType, SmartDeviceException, SmartStrip
|
||||
from kasa import DeviceType, SmartDeviceException, SmartStrip
|
||||
|
||||
from .conftest import (
|
||||
bulb,
|
18
setup.py
18
setup.py
@ -1,19 +1,19 @@
|
||||
from setuptools import setup
|
||||
|
||||
with open("pyHS100/version.py") as f:
|
||||
with open("kasa/version.py") as f:
|
||||
exec(f.read())
|
||||
|
||||
setup(
|
||||
name="pyHS100",
|
||||
name="python-kasa",
|
||||
version=__version__, # type: ignore # noqa: F821
|
||||
description="Python interface for TPLink KASA-enabled smart home devices",
|
||||
url="https://github.com/GadgetReactor/pyHS100",
|
||||
author="Sean Seah (GadgetReactor)",
|
||||
author_email="sean@gadgetreactor.com",
|
||||
description="Python API for TP-Link Kasa Smarthome products",
|
||||
url="https://github.com/python-kasa/python-kasa",
|
||||
author="",
|
||||
author_email="",
|
||||
license="GPLv3",
|
||||
packages=["pyHS100"],
|
||||
install_requires=["click", "deprecation"],
|
||||
packages=["kasa"],
|
||||
install_requires=["click"],
|
||||
python_requires=">=3.6",
|
||||
entry_points={"console_scripts": ["pyhs100=pyHS100.cli:cli"]},
|
||||
entry_points={"console_scripts": ["kasa=kasa.cli:cli"]},
|
||||
zip_safe=False,
|
||||
)
|
||||
|
20
tox.ini
20
tox.ini
@ -17,24 +17,24 @@ deps=
|
||||
deprecation
|
||||
flake8
|
||||
commands=
|
||||
py.test --cov --cov-config=tox.ini pyHS100
|
||||
py.test --cov --cov-config=tox.ini kasa
|
||||
|
||||
[testenv:flake8]
|
||||
deps=
|
||||
flake8
|
||||
flake8-docstrings
|
||||
commands=flake8 pyHS100
|
||||
commands=flake8 kasa
|
||||
|
||||
[testenv:typing]
|
||||
skip_install=true
|
||||
deps=mypy
|
||||
commands=mypy --ignore-missing-imports pyHS100
|
||||
commands=mypy --ignore-missing-imports kasa
|
||||
|
||||
[flake8]
|
||||
exclude = .git,.tox,__pycache__,pyHS100/tests/newfakes.py,pyHS100/tests/test_fixtures.py
|
||||
exclude = .git,.tox,__pycache__,kasa/tests/newfakes.py,kasa/tests/test_fixtures.py
|
||||
max-line-length = 88
|
||||
per-file-ignores =
|
||||
pyHS100/tests/*.py:D100,D101,D102,D103,D104
|
||||
kasa/tests/*.py:D100,D101,D102,D103,D104
|
||||
setup.py:D100
|
||||
ignore = D105, D107, E203, E501, W503
|
||||
#ignore = E203, E266, E501, W503, F403, F401
|
||||
@ -47,11 +47,11 @@ skip_install = true
|
||||
commands = pre-commit run --all-files
|
||||
|
||||
[coverage:run]
|
||||
source = pyHS100
|
||||
source = kasa
|
||||
branch = True
|
||||
omit =
|
||||
pyHS100/cli.py
|
||||
pyHS100/tests/*
|
||||
kasa/cli.py
|
||||
kasa/tests/*
|
||||
|
||||
[coverage:report]
|
||||
exclude_lines =
|
||||
@ -65,5 +65,5 @@ include_trailing_comma=True
|
||||
force_grid_wrap=0
|
||||
use_parentheses=True
|
||||
line_length=88
|
||||
known_first_party=pyHS100
|
||||
known_third_party=click,deprecation,pytest,setuptools,voluptuous
|
||||
known_first_party=kasa
|
||||
known_third_party=click,pytest,setuptools,voluptuous
|
||||
|
Loading…
Reference in New Issue
Block a user