Skip to content
Yurii edited this page Nov 25, 2026 · 5 revisions

REST API

English · Русский

The REST API is available at the ESP32's address over HTTP on port 80. It returns OTGateway state, OpenTherm Slave device data and sensor readings, and accepts settings changes and commands.

Endpoints

Method Path Authentication Request or response
GET /api/info No Device, network, build and memory information
GET /api/vars No OTGateway status, OpenTherm link status and Slave device data
POST /api/vars Yes One or more actions as JSON, up to 1536 bytes. Returns the state
GET /api/sensors Yes Array of sensor names. Add ?detailed=1 to include each sensor’s readings and connection status
GET /api/sensor?id=N Yes Settings for sensor ID N
POST /api/sensor?id=N Yes Update settings for sensor ID N as JSON, up to 1024 bytes
GET /api/sensor/value?id=N Yes Current readings and connection status for sensor ID N
POST /api/sensor/value?id=N Yes Supply a measurement for an enabled MANUAL sensor as JSON, up to 1024 bytes
GET /api/settings/<section> Yes One of the 11 settings objects
POST /api/settings/<section> Yes Update one settings object as JSON, up to 3072 bytes
GET /api/network/settings Yes Configured network settings, including credentials
POST /api/network/settings Yes Update network settings as JSON, up to 1024 bytes
GET /api/network/scan Yes Start or poll a Wi-Fi scan, then retrieve the result array
GET /api/backup/save Yes Download a JSON configuration backup
POST /api/restart Yes Schedule a restart, no body
POST /api/upgrade Yes Upload firmware or filesystem images as multipart form data
GET /api/coredump Yes Download the stored ESP-IDF core dump as binary

Authentication

In the Authentication column, Yes means the endpoint uses the web interface access settings. When authentication is enabled and a password is set, send the username and password using HTTP Basic. No means the endpoint is available without authentication.

Requests through OTGateway's own access point are accepted without authentication when the ESP32 identifies that interface.

Request and response conventions

Send writes as a non-empty JSON object with Content-Type: application/json. Arrays and scalar values are rejected. Write numbers and booleans without quotes. Responses containing data also use JSON.

The reference uses // comments to describe fields. Remove comments before sending a request.

Important

Check the POST response to see which values OTGateway accepted. Valid fields are applied even when the same request contains unknown keys or invalid values.

If you only need the HTTP status, append ?noresponse when posting device settings, network settings, a sensor configuration or a sensor reading. A successful write then returns an empty body.

Status Meaning
200 OK Successful read, or a settings/action request that left the state unchanged
201 Created Settings changed, an action was queued, or a MANUAL measurement was accepted. Repeating a measurement still returns 201
202 Accepted Restart scheduled, OTA accepted, or Wi-Fi scan still running, depending on the route
400 Bad Request Missing/malformed JSON, empty update, missing sensor ID, or an unacceptable measurement
401 Unauthorized The route requires portal authentication. Supply your portal username and password
404 Not Found Unknown settings section, invalid or unavailable sensor ID, absent core dump, or a fresh scan has just been started
409 Conflict Wi-Fi scan requested while Ethernet is selected in network settings
413 Content Too Large JSON body exceeded the limit for that route
503 Service Unavailable A restart is pending/active or an upgrade is in progress. Configuration, sensor, action and restart writes are blocked during this time

OTGateway and OpenTherm Slave device state

Example response from GET /api/vars with temperatures in °C. OTGateway requests a flow temperature of 50 °C. The Slave device reports that heating is active and the burner is on.

{
  "master": {                  // OTGateway state and calculations
    "uptime": 3600,            // ESP32 uptime, s
    "heating": {
      "enabled": true,         // OTGateway has enabled the heating circuit
      "blocking": false,       // Hysteresis has temporarily blocked heating
      "smart_control": false,  // The heating target is indoor temperature
      "overheat": false,       // Heating overheat protection is active
      "freezing": false,       // Freeze protection is active
      "setpoint_temp": 50,     // Setpoint calculated by OTGateway
      "target_temp": 50,       // Heating target temperature
      "current_temp": 46.5,    // Mean heating flow temperature
      "return_temp": 39,       // Mean heating return temperature
      "indoor_temp": 21,       // Combined indoor sensor reading
      "outdoor_temp": 5,       // Combined outdoor sensor reading
      "min_temp": 25,          // Current lower heating target limit
      "max_temp": 70           // Current upper heating target limit
    },
    "dhw": {                   // Domestic hot water
      "enabled": true,         // OTGateway has enabled the DHW circuit
      "overheat": false,       // DHW overheat protection is active
      "target_temp": 50,       // DHW target temperature
      "current_temp": 48,      // Mean DHW temperature
      "return_temp": 0,        // Mean DHW return temperature
      "min_temp": 35,          // Configured lower DHW temperature limit
      "max_temp": 60           // Configured upper DHW temperature limit
    },
    "network": {
      "connected": true,       // ESP32 is connected to the network
      "rssi": -65,             // Wi-Fi signal strength, dBm; 0 outside Wi-Fi mode
      "connection_type": "wifi" // Active connection: wifi, ethernet, wifi-ap or none
    },
    "mqtt": {
      "connected": true        // OTGateway is connected to the MQTT broker
    },
    "emergency": {
      "state": false           // Emergency mode is active
    },
    "ext_pump": {
      "state": false           // The external pump is on
    },
    "cascade_control": {
      "input": true,           // Cascade control input state
      "output": false          // Cascade control output state
    }
  },
  "slave": {                   // Reported by the OpenTherm Slave device
    "member_id": 0,            // Slave member ID
    "flags": 0,                // Slave device configuration flags byte
    "type": 1,                 // Slave device type byte
    "app_version": 1,          // Slave device application version
    "protocol_version": 2.2,   // OpenTherm protocol version
    "connected": true,         // OTGateway receives OpenTherm replies from the Slave device
    "flame": true,             // The Slave device reports a flame
    "cooling": {
      "active": false,         // The Slave device reports active cooling
      "setpoint": 0            // Cooling control signal returned by the Slave device, %
    },
    "modulation": {
      "min": 20,               // Minimum modulation reported by the Slave device, %
      "max": 100               // Modulation limit acknowledged by the Slave device, %
    },
    "power": {
      "min": 4.8,              // Calculated minimum output, kW
      "max": 24                // Maximum output reported by the Slave device, kW
    },
    "heating": {
      "active": true,          // The Slave device reports active heating
      "min_temp": 25,          // Lower heating temperature limit from the Slave device
      "max_temp": 70           // Upper heating temperature limit from the Slave device
    },
    "dhw": {
      "active": false,         // The Slave device reports active DHW
      "min_temp": 35,          // Lower DHW temperature limit from the Slave device
      "max_temp": 60           // Upper DHW temperature limit from the Slave device
    },
    "fault": {
      "active": false,         // Slave device fault flag
      "code": 0                // Manufacturer-specific fault code
    },
    "diag": {
      "active": false,         // Slave device diagnostic flag
      "code": 0                // Manufacturer-specific diagnostic code
    }
  }
}

Device information

Example response from GET /api/info for an ESP32-S3 connected to Wi-Fi, using a build with Ethernet support.

{
  "features": {
    "ethernet": true                 // Ethernet support is compiled in
  },
  "system": {
    "reset_reason": "...",           // Reason for the last reset
    "uptime": 3600                   // ESP32 uptime, s
  },
  "network": {
    "hostname": "otgateway",         // Device hostname on the local network
    "mac": "02:00:00:00:00:01",      // MAC address of the active interface
    "connected": true,               // Wi-Fi or Ethernet uplink has an IP address
    "connection_type": "wifi",       // wifi, ethernet, wifi-ap or none
    "ssid": "example-network",       // Current Wi-Fi SSID; empty outside Wi-Fi mode
    "signal_quality": 70,            // Wi-Fi signal quality, %; 0 outside Wi-Fi mode
    "channel": 6,                    // Current Wi-Fi channel; 0 outside Wi-Fi mode
    "ip": "192.0.2.10",              // Uplink IP address; empty when disconnected
    "subnet": "255.255.255.0",       // Subnet mask
    "gateway": "192.0.2.1",          // Network gateway address
    "dns": "192.0.2.1"               // DNS server address
  },
  "build": {
    "version": "2.0.0",              // Firmware version
    "commit": "abc1234",             // Git revision
    "date": "Jan 15 2026 10:30:00",  // Build date and time
    "env": "s3_mini",                // PlatformIO environment
    "core": "3.3.4",                 // Arduino-ESP32 version
    "sdk": "v5.5.1"                  // ESP-IDF version
  },
  "heap": {                          // Internal heap, bytes
    "total": 327680,                 // Total capacity
    "free": 180224,                  // Currently free
    "min_free": 147456,              // Lowest free space since startup
    "max_free_block": 98304,         // Largest free block
    "min_max_free_block": 81920      // Lowest largest-free-block size since startup
  },
  "psram": {                         // External RAM in bytes
    "total": 2097152,                // Total PSRAM capacity
    "free": 1966080,                 // Currently free
    "min_free": 1900544,             // Lowest free space since startup
    "max_free_block": 1835008        // Largest free block
  },
  "chip": {
    "model": "ESP32-S3",             // Chip model
    "rev": 2,                        // Chip revision
    "cores": 2,                      // Number of cores
    "freq": 240                      // CPU frequency in MHz
  },
  "flash": {
    "size": 4194304                  // Flash capacity in bytes
  }
}

Settings

GET returns a settings section; POST to the same URL changes its settings. The request can contain only the fields being changed, nested as shown in the examples. OTGateway returns the settings in use.

System — /api/settings/system

{
  "loglevel": 3,               // Log level
  "serial": {
    "enabled": true,           // Send logs to the serial port
    "baudrate": 115200         // Serial speed in baud
  },
  "web_serial": {
    "enabled": false           // Enable WebSerial
  },
  "ntp": {
    "server": "pool.ntp.org",  // Time server
    "timezone": "UTC0"         // Time zone in POSIX format
  },
  "unit_system": 0,            // Unit system
  "status_led_gpio": 11        // ESP32 GPIO for the status LED
}

Web interface — /api/settings/portal

{
  "auth": true,            // Require authentication
  "login": "user",         // Portal username
  "password": "password",  // Portal password
  "mdns": true             // Use mDNS
}

Warning

Web interface, MQTT and Wi-Fi settings responses contain saved passwords. Remove the passwords before sharing a response.

OpenTherm — /api/settings/opentherm

{
  "in_gpio": 35,                                   // OpenTherm input GPIO
  "out_gpio": 36,                                  // OpenTherm output GPIO
  "rx_led_gpio": 10,                               // GPIO for the reply indicator
  "member_id": 0,                                  // Master member ID
  "flags": 0,                                      // OpenTherm Master configuration flags
  "heating_disabling_action": 2,                   // Heating circuit disabling action
  "dhw_disabling_action": 2,                       // DHW circuit disabling action
  "ch2_disabling_action": 2,                       // CH2 disabling action
  "min_power": 4,                                  // Minimum thermal output, kW
  "max_power": 24,                                 // Maximum thermal output, kW
  "options": {
    "dhw_support": true,                           // Enable DHW support
    "cooling_support": false,                      // Enable cooling support
    "summer_winter_mode": false,                   // Summer/winter flag value
    "heating_state_to_summer_winter_mode": false,  // Set the summer/winter flag from heating state
    "ch2_always_enabled": true,                    // Keep the second circuit enabled
    "heating_to_ch2": false,                       // Copy the heating request to the second circuit
    "dhw_to_ch2": false,                           // Copy the DHW request to the second circuit
    "dhw_blocking": false,                         // DHW blocking flag value
    "dhw_state_as_dhw_blocking": false,            // Make the blocking flag follow the DHW state
    "max_temp_sync_with_target_temp": true,        // Also send the heating setpoint
                                                   // as the maximum flow temperature
    "get_min_max_temp": true,                      // Read temperature limits from the Slave device
    "ignore_diag_state": false,                    // Ignore the Slave device’s diagnostic flag
    "auto_fault_reset": false,                     // Automatically request a fault reset
    "auto_diag_reset": false,                      // Automatically request a diagnostic reset
    "set_date_and_time": false,                    // Send the date and time to the Slave device
    "always_send_indoor_temp": true,               // Send measured indoor temperature
    "native_otc": false,                           // Use the Slave device’s built-in weather compensation
    "immergas_fix": false                          // Status request format for certain Immergas models
  }
}

MQTT — /api/settings/mqtt

{
  "enabled": true,                        // Connect to the MQTT broker
  "server": "broker.domain",              // Broker hostname or address
  "port": 1883,                           // Broker port
  "user": "",                             // Broker username
  "password": "",                         // Broker password
  "prefix": "otgateway_abcdef",           // Device topic prefix
  "interval": 5,                          // State publication interval, s
  "ha_discovery": true,                   // Enable Home Assistant Discovery
  "ha_discovery_prefix": "homeassistant"  // Home Assistant discovery topic prefix
}

Note

ha_discovery_prefix accepts 1–32 bytes without +, # or embedded NUL characters. It is separate from the device topic prefix; see Home Assistant setup.

Emergency mode — /api/settings/emergency

{
  "target": 40,          // Target temperature in emergency mode
  "threshold_time": 120  // Emergency mode entry and exit delay, s
}

Heating — /api/settings/heating

{
  "enabled": true,             // Allow heating
  "turbo": false,              // Enable turbo with PID or Equitherm
  "target": 50,                // Heating target temperature
  "hysteresis": {
    "enabled": true,           // Use heating hysteresis
    "value": 0.5               // Deviation from the indoor target temperature
  },
  "turbo_factor": 7.5,         // Turbo mode factor
  "min_temp": 25,              // Lower heating flow temperature limit
  "max_temp": 70,              // Upper heating flow temperature limit
  "max_modulation": 100,       // Relative modulation limit for heating, %
  "indoor_temp_avg_type": 0,   // How indoor sensor readings are combined
                               // 0 — mean, 1 — minimum, 2 — maximum
  "outdoor_temp_avg_type": 0,  // How outdoor sensor readings are combined
                               // 0 — mean, 1 — minimum, 2 — maximum
  "overheat_protection": {
    "high_temp": 85,           // Overheat protection activation threshold
    "low_temp": 75             // Overheat protection reset threshold
  },
  "freeze_protection": {
    "high_temp": 15,           // Temperature at which freeze protection clears
    "low_temp": 10             // Threshold for forcing heating on
  }
}

Domestic hot water — /api/settings/dhw

{
  "enabled": true,        // Allow DHW heating
  "target": 50,           // DHW target temperature
  "min_temp": 35,         // Lower DHW target temperature limit
  "max_temp": 60,         // Upper DHW target temperature limit
  "max_modulation": 100,  // Relative modulation limit for DHW, %
  "overheat_protection": {
    "high_temp": 80,      // Overheat protection activation threshold
    "low_temp": 70        // Overheat protection reset threshold
  }
}

PID controller — /api/settings/pid

{
  "enabled": false,         // Enable PID control
  "p_factor": 2,            // Proportional gain
  "i_factor": 0.002,        // Integral gain
  "d_factor": 0,            // Derivative gain
  "dt": 300,                // PID calculation interval, s
  "min_temp": 0,            // Lower PID output limit
  "max_temp": 70,           // Upper PID output limit
  "deadband": {
    "enabled": true,        // Use the deadband
    "p_multiplier": 1,      // P multiplier inside the deadband
    "i_multiplier": 0.05,   // I multiplier inside the deadband
    "d_multiplier": 1,      // D multiplier inside the deadband
    "threshold_high": 0.5,  // Deadband width above the target
    "threshold_low": 1      // Deadband width below the target
  }
}

Weather compensation — /api/settings/equitherm

{
  "enabled": false,        // Enable weather compensation
  "slope": 0.7,
  "exponent": 1.3,
  "shift": 0,
  "target_diff_factor": 2  // Coefficient T
}

The Equitherm coefficients are described under Curve parameters.

External pump — /api/settings/ext_pump

{
  "use": false,                 // Enable external pump control
  "gpio": 255,                  // Relay GPIO
  "invert_state": false,        // Invert GPIO state
  "post_circulation_time": 10,  // Post-circulation time, min
  "antistuck_interval": 30,     // Anti-stuck interval, days
  "antistuck_time": 5           // Anti-stuck run duration, min
}

Cascade control — /api/settings/cascade_control

{
  "input": {                     // Cascade input settings
    "enabled": false,            // Enable input
    "gpio": 255,                 // Input GPIO
    "invert_state": false,       // Invert GPIO state
    "threshold_time": 60         // New state confirmation time, s
  },
  "output": {                    // Cascade output settings
    "enabled": false,            // Enable output
    "gpio": 255,                 // Output GPIO
    "invert_state": false,       // Invert GPIO state
    "threshold_time": 60,        // New state confirmation time, s
    "on_fault": true,            // On a Slave device fault
    "on_loss_connection": true,  // On loss of the OpenTherm connection
    "on_enabled_heating": false  // When heating is enabled and allowed by the input
  }
}

Network

Network settings — /api/network/settings

{
  "hostname": "otgateway",           // Device name on the local network
  "use_dhcp": true,                  // Get network settings from the router
  "static_config": {                 // Static network configuration
    "ip": "192.0.2.10",              // Device IP address
    "gateway": "192.0.2.1",          // Network gateway address
    "subnet": "255.255.255.0",       // Subnet mask
    "dns": "192.0.2.1"               // DNS server address
  },
  "wifi": {
    "ap": {                          // OTGateway access point
      "ssid": "example-ap",          // Access point name
      "password": "example-password", // Access point password
      "channel": 6                   // Access point channel
    },
    "sta": {                         // Wi-Fi network connection
      "ssid": "example-network",     // Wi-Fi network name
      "password": "",                // Wi-Fi network password
      "channel": 0                   // 0: automatic channel selection
    }
  },
  "ethernet": {                      // Present only in Ethernet-enabled builds
    "gpio": {
      "clk": 255,                    // SPI clock GPIO
      "mosi": 255,                   // SPI MOSI GPIO
      "miso": 255,                   // SPI MISO GPIO
      "cs": 255,                     // Chip select GPIO
      "irq": 255,                    // Interrupt GPIO
      "rst": 255                     // Reset GPIO
    },
    "configured": false              // Read-only: all 6 GPIOs are valid
  },
  "type": 2                          // 2: Wi-Fi; 3: Ethernet
}

Ethernet GPIOs are unassigned (255) in this example. Use integer GPIO numbers; 255 or an empty string clears an assignment. ethernet.configured checks that all 6 GPIOs are valid. Builds without Ethernet support omit ethernet and do not accept type: 3.

type selects Wi-Fi (2) or Ethernet (3). The active interface appears as connection_type in /api/info and /api/vars: wifi, ethernet, wifi-ap or none. The fallback access point (wifi-ap) does not count as a network connection: connected is false and the uplink address fields are empty. features.ethernet is present only in Ethernet-enabled builds. See network setup.

The device reconnects after you change its network settings. The ?noreconnect parameter on a POST defers reconnection. This lets you make several changes and restart OTGateway once at the end.

Wi-Fi scan — GET /api/network/scan

Scanning is available only with Wi-Fi selected (type: 2). If Ethernet is selected (type: 3), the endpoint returns 409, including during a temporary Wi-Fi fallback.

  1. Send the request. If no result is ready, OTGateway starts a scan and returns 404.
  2. Repeat the request after a few seconds. A 202 response means the scan is still running.
  3. On 200, read the array of networks. An empty array means none were found. The next request starts a new scan.

Each entry contains the network name (ssid), access point address (bssid), signal quality (signal_quality, %), channel (channel), hidden-network flag (hidden) and Wi-Fi encryption mode code (auth).

Units of measurement

The unit_system field in /api/settings/system selects the units for readings and setpoints.

Quantity Metric (0) Imperial (1)
Temperature °C °F
DHW flow L/min US gal/min
Pressure bar psi
Power kW kW
Modulation, humidity % %

Changing the unit system preserves the numeric values for hysteresis, PID deadband width and Equitherm shift. Standalone PID limits convert as temperatures. When PID runs with Equitherm, the limits are corrections to the heating curve and keep their numeric values.

Actions

Send an actions object to POST /api/vars. You can request several actions at once. A value of true requests the action, and false leaves the state unchanged.

Field in actions What OTGateway does
restart Schedules an ESP32 restart in 15 seconds
reset_fault Asks the Slave device to reset its fault
reset_diagnostic Asks the Slave device to reset its diagnostic indication

To clear an active diagnostic indication on the Slave device, send reset_diagnostic.

curl --user 'user:password' -i -H 'Content-Type: application/json' \
  -d '{"actions":{"reset_diagnostic":true}}' 'http://gateway.example/api/vars'

A 201 Created response means OTGateway queued the command. If it is already queued, OTGateway returns 200 OK. The state can be read again after the next OpenTherm exchange.

curl 'http://gateway.example/api/vars'

If slave.connected is true, check slave.diag.active. A value of false means the Slave device has cleared the indication. If it is still active, slave.diag.code gives the diagnostic code.

To restart the device, you can also send POST /api/restart without a request body. It returns an empty 202 response and schedules a restart in 15 seconds.

Sensors

REST sensor IDs start at 0. For example, Heating temp has ID 2 and appears as #3 in the web interface. Renaming a sensor changes its MQTT slug and preserves its REST ID.

  • GET /api/sensors returns names. The array index is the ID, including disabled sensors and unused entries.
  • GET /api/sensors?detailed=1 returns enabled, name, slug, purpose and readings at those same indices.
  • GET /api/sensor?id=N returns the full configuration, including type.

Default sensor IDs

The standard build supports sensor IDs 0–19. These are the default assignments before any saved configuration is loaded. Configuration is available at /api/sensor?id=N with the same number as its reading URL. Sensor values remain readable while disabled or disconnected. The enabled and connected fields show whether the sensor is enabled and connected.

ID Default name MQTT slug Type Purpose Enabled Reading URL
0 Outdoor temp outdoor_temp 0 0 No /api/sensor/value?id=0
1 Indoor temp indoor_temp 51 1 No /api/sensor/value?id=1
2 Heating temp heating_temp 1 2 Yes /api/sensor/value?id=2
3 Heating return temp heating_return_temp 2 3 Yes /api/sensor/value?id=3
4 Heating setpoint temp heating_setpoint_temp 253 254 Yes /api/sensor/value?id=4
5 DHW temp dhw_temp 3 4 Yes /api/sensor/value?id=5
6 DHW flow rate dhw_flow_rate 5 6 Yes /api/sensor/value?id=6
7 Exhaust temp exhaust_temp 7 7 Yes /api/sensor/value?id=7
8 Pressure pressure 9 252 Yes /api/sensor/value?id=8
9 Modulation level modulation_level 10 8 Yes /api/sensor/value?id=9
10 Power power 11 249 Yes /api/sensor/value?id=10
11–19 Unnamed Empty 255 255 No Use the individual sensor ID

A modulation reading of 0 is valid while the burner is running. slave.flame in /api/vars reports flame status.

Sensor configuration

This is the GET /api/sensor?id=1 response for Indoor temp in the default s3_mini configuration. To change its settings, send only the fields you want to update to POST /api/sensor?id=1.

{
  "id": 1,                               // Sensor ID
  "enabled": false,                      // Sensor enabled
  "name": "Indoor temp",                 // Sensor name
  "slug": "indoor_temp",                 // Sensor identifier for MQTT
  "purpose": 1,                          // Sensor purpose
  "type": 51,                            // Reading source type
  "gpio": 12,                            // Sensor GPIO
  "address": "00:00:00:00:00:00:00:00",  // Sensor address
  "offset": 0,                           // Reading offset
  "factor": 1,                           // Reading multiplier
  "filtering": false,                    // Reading smoothing
  "filtering_factor": 0.15               // Smoothing factor
}

Reading source — type

The type determines where OTGateway gets the reading. OpenTherm data depends on the Slave device's capabilities. Bluetooth requires a BLE-enabled build.

Type Source Type Source
0 OpenTherm outdoor temperature 14 Supply fan speed
1 Heating flow temperature 15 Solar storage temperature
2 Heating return temperature 16 Solar collector temperature
3 DHW temperature 17 Fan speed setpoint
4 Second DHW temperature 18 Current fan speed
5 DHW flow rate 19 Burner starts
6 Second heating circuit temperature 20 DHW burner starts
7 Exhaust temperature 21 Heating pump starts
8 Heat exchanger temperature 22 DHW pump starts
9 Pressure 23 Burner operating hours
10 Modulation level 24 DHW burner operating hours
11 Current boiler power 25 Heating pump operating hours
12 Exhaust CO₂ 26 DHW pump operating hours
13 Exhaust fan speed 27 Cooling hours
50 NTC 10 kΩ 253 Heating setpoint calculated by OTGateway
51 Dallas temperature 254 MANUAL input
52 Bluetooth 255 Unconfigured
53 DHT11 54 DHT22

Purpose — purpose

The purpose determines where a reading is used, for example in the indoor or outdoor temperature calculation. For MANUAL input it also defines the units of the supplied value.

Purpose Meaning Purpose Meaning
0 Outdoor temperature 247 Number
1 Indoor temperature 248 Power factor (%)
2 Heating temperature 249 Power (kW)
3 Heating return temperature 250 Fan speed (rpm)
4 DHW temperature 251 CO₂ (ppm)
5 DHW return temperature 252 Pressure
6 DHW flow rate 253 Humidity (%)
7 Exhaust temperature 254 Generic temperature
8 Modulation (%) 255 Unconfigured

Sensor readings

Every REST reading object includes connected (boolean) and signal_quality (percentage). The remaining fields depend on the configured type. A disconnected sensor can retain its last value or show its initial value.

Type Additional reading fields
Bluetooth temperature, humidity (%), battery (%), rssi (dBm)
DHT11, DHT22 temperature, humidity (%)
Dallas, NTC, OpenTherm, controller setpoint, MANUAL sensors and unconfigured entries value

Bluetooth and MANUAL sensors time out after 10 minutes without activity. The other types use a 3-minute inactivity timeout. A driver can also report a disconnection earlier.

Write a MANUAL reading

Send POST /api/sensor/value?id=N for an enabled MANUAL sensor. In value, supply a finite JSON number in the units selected in OTGateway.

A successful write updates the reading and activity time, marks the sensor connected and requests MQTT publication. Repeating the same value also refreshes activity.

A 400 response means the value is missing or quoted, the sensor is disabled, or its type is a physical source.

Examples

In the curl examples, replace http://gateway.example with your device's address and replace user and password with your web interface username and password. If authentication is disabled, omit --user 'user:password'.

Follow a heating request over OpenTherm

Read the current state and confirm that slave.connected is true.

Under master.heating, check the target mode and its limits. With smart_control = true, the target is indoor temperature (PID, Equitherm or the Slave device's native weather compensation). With false, it is heating fluid temperature. The allowed range is given by min_temp and max_temp.

curl 'http://gateway.example/api/vars'

This example uses direct control (smart_control: false) and metric units. To set a flow temperature of 50 °C, send the target field. The value must be within the displayed range.

curl --user 'user:password' -H 'Content-Type: application/json' \
  -d '{"target":50}' 'http://gateway.example/api/settings/heating'

Check target in the response — 50 confirms the accepted setting. Then repeat GET /api/vars. In the state excerpt below, OTGateway allows heating and the Slave device reports an active circuit and flame.

{
  "master": {                  // OTGateway state and calculations
    "heating": {
      "enabled": true,         // OTGateway has enabled the heating circuit
      "smart_control": false,  // The heating target is indoor temperature
      "setpoint_temp": 50      // Setpoint calculated by OTGateway
    }
  },
  "slave": {                   // Reported by the OpenTherm Slave device
    "connected": true,         // OTGateway receives OpenTherm replies from the Slave device
    "heating": {
      "active": true           // The Slave device reports active heating
    },
    "flame": true              // The Slave device reports a flame
  }
}

OTGateway calculates master.heating.setpoint_temp according to the heating mode. The Slave device reports heating activity in slave.heating.active and burner operation in slave.flame. To check the measured flow temperature, read Heating temp.

Change one setting

To enable heating hysteresis, send only the nested hysteresis.enabled field. Check its value in the response.

curl --user 'user:password' -H 'Content-Type: application/json' \
  -d '{"hysteresis":{"enabled":true}}' 'http://gateway.example/api/settings/heating'

Request a Slave device fault reset

The first command asks OTGateway to reset the fault. OTGateway sends the reset command to the Slave device over OpenTherm. After the next exchange, run the second command and check slave.fault.active and slave.fault.code.

curl --user 'user:password' -H 'Content-Type: application/json' \
  -d '{"actions":{"reset_fault":true}}' 'http://gateway.example/api/vars'
curl 'http://gateway.example/api/vars'

Work with a sensor

Read a physical sensor

The OpenTherm task regularly reads the flow temperature from the Slave device and stores it in ESP32 memory. The HTTP client receives the latest stored reading.

sequenceDiagram
    participant Slave device as OpenTherm Slave device
    box OTGateway (ESP32)
        participant Task as OpenTherm task
        participant Memory as Memory
        participant API as REST API
    end
    participant Client as HTTP client

    loop Scheduled polling
        Task->>Slave device: Read flow<br/>temperature
        Slave device-->>Task: 46.5 °C
        Task->>Memory: Store Heating temp<br/>46.5 °C
    end

    Client->>API: GET /api/sensors<br/>?detailed=1
    API->>Memory: Read sensor values
    Memory-->>API: Heating temp<br/>46.5 °C
    API-->>Client: 200 OK<br/>Readings in JSON
Loading

Request the list of sensors with their readings.

curl --user 'user:password' 'http://gateway.example/api/sensors?detailed=1'

Find the sensor in the array by its name. The default name for the flow temperature sensor is Heating temp. These 3 fields show its reading at a flow temperature of 46.5 °C.

{
  "name": "Heating temp",
  "connected": true,
  "value": 46.5
}

The value field uses the configured temperature units. If connected is false, the stored reading may be from before the connection was lost.

Connect a Dallas sensor

The default Indoor temp sensor has ID 1 and starts disabled. In this example the 1-Wire bus is connected to GPIO 12 on an s3_mini. Use the GPIO you wired in the first request.

curl --user 'user:password' -H 'Content-Type: application/json' \
  -d '{"enabled":true,"gpio":12}' 'http://gateway.example/api/sensor?id=1'
curl --user 'user:password' 'http://gateway.example/api/sensor?id=1'
curl --user 'user:password' 'http://gateway.example/api/sensor/value?id=1'

With no address assigned, OTGateway can select the first unclaimed probe on the bus. After discovery, the second request shows its 8-byte address and the third returns its value. To select a specific probe, include its address in the first request.

Supply a reading from another system

First find an unused sensor ID. These commands use ID 11, which is free in the default configuration. If it is in use, choose a free ID and use that ID in every request below. Create an enabled MANUAL sensor (type 254) named Indoor probe. Purpose 254 displays the temperature. Choose purpose 1 if this reading should contribute to indoor heating control.

curl --user 'user:password' -H 'Content-Type: application/json' \
  -d '{"enabled":true,"name":"Indoor probe","type":254,"purpose":254}' \
  'http://gateway.example/api/sensor?id=11'

Check the returned enabled, type, purpose and slug. Send the reading in the device's units, then read it back using the same sensor ID.

curl --user 'user:password' -H 'Content-Type: application/json' \
  -d '{"value":21.5}' 'http://gateway.example/api/sensor/value?id=11'
curl --user 'user:password' 'http://gateway.example/api/sensor/value?id=11'

POST returns HTTP 201 with the accepted reading. GET returns the current reading with HTTP 200. This example uses metric units.

{
  "connected": true,      // OTGateway receives sensor readings
  "signal_quality": 100,  // Signal quality, %
  "value": 21.5           // Sensor reading
}

Important

Keep the interval between readings under 10 minutes, even if the temperature stays the same.

To disable the sensor, POST {"enabled":false} to /api/sensor?id=11. After renaming it, update the slug in its MQTT topics as well.

Clone this wiki locally