Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tamshow channel value via http
• For any OpenBeken device you can read the present value of a channel with a single HTTP GET request:
http://<device_ip>/cm?cmnd=Ch<idx>
→ returns the raw value as plain text.
• If you prefer a named command (added in recent builds) use:
http://<device_ip>/cm?cmnd=GetChannel <idx>
→ same result, but keeps the index in the reply.
• To obtain every channel at once (JSON) call:
http://<device_ip>/cm?cmnd=json
or …cm?cmnd=getState
.
Key points
– Replace <device_ip>
with the actual IP of your module and <idx>
with the numerical channel index (1-64).
– The request is idempotent, needs no body, works from any browser, curl, wget, Node-RED, etc.
– Returned type: plain integer/float for Ch<n>
; structured JSON for json
/ getState
.
Channel concept
• A “channel” in OpenBeken is a general-purpose variable that can hold a relay state, PWM level, sensor reading or any script value.
• Indices start at 1; assignment is visible in the WebUI “Pins/Channels” page or with the CLI command channels
.
HTTP command interface
• OpenBeken inherits the classic Tasmota-style /cm?cmnd=<command>
endpoint.
• The parser tokenises the remainder of the URI exactly as you would type it in the serial console.
• Space between command and parameter must be URL-encoded (%20
) unless you already separate parameters with +
:
…cm?cmnd=GetChannel%201
or …cm?cmnd=GetChannel+1
.
Command variants and typical replies Command |
Reply type | Example reply |
---|---|---|
Ch1 |
text | 0 or 1 or 53.7 |
GetChannel 1 |
text | 1 |
json |
JSON object | {"1":1,"2":0,"8":75,"24":22.5} |
getState |
JSON | see below |
AllChannels (build ≥1.17.x) |
CSV | 1,0,75,22.5 |
Example getState
reply:
{
"DeviceName":"GarageDoor",
"Uptime":"0T01:22:18",
"WiFi_RSSI":-62,
"Channels":{"1":0,"2":1,"8":75,"24":22.5}
}
Performance notes
• Ch<n>
is fastest (few bytes).
• json
is preferable when you need many values in one round-trip.
• For real-time automation use MQTT or WebSockets; HTTP polling every second is acceptable for dashboards but not for millisecond-level control.
– Firmware 1.17.x (February 2024) introduced the more explicit GetChannel
, SetChannel
, /api/channels
and server-sent-events endpoint /events
for streaming changes.
– A permissive CORS header can be enabled (addEventHandler http_pre_response cors_handler
) so modern SPAs can fetch JSON directly from the device.
– Upcoming roadmap (community PR #615) will unify REST paths to /api/v1/channels/<idx>
and add bearer-token auth.
Example curl usage:
# Read channel 2
curl -s "http://192.168.0.41/cm?cmnd=Ch2"
# Same with named command
curl -s "http://192.168.0.41/cm?cmnd=GetChannel%202"
# Read all as JSON and pretty-print with jq
curl -s "http://192.168.0.41/cm?cmnd=json" | jq .
Alias shortcut in autoexec.bat if you need human-readable webpage:
alias mydash "return <h1>Temp:$CH24 °C Hum:$CH25 %</h1>"
addEventHandler http_get "/status" mydash
– If the endpoint is exposed outside your LAN, enable HTTP auth (setWebAuth admin strongPwd
) or migrate to HTTPS reverse-proxy.
– Comply with GDPR/CCPA when publishing sensor data that could identify occupants (e.g., presence, energy use).
openbeken.local
) or a network scanner. – Older images (<1.16) do not understand GetChannel
; stick to Ch<n>
.
– When a channel is not initialised the reply may be empty; initialise by SetChannel <idx> 0
.
• Examine the new /api/v1/
endpoints once merged.
• Benchmark SSE stream vs MQTT throughput for high-frequency sensor boards.
• Contribute to documentation at github.com/openshwprojects/OpenBK7231T_App_Doc.
A channel value can be queried over HTTP with one line:
http://<device_ip>/cm?cmnd=Ch<idx>
(legacy) or …cm?cmnd=GetChannel <idx>
(new).
For structured data use cm?cmnd=json
.
Secure the web server, prefer MQTT for push updates, and keep firmware current to gain the richer REST API now under development.