1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
# Python NuHeat
[](https://pypi.org/project/nuheat/)
[](https://pypi.org/project/nuheat/)
[](https://pypi.org/project/nuheat/)
[](https://github.com/broox/python-nuheat/actions?query=branch%3Amaster)
[](https://coveralls.io/github/broox/python-nuheat?branch=master)
[](https://snyk.io/advisor/python/nuheat)
A Python 3 library that allows control of connected [NuHeat Signature](http://www.nuheat.com/products/thermostats/signature-thermostat) radiant floor thermostats.
* This uses the web-based NuHeat API, so it requires an external internet connection
* The API in use is not an officially published API, so it could change without notice
* Please contribute!
# Installation
```shell
$ pip install nuheat
```
# Usage
```python
from nuheat import NuHeat
# Initalize an API session with your login credentials
api = NuHeat("email@example.com", "your-secure-password")
api.authenticate()
# Fetch a thermostat by serial number / ID. This can be found on the NuHeat website by selecting
# your thermostat and noting the Thermostat ID
thermostat = api.get_thermostat("12345")
# Get the current temperature of the thermostat
thermostat.fahrenheit
thermostat.celsius
# Get the current target temperature of the thermostat
thermostat.target_fahrenheit
thermostat.target_celsius
# Get the minimum and maximum temperatures supported by the thermostat
thermostat.min_fahrenheit
thermostat.max_fahrenheit
thermostat.min_celsius
thermostat.max_celsius
# Get the current mode of the thermostat
thermostat.schedule_mode
# The possible schedule modes are one of the following 3 integers:
# 1. Run the schedule programmed into the thermostat
# 2. Temporarily hold a target temperature until the next scheduled event
# 3. Permanently hold a target temperature until the mode is manually changed
# Get other properties
thermostat.heating
thermostat.online
thermostat.serial_number
# Set a new temperature and permanently hold
# Note: Any pre-programmed thermostat schedules will be ignored until you resume the schedule or
# change the mode.
thermostat.set_target_fahrenheit(72)
# If you prefer celsius...
thermostat.set_target_celsius(22)
# You can also do this via the convenience property setters
thermostat.target_fahrenheit = 72
# or with celsius
thermostat.target_celsius = 22
# To resume the schedule programmed into the thermostat
thermostat.resume_schedule()
# Which is effectively the same as explicitly changing the mode like so
thermostat.schedule_mode = 1
# To set a new target temperature with an explicit schedule mode
thermostat.set_target_fahrenheit(72, mode=2)
# If you prefer celsius, you can use that too
thermostat.set_target_celsius(22, mode=2)
# Set a target temperature until a specified datetime
# Note: A timezone aware datetime should be passed in, otherwise UTC will be assumed
from datetime import datetime, timedelta, timezone
hold_time = datetime.now() + timedelta(hours=4)
thermostat.set_target_fahrenheit(69, mode=2, hold_time=hold_time)
```
# Contributing
Pull requests are always welcome!
## Running locally with Docker
```shell
# Build and run the docker container:
$ docker build -t python-nuheat .
$ docker run -it --rm -v $(pwd):/python-nuheat python-nuheat
# To run the interactive shell:
$ ipython
# To run tests:
$ pytest
```
|