Package: smartrent-py
SmartRent APIsmartrent-pyis a simple library for SmartRent devicesUses websockets for communication and supports async functionsFeel free to ⭐️ this repo to get notified about the latest features!📚 Read the docs! 📚Supported DevicesThis client supports:🔐 Door Locks🌡 Thermostats💧 Leak Sensors💡 Binary Switches🎚 Multilevel (Dimmer) SwitchesUsageInstallationpipinstallsmartrent-pyGetting an API ObjectIn order to get an api object to interact with, you must login with theasync_loginfunction. This starts and handles a web session with SmartRent.importasynciofromsmartrentimportasync_loginasyncdefmain():api=awaitasync_login('<EMAIL>','<PASSWORD>')asyncio.run(main())Getting DevicesYou can get lists of your devices from the api with theget_locks,get_thermostats,get_switchesandget_leak_sensorsfunctions. You can then interact with the devices with their getter and setter functions.importasynciofromsmartrentimportasync_loginasyncdefmain():api=awaitasync_login('<EMAIL>','<PASSWORD>')lock=api.get_locks()[0]locked=lock.get_locked()ifnotlocked:awaitlock.async_set_locked(True)asyncio.run(main())Automatic UpdatingIf you need to get live updates to your device object from SmartRent, you can do that by callingstart_updater. You can stop getting updates by callingstop_updater.You can also set a callback function viaset_update_callbackthat will be called when an update is triggered.For example, if you want to set your thermostat toDad Modeyou can trigger an event every time thecooling_setpointis changed and just change it back to your own desired value.importasynciofromsmartrentimportasync_loginasyncdefmain():api=awaitasync_login('<EMAIL>','<PASSWORD>')thermo=api.get_thermostats()[0]thermo.start_updater()CONSTANT_COOL=80asyncdefon_evt():ifCONSTANT_COOL!=thermo.get_cooling_setpoint():awaitthermo.async_set_cooling_setpoint(CONSTANT_COOL)thermo.set_update_callback(on_evt)whileTrue:awaitasyncio.sleep(60)asyncio.run(main())DevelopmentSetting up dev enviornmentpip install -r requirements_test.txtRunning the code formatterBlackis used for quick and easy code formattingblack smartrentSpecial thanksMuch inspiration was taken from these projects:AMcPherran/SmartRent-MQTT-Bridgenatanweinberger/smartrent-pythonBurry/homebridge-smartrentVersioningWe useSemVerfor versioning. For the versions available, see thetags 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 apiWe need to get info about how the device reacts when it enters different statesBoth of these can be done in one script.You have to runpython3 ./tools/device_helper.pyIt will print out some output and a table withDevice IDs andDevice 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 SensorThe program will then ask for aDevice IDthat you wish to track. Enter in theDevice IDyou 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 humidityThermostatSetpoint  cooling_setpoint    77
MultiLvlSensor      current_humidity    53Once 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 fromdevice_helper.py. Feel free to hide yourDevice IDs if you wish.