Unofficial Python API for SmartRent devices
Project description
SmartRent API
Unofficial api for SmartRent devices
Uses websockets for communication and supports async functions
Feel free to ⭐️ this repo to get notified about the latest features!
Supported Devices
This client supports:
- 🔐 Door Locks
- 🌡 Thermostats
- 💧 Leak Sensors
- 💡 Binary Switches
Usage
Installation
pip install smartrent.py
Getting an API Object
In order to get an api object to interact with, you must login with the async_login
function. This starts and handles a web session with SmartRent.
import asyncio
from smartrent import async_login
async def main():
api = await async_login('<EMAIL>', '<PASSWORD>')
asyncio.run(main())
Getting Devices
You can get lists of your devices from the api with the get_locks
, get_thermostats
, get_switches
and get_leak_sensors
functions. You can then interact with the devices with their getter and setter functions.
import asyncio
from smartrent import async_login
async def main():
api = await async_login('<EMAIL>', '<PASSWORD>')
lock = api.get_locks()[0]
locked = lock.get_locked()
if not locked:
await lock.async_set_locked(True)
asyncio.run(main())
Automatic Updating
If you need to get live updates to your device object from SmartRent, you can do that by calling start_updater
. You can stop getting updates by calling stop_updater
.
You can also set a callback function via set_update_callback
that will be called when an update is triggered.
For example, if you want to set your thermostat to Dad Mode
you can trigger an event every time the cooling_setpoint
is changed and just change it back to your own desired value.
import asyncio
from smartrent import async_login
async def main():
api = await async_login('<EMAIL>', '<PASSWORD>')
thermo = api.get_thermostats()[0]
thermo.start_updater()
CONSTANT_COOL = 80
async def on_evt():
if CONSTANT_COOL != thermo.get_cooling_setpoint():
await thermo.async_set_cooling_setpoint(CONSTANT_COOL)
thermo.set_update_callback(on_evt)
while True:
await asyncio.sleep(60)
asyncio.run(main())
Development
Setting up dev enviornment
pip install -r requirements_test.txt
Running the code formatter
Black is used for quick and easy code formatting
black smartrent
Special thanks
Much inspiration was taken from these projects:
AMcPherran/SmartRent-MQTT-Bridge
natanweinberger/smartrent-python
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
TODOs
- Add support for Two Factor Auth
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file smartrent.py-0.2.3.tar.gz
.
File metadata
- Download URL: smartrent.py-0.2.3.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Darwin/20.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fdb4cd0b24fa5fc3512c8f46bd931c394f0cbfe751ff7232bd1e63b77969a2f |
|
MD5 | 76fd6f1fc3e37344ae67f145128e3425 |
|
BLAKE2b-256 | b4442f098d39f40816956274955fbee3e5bf7d2782c90e26cde23a7806162504 |
File details
Details for the file smartrent.py-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: smartrent.py-0.2.3-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Darwin/20.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60a1e18d798b889e42b7d1bf4f76ed666ebe0fd87a7bb4824c895d2e4cdaea5e |
|
MD5 | 0c32fbe271d055b85fb262724a6dc4df |
|
BLAKE2b-256 | fe591e4d8ae2f1aefbd9549952dd8b8ae5c368f337b14dd2f08e5e44ae0f86a0 |