Unofficial Python API for SmartRent devices
Project description
SmartRent API
Unofficial api for SmartRent devices
Uses websockets for communication and supports async functions
Known Devices supported
Locks
- Yale YRD256
Thermostats
- Honeywell T6 Pro (TH6320ZW2003)
Usage
Installing
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's webserver.
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
and get_thermostats
functions. You can then interact with the devices with thier 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())
TODOs
- Add support for water sensors. I'm not brave enough to get my sensor wet and see what messages it provides
- 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.1.5.tar.gz
.
File metadata
- Download URL: smartrent.py-0.1.5.tar.gz
- Upload date:
- Size: 9.8 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 | 547277441a27d6304c94fb3ccefeac979c2aab20272610c717d0dec8bc435d07 |
|
MD5 | fa5252554a070ded0b0c6993007cf3e2 |
|
BLAKE2b-256 | ded5b31f6e8ce221412a11f74011534dd9cb5af704eb17cdc844ee5eb0cb403f |
File details
Details for the file smartrent.py-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: smartrent.py-0.1.5-py3-none-any.whl
- Upload date:
- Size: 10.7 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 | 2bb1507be81d88e90299e941b0e4e3db2532d22c70d7a76d2973ba988ea934f4 |
|
MD5 | 12ea499f21b0a2a4882ab17f159db1d7 |
|
BLAKE2b-256 | d89f41ec81313c3eae9cbec2bebd72e30efee71e59a457f854e3b20f026a1e2e |