Skip to main content

SmartRent API

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

[!WARNING] I moved out of my apartment and don't have a way to access SmartRent anymore. I will add bug fix PRs as ppl contribute them

smartrent-py is a simple library 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
  • 🏃 Motion Sensors
  • 💡 Binary Switches
  • 🎚 Multilevel (Dimmer) 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

Burry/homebridge-smartrent

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Adding Unsupported Devices!

This library is built in a way that it is easy to add any smartrent device. If you find that one of the devices you own is not supported, we should be able to add it to this libray.

Two things are needed to get the info to add a new device:

  • We have to get some device info from smartrents api
  • We need to get info about how the device reacts when it enters different states

Both of these can be done in one script.

You have to run python3 ./tools/device_helper.py

It will print out some output and a table with Device IDs and Device Names. The device you wish to add should be listed in that table.

Device ID:      Device Name:
==============================
2211234         Thermostat
2212345         Front Door - Lock
2212347         Washer - Leak Sensor

The program will then ask for a Device ID that you wish to track. Enter in the Device ID you want to gather information from.

Put in the Device ID you wish to track: 2211234
Joining topic for 2211234...
{'response': {}, 'status': 'ok'}

You can now change the state of your device either physically in your apartment/house or through the SmartRent app. For example, this is a thermostat's cooling point being turned up, and then the thermostat sending an update about the current humidity

ThermostatSetpoint  cooling_setpoint    77
MultiLvlSensor      current_humidity    53

Once you get a good amount of info, open up an issue describing that you wish to add support for a new device and paste all of the output from device_helper.py. Feel free to hide your Device IDs if you wish.

Metadata

Release files for smartrent-py 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smartrent-py 0.5.2
File Size Uploaded
smartrent-py-0.5.2.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for smartrent-py 0.5.2
File Interpreter ABI Platform
smartrent_py-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 32.1 kB

Release files / smartrent-py-0.5.2.tar.gz

Download URL smartrent-py-0.5.2.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3d11d12c0bfaffbcf0caadc72899205a87e9565d6f770adc06aa9da7b3cd1287
BLAKE2b-256 checksum
How to use checksums
f35c52a84b756d300d4791628b02628d87cf991584388a052420f2e235e71520
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.9.9 Darwin/24.6.0

Release files / smartrent_py-0.5.2-py3-none-any.whl

Download URL smartrent_py-0.5.2-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a270d2981955e1a62674f8e6b9a57fcd299a50263d826040e3e2a8d1ab14d9c9
BLAKE2b-256 checksum
How to use checksums
1a8c8061d66f2a351ce0d6d3cb3e8b10a0abcc2b4a38ae069190700ee3da0f93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.9.9 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page