Skip to main content

Unofficial Python API for SmartRent devices

Project description

SmartRent API

PyPI version Supported Python versions Downloads PyPI downloads GitHub Documentation Status Code style: black

Unofficial api for SmartRent devices

Uses websockets for communication and supports async functions

📚 Read the docs! 📚

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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartrent.py-0.1.6.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

smartrent.py-0.1.6-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file smartrent.py-0.1.6.tar.gz.

File metadata

  • Download URL: smartrent.py-0.1.6.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

Hashes for smartrent.py-0.1.6.tar.gz
Algorithm Hash digest
SHA256 b5d59367b0609e83b3320f6022b0a704473f20efe04e53b95f86efa7fc627642
MD5 e3b3fef147db52c4a3ce2d5a828f0069
BLAKE2b-256 ed120b0a68b0450d4a00fe52c24e2baf4a97021cbbb8b9569549d0a7c12169fe

See more details on using hashes here.

File details

Details for the file smartrent.py-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: smartrent.py-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 10.8 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

Hashes for smartrent.py-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4078d104166bda2033428412826a6d297a1aadc2f33ebc96d7ca7b880a5fe4f1
MD5 f95d9f6202d97c509f7f7efccd7e314f
BLAKE2b-256 30eef160d22861ceebcdb919634d7fd8ac2ce4605c6019b9fda99aeaa13be389

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page