HCPBridge Documentation GitHub

HTTP API

The web interface uses a small JSON API on port 80. You can use it for scripts and other home automation systems as well.

AuthenticationWithout a web password the API is open in your network. With a password every endpoint below (except /events) requires HTTP basic authentication with user admin. The OTA page has its own login (admin / admin).

Overview

RouteMethodPurpose
/GETWeb interface
/statusGETDoor state, sensors, digital I/O
/statushGETRaw door state
/commandGETDoor and light commands
/ioGETSwitch a digital output
/configGET / POSTRead / write the configuration
/sysinfoGETDiagnostics
/eventsGET (SSE)Live sensor and I/O changes
/resetGETFactory reset: erases all settings and restarts
/updateGET / POSTOTA firmware update page (ElegantOTA)

GET /status

{
  "doorstate": "open",
  "valid": true,
  "targetPosition": 100,
  "currentPosition": 100,
  "light": false,
  "state": 0,
  "busResponseAge": 0,
  "lastModbusRespone": 123456,
  "swversion": "1.1.0",
  "sensors": { "_failed": [], "temp": "21.4 °C", "dist": "38 cm", "free": "false" },
  "sensor_status": { "BME280": "active", "DS18X20": "off", "DHT22": "off",
                     "HC-SR04": "active", "HC-SR501": "off", "MQ4": "off" },
  "io": { "in1": false, "out1": true },
  "lastCommandTopic": "hormann/hcpbridge/command/door",
  "lastCommandPayload": "open"
}
FieldMeaning
doorstateDetailed state: open, closed, opening, closing, open h, opening h, opening v, venting, stopped
validtrue once the operator has talked to the bridge
currentPosition / targetPosition0 (closed) … 100 (open)
lightOperator light on
stateNumeric state: 0 open, 1 opening, 2 closed, 3 closing, 4 half open, 5 moving to vent, 6 vent, 7 moving to half, 8 stopped
busResponseAgeSeconds since the last bus request (−1 = none yet)
sensorsValues of the enabled sensors incl. unit; keys of failed sensors are listed in _failed. free: "true" = parking space available.
sensor_statusactive, disabled (failed) or off per sensor
ioOnly present when at least one channel is enabled
lastCommandTopic / …PayloadLast MQTT command received

GET /statush

Compact door state straight from the bus handler: valid ("true" if the last bus request is younger than 2 s), targetPosition, currentPosition, light, state (text) and busResponseAge.

GET /command

actionEffect
0Close
1Open
2Stop (only while moving)
3Ventilation position
4Half-open position
5Toggle light
6Restart the bridge
7Drive to position (0–100; ≤ 5 closes, ≥ 95 opens)
8Toggle: open if not fully open, otherwise close
curl "http://192.168.1.42/command?action=1"
curl "http://192.168.1.42/command?action=7&position=40"
curl -u admin:secret "http://192.168.1.42/command?action=5"   # with web password

Returns OK (text/plain).

GET /io

Parameters output (1 or 2) and state (on/1/true, off, toggle). Returns 200 OK, 400 when a parameter is missing and 404 when the output is not enabled.

curl "http://192.168.1.42/io?output=1&state=toggle"

GET / POST /config

GET returns all settings as JSON (keys as in the configuration reference); passwords are returned as "*" when set.

POST with Content-Type: application/json saves settings and restarts the bridge. It behaves like the web forms:

curl -X POST -H "Content-Type: application/json" \
  -d '{"sen_StInterval":"30","sen_sr04_en":"on","sen_sr04trigpin":"5","sen_sr04echopin":"27"}' \
  http://192.168.1.42/config
The example saves the whole sensor group: every sensor not listed as "on" is disabled and missing numeric fields keep their values. Read the configuration first and send the complete group.

GET /sysinfo

{
  "freemem": 187432, "hostname": "HCPBRIDGE", "ip": "192.168.1.42",
  "wifistatus": 3, "rssi": -61, "mqttstatus": true, "restart_reason": 1,
  "swversion": "1.1.0", "buildenv": "HCP_Giffordv3",
  "sensors": { "BME280": "active", "DS18X20": "off", "DHT22": "off", "HC-SR04": "off", "HC-SR501": "off", "MQ4": "off" },
  "io": { "in1": "active", "in2": "off", "out1": "off", "out2": "off" }
}

wifistatus 3 = connected; rssi is 0 when not connected.

GET /events (server-sent events)

The web interface subscribes to /events for instant updates:

EventData
sensorOne changed value incl. unit, e.g. {"temp":"21.6 °C"} or {"motion":"true"}
ioFull I/O state, e.g. {"in1":"true","out1":"false"}
curl -N http://192.168.1.42/events