diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-18 06:55:55 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-18 06:55:55 +0000 |
commit | 851a816cdefde6e996fdd529879391b901cd1dda (patch) | |
tree | b270eac90b4d8309e6cdaf07dd4c634241443b10 | |
parent | 922a88c227b0877377e4572c14c801f1ac263791 (diff) |
automatic import of python-pylutron-caseta
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-pylutron-caseta.spec | 423 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 425 insertions, 0 deletions
@@ -0,0 +1 @@ +/pylutron_caseta-0.18.1.tar.gz diff --git a/python-pylutron-caseta.spec b/python-pylutron-caseta.spec new file mode 100644 index 0000000..e6f772e --- /dev/null +++ b/python-pylutron-caseta.spec @@ -0,0 +1,423 @@ +%global _empty_manifest_terminate_build 0 +Name: python-pylutron-caseta +Version: 0.18.1 +Release: 1 +Summary: Provides an API to the Lutron Smartbridge +License: Apache +URL: https://github.com/gurumitts/pylutron-caseta +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/a0/37/6caca9d22a4beb3ecae97c453929b9947eb5a6c3dd0afc84ee3e15c9956d/pylutron_caseta-0.18.1.tar.gz +BuildArch: noarch + +Requires: python3-cryptography +Requires: python3-click +Requires: python3-xdg +Requires: python3-zeroconf +Requires: python3-black +Requires: python3-flake8 +Requires: python3-pylint +Requires: python3-mypy +Requires: python3-pydocstyle +Requires: python3-coveralls +Requires: python3-pytest +Requires: python3-pytest-asyncio +Requires: python3-pytest-cov +Requires: python3-pytest-timeout +Requires: python3-pytest-sugar + +%description +# pylutron-caseta
+
+A Python API to control Lutron Caséta devices.
+
+[](https://coveralls.io/github/gurumitts/pylutron-caseta?branch=dev)
+
+## Getting started
+
+If you don't know the IP address of the bridge, the `leap-scan` tool (requires the cli extra, `pip install pylutron_caseta[cli]`) will search for LEAP devices on the local network and display their address and LEAP port number.
+
+### Authentication
+
+In order to communicate with the bridge device, you must complete the pairing process. This generates certificate files for authentication. pylutron_caseta can do this two ways.
+
+#### lap-pair
+
+If pylutron_caseta is installed with the cli extra (`pip install pylutron_caseta[cli]`), the `lap-pair` tool can be used to generate the certificate files. Simply running `lap-pair <BRIDGE HOST>` (note the LEAP port number should not be included) will begin the pairing process. The certificate files will be saved in `$XDG_CONFIG_HOME/pylutron_caseta` (normally `~/.config/pylutron_caseta`) in the files `[BRIDGE HOST]-bridge.crt`, `[BRIDGE HOST].crt`, `[BRIDGE HOST].key`. Check `lap-pair --help` if you want to use different files.
+
+#### The pairing module
+
+If pylutron_caseta is being integrated into a larger application, the pairing functionality can be reused to allow pairing from within that application.
+
+```py
+async def pair(host: str):
+ def _ready():
+ print("Press the small black button on the back of the bridge.")
+
+ data = await async_pair(host, _ready)
+ with open("caseta-bridge.crt", "w") as cacert:
+ cacert.write(data["ca"])
+ with open("caseta.crt", "w") as cert:
+ cert.write(data["cert"])
+ with open("caseta.key", "w") as key:
+ key.write(data["key"])
+ print(f"Successfully paired with {data['version']}")
+```
+
+### Connecting to the bridge
+
+Once you have the certificate files, you can connect to the bridge and start controlling devices.
+
+```py
+import asyncio
+
+from pylutron_caseta.smartbridge import Smartbridge
+
+async def example():
+ # `Smartbridge` provides an API for interacting with the Caséta bridge.
+ bridge = Smartbridge.create_tls(
+ "YOUR_BRIDGE_IP", "caseta.key", "caseta.crt", "caseta-bridge.crt"
+ )
+ await bridge.connect()
+
+ # Get the first light.
+ # The device is represented by a dict.
+ device = bridge.get_devices_by_domain("light")[0]
+ # Turn on the light.
+ # Methods that act on devices expect to be given the device id.
+ await bridge.turn_on(device["device_id"])
+
+ await bridge.close()
+
+
+# Because pylutron_caseta uses asyncio,
+# it must be run within the context of an asyncio event loop.
+loop = asyncio.get_event_loop()
+loop.run_until_complete(example())
+```
+
+### The leap tool
+
+For development and testing of new features, there is a `leap` command in the cli extras (`pip install pylutron_caseta[cli]`) which can be used for communicating directly with the bridge, similar to using `curl`.
+
+Getting information about the bridge:
+
+```
+$ leap 192.168.86.49/server | jq
+{
+ "Servers": [
+ {
+ "href": "/server/1",
+ "Type": "LEAP",
+ "NetworkInterfaces": [
+ {
+ "href": "/networkinterface/1"
+ }
+ ],
+ "EnableState": "Enabled",
+ "LEAPProperties": {
+ "PairingList": {
+ "href": "/server/leap/pairinglist"
+ }
+ },
+ "Endpoints": [
+ {
+ "Protocol": "TCP",
+ "Port": 8081,
+ "AssociatedNetworkInterfaces": null
+ }
+ ]
+ }
+ ]
+}
+```
+
+Turning on the first dimmer:
+
+```
+$ ip=192.168.86.49
+$ device=$(leap "${ip}/zone/status/expanded?where=Zone.ControlType:\"Dimmed\"" | jq -r '.ZoneExpandedStatuses[0].Zone.href')
+$ leap -X CreateRequest "${ip}${device}/commandprocessor" -d '{"Command":{"CommandType":"GoToLevel","Parameter":[{"Type":"Level","Value":100}]}}'
+```
+ + +%package -n python3-pylutron-caseta +Summary: Provides an API to the Lutron Smartbridge +Provides: python-pylutron-caseta +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-pylutron-caseta +# pylutron-caseta
+
+A Python API to control Lutron Caséta devices.
+
+[](https://coveralls.io/github/gurumitts/pylutron-caseta?branch=dev)
+
+## Getting started
+
+If you don't know the IP address of the bridge, the `leap-scan` tool (requires the cli extra, `pip install pylutron_caseta[cli]`) will search for LEAP devices on the local network and display their address and LEAP port number.
+
+### Authentication
+
+In order to communicate with the bridge device, you must complete the pairing process. This generates certificate files for authentication. pylutron_caseta can do this two ways.
+
+#### lap-pair
+
+If pylutron_caseta is installed with the cli extra (`pip install pylutron_caseta[cli]`), the `lap-pair` tool can be used to generate the certificate files. Simply running `lap-pair <BRIDGE HOST>` (note the LEAP port number should not be included) will begin the pairing process. The certificate files will be saved in `$XDG_CONFIG_HOME/pylutron_caseta` (normally `~/.config/pylutron_caseta`) in the files `[BRIDGE HOST]-bridge.crt`, `[BRIDGE HOST].crt`, `[BRIDGE HOST].key`. Check `lap-pair --help` if you want to use different files.
+
+#### The pairing module
+
+If pylutron_caseta is being integrated into a larger application, the pairing functionality can be reused to allow pairing from within that application.
+
+```py
+async def pair(host: str):
+ def _ready():
+ print("Press the small black button on the back of the bridge.")
+
+ data = await async_pair(host, _ready)
+ with open("caseta-bridge.crt", "w") as cacert:
+ cacert.write(data["ca"])
+ with open("caseta.crt", "w") as cert:
+ cert.write(data["cert"])
+ with open("caseta.key", "w") as key:
+ key.write(data["key"])
+ print(f"Successfully paired with {data['version']}")
+```
+
+### Connecting to the bridge
+
+Once you have the certificate files, you can connect to the bridge and start controlling devices.
+
+```py
+import asyncio
+
+from pylutron_caseta.smartbridge import Smartbridge
+
+async def example():
+ # `Smartbridge` provides an API for interacting with the Caséta bridge.
+ bridge = Smartbridge.create_tls(
+ "YOUR_BRIDGE_IP", "caseta.key", "caseta.crt", "caseta-bridge.crt"
+ )
+ await bridge.connect()
+
+ # Get the first light.
+ # The device is represented by a dict.
+ device = bridge.get_devices_by_domain("light")[0]
+ # Turn on the light.
+ # Methods that act on devices expect to be given the device id.
+ await bridge.turn_on(device["device_id"])
+
+ await bridge.close()
+
+
+# Because pylutron_caseta uses asyncio,
+# it must be run within the context of an asyncio event loop.
+loop = asyncio.get_event_loop()
+loop.run_until_complete(example())
+```
+
+### The leap tool
+
+For development and testing of new features, there is a `leap` command in the cli extras (`pip install pylutron_caseta[cli]`) which can be used for communicating directly with the bridge, similar to using `curl`.
+
+Getting information about the bridge:
+
+```
+$ leap 192.168.86.49/server | jq
+{
+ "Servers": [
+ {
+ "href": "/server/1",
+ "Type": "LEAP",
+ "NetworkInterfaces": [
+ {
+ "href": "/networkinterface/1"
+ }
+ ],
+ "EnableState": "Enabled",
+ "LEAPProperties": {
+ "PairingList": {
+ "href": "/server/leap/pairinglist"
+ }
+ },
+ "Endpoints": [
+ {
+ "Protocol": "TCP",
+ "Port": 8081,
+ "AssociatedNetworkInterfaces": null
+ }
+ ]
+ }
+ ]
+}
+```
+
+Turning on the first dimmer:
+
+```
+$ ip=192.168.86.49
+$ device=$(leap "${ip}/zone/status/expanded?where=Zone.ControlType:\"Dimmed\"" | jq -r '.ZoneExpandedStatuses[0].Zone.href')
+$ leap -X CreateRequest "${ip}${device}/commandprocessor" -d '{"Command":{"CommandType":"GoToLevel","Parameter":[{"Type":"Level","Value":100}]}}'
+```
+ + +%package help +Summary: Development documents and examples for pylutron-caseta +Provides: python3-pylutron-caseta-doc +%description help +# pylutron-caseta
+
+A Python API to control Lutron Caséta devices.
+
+[](https://coveralls.io/github/gurumitts/pylutron-caseta?branch=dev)
+
+## Getting started
+
+If you don't know the IP address of the bridge, the `leap-scan` tool (requires the cli extra, `pip install pylutron_caseta[cli]`) will search for LEAP devices on the local network and display their address and LEAP port number.
+
+### Authentication
+
+In order to communicate with the bridge device, you must complete the pairing process. This generates certificate files for authentication. pylutron_caseta can do this two ways.
+
+#### lap-pair
+
+If pylutron_caseta is installed with the cli extra (`pip install pylutron_caseta[cli]`), the `lap-pair` tool can be used to generate the certificate files. Simply running `lap-pair <BRIDGE HOST>` (note the LEAP port number should not be included) will begin the pairing process. The certificate files will be saved in `$XDG_CONFIG_HOME/pylutron_caseta` (normally `~/.config/pylutron_caseta`) in the files `[BRIDGE HOST]-bridge.crt`, `[BRIDGE HOST].crt`, `[BRIDGE HOST].key`. Check `lap-pair --help` if you want to use different files.
+
+#### The pairing module
+
+If pylutron_caseta is being integrated into a larger application, the pairing functionality can be reused to allow pairing from within that application.
+
+```py
+async def pair(host: str):
+ def _ready():
+ print("Press the small black button on the back of the bridge.")
+
+ data = await async_pair(host, _ready)
+ with open("caseta-bridge.crt", "w") as cacert:
+ cacert.write(data["ca"])
+ with open("caseta.crt", "w") as cert:
+ cert.write(data["cert"])
+ with open("caseta.key", "w") as key:
+ key.write(data["key"])
+ print(f"Successfully paired with {data['version']}")
+```
+
+### Connecting to the bridge
+
+Once you have the certificate files, you can connect to the bridge and start controlling devices.
+
+```py
+import asyncio
+
+from pylutron_caseta.smartbridge import Smartbridge
+
+async def example():
+ # `Smartbridge` provides an API for interacting with the Caséta bridge.
+ bridge = Smartbridge.create_tls(
+ "YOUR_BRIDGE_IP", "caseta.key", "caseta.crt", "caseta-bridge.crt"
+ )
+ await bridge.connect()
+
+ # Get the first light.
+ # The device is represented by a dict.
+ device = bridge.get_devices_by_domain("light")[0]
+ # Turn on the light.
+ # Methods that act on devices expect to be given the device id.
+ await bridge.turn_on(device["device_id"])
+
+ await bridge.close()
+
+
+# Because pylutron_caseta uses asyncio,
+# it must be run within the context of an asyncio event loop.
+loop = asyncio.get_event_loop()
+loop.run_until_complete(example())
+```
+
+### The leap tool
+
+For development and testing of new features, there is a `leap` command in the cli extras (`pip install pylutron_caseta[cli]`) which can be used for communicating directly with the bridge, similar to using `curl`.
+
+Getting information about the bridge:
+
+```
+$ leap 192.168.86.49/server | jq
+{
+ "Servers": [
+ {
+ "href": "/server/1",
+ "Type": "LEAP",
+ "NetworkInterfaces": [
+ {
+ "href": "/networkinterface/1"
+ }
+ ],
+ "EnableState": "Enabled",
+ "LEAPProperties": {
+ "PairingList": {
+ "href": "/server/leap/pairinglist"
+ }
+ },
+ "Endpoints": [
+ {
+ "Protocol": "TCP",
+ "Port": 8081,
+ "AssociatedNetworkInterfaces": null
+ }
+ ]
+ }
+ ]
+}
+```
+
+Turning on the first dimmer:
+
+```
+$ ip=192.168.86.49
+$ device=$(leap "${ip}/zone/status/expanded?where=Zone.ControlType:\"Dimmed\"" | jq -r '.ZoneExpandedStatuses[0].Zone.href')
+$ leap -X CreateRequest "${ip}${device}/commandprocessor" -d '{"Command":{"CommandType":"GoToLevel","Parameter":[{"Type":"Level","Value":100}]}}'
+```
+ + +%prep +%autosetup -n pylutron-caseta-0.18.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-pylutron-caseta -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 0.18.1-1 +- Package Spec generated @@ -0,0 +1 @@ +589ca27865d97e5e0de8c3a01f0abc06 pylutron_caseta-0.18.1.tar.gz |