Skip to main content

Unofficial Python API for SmartRent devices

Project description

SmartRent API

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

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!

📚 Read the docs! 📚

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 and get_thermostats 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

Burry/homebridge-smartrent

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


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.2.2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

smartrent.py-0.2.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: smartrent.py-0.2.2.tar.gz
  • Upload date:
  • Size: 11.6 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.2.2.tar.gz
Algorithm Hash digest
SHA256 65c077ae5cd3e6280cf18fa2f29bcbcd5fa1c596a08a015fb3849e0d218ab102
MD5 2013243b859d04514f91e13d2df33e3f
BLAKE2b-256 854c5a6eb582c8db7d20263e715e56267114c0dfa45704415be7eef566e19115

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smartrent.py-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 15.0 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.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ee5c6a0513f52a0aac949ae6740d3bb6077050b296336e7802a71f8832151746
MD5 ec7d233821f17a17ecf6b56bc542b7ea
BLAKE2b-256 609f1a3ffbeba0f38f33b5b54b4a84a114f5b03975d8a670c6acb83ef868d395

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