client library for wifi thermostats sold by radiothermostat.com
Project description
Introduction
This is a library for communicating with a wifi-enabled home thermostat made by Radio Thermostat Company of America. At the time of writing, this includes the CT30, CT80, and the Filtrete 3M50, which is made by Radio Thermostat but rebranded and sold at Home Depot in the US.
Radio Thermostat Company of America was not involved in the creation of this software and has not sanctioned or endorsed it in any way.
License
This software is available under a BSD-style license. Please see LICENSE.txt.
Features
Auto-Discovery Your thermostat can be automatically detected, so there is no need to enter an IP address or domain name.
Comprehensive Nearly every documented feature that works is implemented in this library.
Python 3 Support This works in all Python versions from 2.7 up.
Tested There is good test coverage using true unit tests.
Usage
Getting Started
Import the library, and away we go.
>>> import radiotherm >>> tstat = radiotherm.get_thermostat('192.168.0.2') >>> tstat.temp {'raw': 72.5}
If you have only one thermostat on your network, you can do auto-discovery by omitting the address.
>>> tstat = radiotherm.get_thermostat()
Human-Readable Values
The value from the thermostat is always returned under the key ‘raw’. For fields that support human-readable values, there will be a key ‘human’.
>>> tstat.tmode {'raw': 2, 'human': 'Cool'}
API
The library centers around the Thermostat class, whose attributes are closely related to the attributes defined in Radio Thermostat’s API doccumentation. For example, /tstat/temp in this case maps to the “temp” attribute on your Thermostat instance.
Device Versions
Supported models:
CT30 v1.75
CT30 v1.92
CT30 v1.94
CT30 v1.99
CT50 V1.09
CT50 V1.88
CT50 V1.92
CT50 V1.94
CT80 Rev B1 V1.00
CT80 Rev B2 V1.00
CT80 Rev B2 V1.03
CT80 Rev B2 V1.09
Since I only have access to the 3M50 (which reports its model as “CT50 V1.94”), that is the model that most development has occured with. Do you have another model? Let me know, and let’s collaborate to get it supported!
New models that are derivatives of the CT30 or CT80 should be detected automatically and basic functionality should work. If you find this is not the case, it can be supported easily by subclassing either the CT30 or CT80 classes, depending on the thermostat model. Most of the API should work on all devices, but there are apparently some differences that will need to be accounted for. Long-term, I expect for those common features to be implemented on CommonThermostat, while device-specific deviations will be implemented on subclasses, such as the CT50v194 class.
Supported Features
Many of the features documented in the manufacturer’s API reference do not seem to work. For example, /tstat/save_energy seems to be broken. This library should not implement those broken features.
Also, there are some features, like humidity control, that are only available on specific devices.
Isn’t there already a python library?
Yes! Many thanks to Paul Jenning for creating Python-TStat. The existance of his library was a substantial motivation for me to buy this device.
Why create a new library?
I quickly identified some areas of Python-TStat that I wanted to improve. That led me to realize that there were conceptual differences between that library and my idea of what I wanted to use in my own projects.
Thin wrapper. I want API libraries to be thin. Python-TStat does automatic result caching by default, which I personally don’t want.
PEP-8. I think it’s important, and it would have taken a lot of work to make Python-TStat compliant.
Testing. It’s important to me that code be tested, and Python-TStat had no tests. Proper unit-testing is much easier to do when the code was written from the beginning with it in mind, so that made it more convenient to start over.
Simplicity. My approach to defining the API in python is inspired by Django’s model API, and I think it’s resulted in easy-to-use and easy-to-read code.
Less Code. I’ve implemented a feature set very similar to that of Python-TStat (minus caching). Not counting comments, doc blocks or blank lines, this library (at the time of initial release) has 201 lines of code, whereas Python-TStat has 349.
Python 3 Support. This is also important to me. This library supports all python versions from 2.6 up.
All of that said, Python-TStat is a good library that works well. I just decided that the quickest way for me to achieve the above goals was to start from scratch, which was relatively painless since the device’s API isn’t very complicated or large.
Release Notes
2.1.0
Shorten http request timeout for cases where the thermostat does not respond. (@vinnyfuria)
Drop python 2.6 support
Use GitHub Actions instead of Travis-CI (@mhrivnak)
2.0.0
Add support for the LED API (David Rasch)
Allow unknown thermostats to work properly instead of failing (@JerryWorkman, @craftyguy)
Handle transient thermostat errors (@tubaman)
1.4.1
Minor update to bump version in setup.py
1.4
Several new models were added with thanks to the corresponding contributors!
CT80 Rev B1 V1.00 - Eamon Doyle CT80 Rev B2 V1.00 - Clayton Craft
Additional changes: - Add ‘model’ parameter to get_thermostat() - skimj - Add program_mode for CT80 - skimj
1.3
Several models were added with thanks to the corresponding contributors!
CT30 v1.75 - Albert Lee CT30 V1.94 - billy1 CT30 v1.99 - Adam Fazzari CT50 V1.92 - mdingman CT80 Rev B2 V1.09 - Steve Bauer
Thanks also to Albert Lee for adding remote temperature support, energy LED support, plus support for the “lock_mode” and “simple_mode”.
1.2
Thanks to a contribution from Nick Pegg, the CT80 Rev B2 V1.03 is now supported.
Support for Travis CI was added, so all pushes to the GitHub repository are automatically tested with multiple python versions.
1.1
Thanks to community contributions, this library now supports the CT50 V1.09 and CT50 V1.88. No changes were made except to certify that all functionality works with these models, and add a new subclass for each.
1.0
Initial release! This supports only the CT50 V1.94
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
File details
Details for the file radiotherm-2.1.0.tar.gz
.
File metadata
- Download URL: radiotherm-2.1.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | adc84632b9527162d4790b0a5f9f1ed3305f0a5cdb52892aee54a203d773feee |
|
MD5 | f0b06e0f87bdd070a907fa42f6c741c4 |
|
BLAKE2b-256 | b1d80e0f2525777db7f32c0477c82fb7979b1c0a7f1f33eded8c286c5b0b2208 |