Welcome to Open Energy Monitor’s Thermostat documentation!

This module provides a Python API to the Open Energy Monitor Thermostat. Currently it only provides enough functionality for external control of the thermostat rather than providing access to all the configuration options.

This package implements one class oemthermostat.Thermostat which provides properties and methods to control the device. Some simple examples are below:

>>> from oemthermostat import Thermostat
>>> t = thermostat('192.168.0.1')
>>> t.setpoint
21.5
>>> t.setpoint = 18.6
>>> t.state
False
>>> t.switch()
>>> t.state
True

Contents:

HTTP API

The following documents the HTTP API of the thermostat / relay device. This was discovered by reading the original source code for the ESP8266 and using the dev tools in Firefox to inspect the calls in the web interface.

Note

This is incomplete, I will add more as I research it.

GET /control/thermostat.cgi?param=state

Get the status of the thermostat.

Parameters:
  • param=state – Request state of the thermostat.

Example request:

GET /control/thermostat.cgi?param=state HTTP/1.1
Host: example.com
Accept: application/json, text/javascript

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
 "temperature": "22.81",
 "humidity": "N/A",
 "humidistat": 0,
 "relay1state": 0,
 "relay1name":"Heating",
 "state":2,
 "manualsetpoint": 1900,
 "heat_cool":0
}
Status Codes:
POST /control/thermostat.cgi?param=thermostat_state

Set operation mode of the thermostat.

Parameters:
  • param=thermostat_state – Set thermostat operation mode.
Form:

0 - off, 1 - schedule, 2 - manual

POST /control/thermostat.cgi?param=thermostat_manualsetpoint

Set target temperature of thermostat.

Form Parameters:
 
  • int – Temperature in 1/100 C.
POST /control/thermostat.cgi?param=thermostat_heat_cool
Form:0 - heating, 1 - cooling
POST /control/thermostat.cgi?param=thermostat_schedule

Set scheduled setpoint.

Example request:

POST /control/thermostat.cgi?param=thermostat_schedule HTTP/1.1
Accept: application/json

{"mon":
 [
  {"s": 0,
  "e": 2400,
  "sp": 2100
 ]
}
GET /control/relay.cgi?relay1=(int: state)

Change the current state of the relay.

Parameters:
  • relay1 – 0 - off, 1 - on

oemthermostat Package

Classes

Thermostat(host[, port, username, password]) A class for interacting with the OpenEnergyMonitor Thermostat’s HTTP API.

Class Inheritance Diagram

Inheritance diagram of oemthermostat.client.Thermostat