Repository navigation
Expand file tree
/
Copy pathapi.html
More file actions
223 lines (215 loc) · 17.2 KB
/
Copy pathapi.html
File metadata and controls
223 lines (215 loc) · 17.2 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<!doctype html>
<html lang="en" data-page="api">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>REST API - Open Firenet</title>
<meta name="description" content="Overview of the local REST API of the Open Firenet bridge: read the stove state and send controls with plain HTTP and JSON.">
<link rel="alternate" hreflang="en" href="https://openfirenet.github.io/api.html">
<link rel="alternate" hreflang="fr" href="https://openfirenet.github.io/fr/api.html">
<link rel="alternate" hreflang="de" href="https://openfirenet.github.io/de/api.html">
<link rel="alternate" hreflang="it" href="https://openfirenet.github.io/it/api.html">
<link rel="alternate" hreflang="es" href="https://openfirenet.github.io/es/api.html">
<link rel="alternate" hreflang="x-default" href="https://openfirenet.github.io/api.html">
<script>
// Language: a visitor arriving from outside the site gets the language they chose before, or else the first language of
// their browser that the site is written in. On the home page, a first visit shows the animated logo meanwhile.
(function () {
var html = document.documentElement, here = html.lang, stored = null, target = null, chosen = null;
try { stored = localStorage.getItem('site-lang'); } catch (e) {}
var handoff = false;
try { handoff = sessionStorage.getItem('site-splash') === '1'; sessionStorage.removeItem('site-splash'); } catch (e) {}
var inside = document.referrer.indexOf(location.origin + '/') === 0;
function alt(code) {
var l = document.querySelector('link[rel="alternate"][hreflang="' + code + '"]');
return l ? new URL(l.href).pathname : null; // same site, whatever host serves it
}
if (!inside) {
var wanted = stored ? [stored] : (navigator.languages || [navigator.language || '']);
for (var i = 0; i < wanted.length; i++) {
var code = String(wanted[i]).slice(0, 2).toLowerCase();
if (code === here) { chosen = here; break; }
if (alt(code)) { chosen = code; target = alt(code); break; }
}
}
var still = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
var splash = !still && html.getAttribute('data-page') === 'index' && (handoff || (!stored && !inside));
if (chosen && !stored) { try { localStorage.setItem('site-lang', chosen); } catch (e) {} }
if (!splash) { if (target) location.replace(target); return; }
// How long the logo shows, then fades; one colour wave crosses it in that time, whatever the durations.
var SHOW = 900, FADE = 400;
html.style.setProperty('--splash-fade', FADE + 'ms');
html.style.setProperty('--splash-wave', (SHOW + FADE) + 'ms');
html.classList.add('splash');
if (handoff) html.classList.add('splash-handoff');
// The logo shows briefly, then fades out on this page, or goes on to the page in the right language, which fades it out.
setTimeout(function () {
if (target) {
try { sessionStorage.setItem('site-splash', '1'); } catch (e) {}
location.replace(target);
return;
}
html.classList.add('splash-out');
setTimeout(function () { html.classList.remove('splash', 'splash-out', 'splash-handoff'); }, FADE);
}, handoff ? 100 : SHOW);
})();
</script>
<link rel="icon" href="assets/img/brand-icon.png">
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<div class="splash-screen" aria-hidden="true"><div class="splash-logo"><span class="splash-emblem"></span><span class="splash-words"><span class="splash-open">Open</span><span class="splash-fire">Firenet</span></span></div></div>
<header class="site-header">
<div class="inner">
<a class="brand" href="index.html"><img src="assets/img/brand-icon.png" alt="">Open Firenet</a>
<button class="nav-toggle" type="button" aria-expanded="false" aria-controls="site-nav">☰ Menu</button>
<nav class="nav" id="site-nav" aria-label="Main">
<a href="how-it-works.html">How it works</a>
<a href="download.html">Download</a>
<a href="get-started.html">Get started</a>
<details class="nav-group">
<summary>Stove & board</summary>
<div class="nav-menu">
<a href="compatibility.html">Stove compatibility</a>
<a href="hardware.html">Hardware</a>
<a href="screen.html">Stick screen</a>
</div>
</details>
<details class="nav-group active">
<summary>Integrations</summary>
<div class="nav-menu">
<a href="home-assistant.html">Home Assistant</a>
<a href="mqtt.html">MQTT</a>
<a href="api.html" class="active" aria-current="page">REST API</a>
</div>
</details>
<a href="troubleshooting.html">Troubleshooting</a>
<details class="nav-group nav-lang">
<summary aria-label="Language"><svg class="flag" viewBox="0 0 3 2" preserveAspectRatio="none" aria-hidden="true"><rect width="3" height="2" fill="#012169"/><path d="M0 0L3 2M3 0L0 2" stroke="#fff" stroke-width="0.4"/><path d="M0 0L3 2M3 0L0 2" stroke="#c8102e" stroke-width="0.14"/><path d="M1.5 0V2M0 1H3" stroke="#fff" stroke-width="0.66"/><path d="M1.5 0V2M0 1H3" stroke="#c8102e" stroke-width="0.4"/></svg>English</summary>
<div class="nav-menu">
<a href="api.html" hreflang="en" lang="en" data-lang="en" class="active" aria-current="page"><svg class="flag" viewBox="0 0 3 2" preserveAspectRatio="none" aria-hidden="true"><rect width="3" height="2" fill="#012169"/><path d="M0 0L3 2M3 0L0 2" stroke="#fff" stroke-width="0.4"/><path d="M0 0L3 2M3 0L0 2" stroke="#c8102e" stroke-width="0.14"/><path d="M1.5 0V2M0 1H3" stroke="#fff" stroke-width="0.66"/><path d="M1.5 0V2M0 1H3" stroke="#c8102e" stroke-width="0.4"/></svg>English</a>
<a href="fr/api.html" hreflang="fr" lang="fr" data-lang="fr"><svg class="flag" viewBox="0 0 3 2" preserveAspectRatio="none" aria-hidden="true"><rect width="1" height="2" fill="#0055a4"/><rect x="1" width="1" height="2" fill="#fff"/><rect x="2" width="1" height="2" fill="#ef4135"/></svg>Français</a>
<a href="de/api.html" hreflang="de" lang="de" data-lang="de"><svg class="flag" viewBox="0 0 3 2" preserveAspectRatio="none" aria-hidden="true"><rect width="3" height="0.67" fill="#000"/><rect y="0.67" width="3" height="0.67" fill="#dd0000"/><rect y="1.33" width="3" height="0.67" fill="#ffce00"/></svg>Deutsch</a>
<a href="it/api.html" hreflang="it" lang="it" data-lang="it"><svg class="flag" viewBox="0 0 3 2" preserveAspectRatio="none" aria-hidden="true"><rect width="1" height="2" fill="#009246"/><rect x="1" width="1" height="2" fill="#fff"/><rect x="2" width="1" height="2" fill="#ce2b37"/></svg>Italiano</a>
<a href="es/api.html" hreflang="es" lang="es" data-lang="es"><svg class="flag" viewBox="0 0 3 2" preserveAspectRatio="none" aria-hidden="true"><rect width="3" height="2" fill="#c60b1e"/><rect y="0.5" width="3" height="1" fill="#ffc400"/></svg>Español</a>
</div>
</details>
</nav>
</div>
</header>
<main>
<h1>REST API</h1>
<p class="lead">The bridge serves a JSON API on your network, with natural units: temperatures in °C, power in percent, readable mode names. No key, no account.</p>
<div class="actions" style="margin:18px 0">
<a class="btn" href="api-reference.html">Full API reference</a>
<a class="btn ghost" href="openapi.yaml">OpenAPI file</a>
</div>
<h2>Endpoints</h2>
<p>Click an endpoint or a method for its details in the <a href="api-reference.html">API reference</a>.</p>
<div class="table-wrap">
<table>
<tr><th>Endpoint</th><th>Method</th><th>Purpose</th></tr>
<tr><td><a href="api-reference.html#get-api-state"><code>/api/state</code></a></td><td><a href="api-reference.html#get-api-state"><span class="method get">GET</span></a></td><td>Everything at once: bridge, stove, sensors, controls, link diagnostics</td></tr>
<tr><td><a href="api-reference.html#get-api-controls"><code>/api/controls</code></a></td><td><a href="api-reference.html#get-api-controls"><span class="method get">GET</span></a> <a href="api-reference.html#post-api-controls"><span class="method post">POST</span></a></td><td>Read or change the settings (partial updates accepted)</td></tr>
<tr><td><a href="api-reference.html#get-api-schedule"><code>/api/schedule</code></a></td><td><a href="api-reference.html#get-api-schedule"><span class="method get">GET</span></a> <a href="api-reference.html#post-api-schedule"><span class="method post">POST</span></a></td><td>Weekly heating schedule: 14 time slots and the setback temperature</td></tr>
<tr><td><a href="api-reference.html#get-api-version"><code>/api/version</code></a></td><td><a href="api-reference.html#get-api-version"><span class="method get">GET</span></a></td><td>Firmware version and build date</td></tr>
<tr><td><a href="api-reference.html#get-api-mqtt"><code>/api/mqtt</code></a></td><td><a href="api-reference.html#get-api-mqtt"><span class="method get">GET</span></a> <a href="api-reference.html#post-api-mqtt"><span class="method post">POST</span></a></td><td>MQTT settings and connection status, see <a href="mqtt.html">MQTT</a></td></tr>
<tr><td><a href="api-reference.html#get-api-txgap"><code>/api/txgap</code></a></td><td><a href="api-reference.html#get-api-txgap"><span class="method get">GET</span></a> <a href="api-reference.html#post-api-txgap"><span class="method post">POST</span></a></td><td>Delay between messages sent to the stove (50 to 600 ms, default 150)</td></tr>
<tr><td><a href="api-reference.html#post-api-restart"><code>/api/restart</code></a></td><td><a href="api-reference.html#post-api-restart"><span class="method post">POST</span></a></td><td>Restart the bridge</td></tr>
<tr><td><a href="api-reference.html#post-api-forget"><code>/api/forget</code></a></td><td><a href="api-reference.html#post-api-forget"><span class="method post">POST</span></a></td><td>Erase the Wi-Fi settings and go back to setup mode</td></tr>
<tr><td><a href="api-reference.html#get-log"><code>/log</code></a></td><td><a href="api-reference.html#get-log"><span class="method get">GET</span></a></td><td>Plain-text log of the dialogue with the stove</td></tr>
</table>
</div>
<h2>Who can call it</h2>
<p>Programs on your network: Home Assistant, scripts, <code>curl</code>, Node-RED. And the bridge's own web page. Since firmware 4.0, a page of another website opened in a browser cannot: the bridge answers 403 to a request that names another page as its origin, and sends no cross-origin permission.</p>
<p>The bridge answers at its IP address, at a name without a dot and at <code>open-firenet.local</code>. Another name must first be added in the Bridge tab, Network, section "Access to the page" (or with <code>/api/access</code>); until then the bridge answers 403 with a JSON body that gives its IP address.</p>
<h2>Read the state</h2>
<pre><code>curl http://open-firenet.local/api/state</code></pre>
<p>The answer is grouped by topic. The parts you will use most:</p>
<div class="table-wrap">
<table>
<tr><th>Field</th><th>Meaning</th></tr>
<tr><td><code>stove.state</code>, <code>stove.model_name</code>, <code>stove.mainboard_version</code></td><td>Operating state, model and firmware version of the stove</td></tr>
<tr><td><code>stove.error_code</code>, <code>stove.warning_code</code></td><td>Current error and warning, 0 when there is none</td></tr>
<tr><td><code>sensors.room_temperature</code></td><td>Room temperature, <code>null</code> when no RIKA room sensor is connected</td></tr>
<tr><td><code>sensors.pellets_total_kg</code>, <code>sensors.service_countdown_kg</code></td><td>Pellets burned in total, and what is left before the next service</td></tr>
<tr><td><code>controls.on</code>, <code>controls.mode</code>, <code>controls.target_temperature</code>, <code>controls.power_percent</code></td><td>The current settings</td></tr>
<tr><td><code>version_ack</code>, <code>version_frame</code></td><td>Whether the stove accepted the bridge, and which protocol variant it answered: <code>V3</code> (firmware 2.29), <code>V28</code> (2.28), <code>V1</code> (2.26 / 2.27); <code>?</code> for a stove on firmware 2.25, which speaks numeric frames</td></tr>
<tr><td><code>usb.host_connected</code>, <code>usb.rx_bytes</code></td><td>Whether the stove sees the bridge over USB, and how many bytes it has sent</td></tr>
<tr><td><code>raw_sensors</code></td><td>Every value the stove reports, under its RIKA name</td></tr>
</table>
</div>
<h2>Send controls</h2>
<p>Post a JSON object with only the fields you want to change:</p>
<pre><code># 21 °C in comfort mode
curl -X POST http://open-firenet.local/api/controls \
-H "Content-Type: application/json" \
-d '{"target_temperature": 21, "mode": "comfort"}'
# switch on at 80 % power
curl -X POST http://open-firenet.local/api/controls \
-H "Content-Type: application/json" \
-d '{"on": true, "power_percent": 80}'</code></pre>
<div class="table-wrap">
<table>
<tr><th>Field</th><th>Values</th></tr>
<tr><td><code>on</code></td><td><code>true</code> / <code>false</code></td></tr>
<tr><td><code>mode</code></td><td><code>"manual"</code>, <code>"auto"</code>, <code>"comfort"</code></td></tr>
<tr><td><code>power_percent</code></td><td>30 to 100</td></tr>
<tr><td><code>target_temperature</code></td><td>14 to 28 °C, in whole degrees (a half degree is rounded)</td></tr>
<tr><td><code>frost_protection_active</code>, <code>frost_protection_temperature</code></td><td><code>true</code> / <code>false</code>, 4 to 10 °C</td></tr>
<tr><td><code>room_temperature_offset</code></td><td>-4.0 to +4.0 °C</td></tr>
<tr><td><code>convectionFan1Active</code>, <code>convectionFan1Level</code>, <code>convectionFan1Area</code> (and <code>Fan2</code>)</td><td>MultiAir: on/off, 0 = auto or 1 to 5, trim -30 to +30 %</td></tr>
</table>
</div>
<div class="note">
<p>Since firmware 4.0, commands are only accepted on POST and PUT, and a command sent before the stove has given its settings (the bridge is not linked, or has just started) is refused with <code>503</code> and <code>"error": "stove_not_ready"</code>. Nothing was sent to the stove: try again a few seconds later.</p>
</div>
<h2>Full reference</h2>
<p>Every endpoint and every field, with its type, unit and range, is in the <a href="api-reference.html">API reference</a>. It is generated from the <a href="openapi.yaml">OpenAPI description</a> of the firmware, which you can load into your own tools (documentation viewers, client generators).</p>
<p>The schedule format and the protocol notes are also in the firmware repository: <a href="https://github.com/openfirenet/open-firenet#rest-api-v2">README, REST API</a> and <a href="https://github.com/openfirenet/open-firenet/blob/main/PROTOCOL.md">PROTOCOL.md</a>.</p>
</main>
<footer class="site-footer">
<div class="inner">
<p>Open Firenet is an open-source project, not affiliated with or endorsed by RIKA Innovative Ofentechnik GmbH. The protocol was reverse-engineered for interoperability only. Use at your own risk, no warranty.</p>
<p><a href="https://github.com/openfirenet">GitHub</a> · <a href="contribute.html">Contribute</a> · Questions and problems: <a href="https://github.com/openfirenet/open-firenet/issues">bridge and firmware issues</a> · <a href="https://github.com/openfirenet/open-firenet-ha/issues">Home Assistant integration issues</a></p>
</div>
</footer>
<div class="lightbox" id="lightbox" hidden><img alt=""></div>
<script>
// Navigation menus: only one open at a time, closed by a click elsewhere or by Escape.
(function () {
var groups = document.querySelectorAll('.nav-group');
function closeAll(except) { groups.forEach(function (g) { if (g !== except) g.open = false; }); }
var phone = window.matchMedia('(max-width: 760px)');
groups.forEach(function (g) { g.addEventListener('toggle', function () { if (g.open && !phone.matches) closeAll(g); }); });
document.addEventListener('click', function (e) { if (!phone.matches && !e.target.closest('.nav-group')) closeAll(null); });
document.addEventListener('keydown', function (e) { if (e.key === 'Escape') closeAll(null); });
// On a phone the whole bar folds behind a Menu button.
var toggle = document.querySelector('.nav-toggle'), nav = document.getElementById('site-nav');
toggle.addEventListener('click', function () {
var open = nav.classList.toggle('open');
toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
groups.forEach(function (g) { g.open = open; }); // on a phone the groups are shown in full
});
})();
// Languages: a click on a language in the menu remembers it.
document.querySelectorAll('.nav-lang a[data-lang]').forEach(function (a) {
a.addEventListener('click', function () { try { localStorage.setItem('site-lang', a.getAttribute('data-lang')); } catch (e) {} });
});
// Screenshots open full size on click; click again or press Escape to close.
(function () {
var box = document.getElementById('lightbox'), big = box.querySelector('img');
function close() { box.hidden = true; big.removeAttribute('src'); }
document.querySelectorAll('img.shot').forEach(function (img) {
img.tabIndex = 0;
img.setAttribute('role', 'button');
function open() { big.src = img.currentSrc || img.src; big.alt = img.alt; box.hidden = false; }
img.addEventListener('click', open);
img.addEventListener('keydown', function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(); } });
});
box.addEventListener('click', close);
document.addEventListener('keydown', function (e) { if (e.key === 'Escape') close(); });
})();
</script>
</body>
</html>