|
128 | 128 | $store.state.mqtt['openWB/general/http_api']
|
129 | 129 | "
|
130 | 130 | @update:model-value="
|
131 |
| - sendSystemCommand('httpApi', {'active': $event}) |
| 131 | + sendSystemCommand('httpApi', { active: $event }) |
132 | 132 | "
|
133 | 133 | >
|
134 | 134 | <template #help>
|
135 | 135 | <p>
|
136 | 136 | Mit der HTTP-API kann man den Wert eines
|
137 |
| - MQTT-Topics per HTTPs (Port 8443) oder optional |
138 |
| - auch HTTP (Port 8090) abfragen. Ein Zugriff ist |
139 |
| - nur lesend möglich, nicht schreibend. Es wird |
140 |
| - empfohlen, nur HTTPs zu aktivieren. |
| 137 | + MQTT-Topics per HTTPs (Port 8443) abfragen oder |
| 138 | + neu setzen. Topics können über GET oder POST |
| 139 | + abgefragt, neue Werte nur mit POST gesetzt |
| 140 | + werden. |
141 | 141 | </p>
|
142 | 142 | <p>
|
143 |
| - Beispiel: Abfrage des aktuellen |
| 143 | + Beispiel 1: Abfrage des aktuellen |
144 | 144 | Systemzeitstempels
|
145 | 145 | </p>
|
146 | 146 | <ul>
|
147 | 147 | <li>
|
148 |
| - Verschlüsselter GET-Request: |
149 |
| - <a |
150 |
| - :href="`https://${getIpAddress()}:8443/?topic=openWB/system/time`" |
151 |
| - target="_blank" |
152 |
| - rel="noopener noreferrer" |
| 148 | + GET-Request:<br /> |
| 149 | + <openwb-base-copy-to-clipboard |
| 150 | + class="text-info" |
| 151 | + tooltip="URL kopieren" |
153 | 152 | >
|
154 | 153 | https://{{
|
155 | 154 | getIpAddress()
|
156 |
| - }}:8443/?topic=openWB/system/time |
157 |
| - </a> |
| 155 | + }}:8443/v1/?topic=openWB/system/time |
| 156 | + </openwb-base-copy-to-clipboard> |
158 | 157 | </li>
|
159 | 158 | <li>
|
160 |
| - GET-Request (falls unverschlüsseltes HTTP |
161 |
| - aktiviert wurde): |
162 |
| - <a |
163 |
| - :href="`http://${getIpAddress()}:8080/?topic=openWB/system/time`" |
164 |
| - target="_blank" |
165 |
| - rel="noopener noreferrer" |
| 159 | + POST-Request über 'curl' mit privatem |
| 160 | + SSL-Zertifikat und Verarbeitung durch |
| 161 | + 'jq':<br /> |
| 162 | + <openwb-base-copy-to-clipboard |
| 163 | + class="text-info" |
| 164 | + tooltip="Befehl kopieren" |
166 | 165 | >
|
167 |
| - http://{{ |
168 |
| - getIpAddress() |
169 |
| - }}:8080/?topic=openWB/system/time |
170 |
| - </a> |
| 166 | + curl -k -s -X POST --data |
| 167 | + '{"topic":"openWB/system/time"}' |
| 168 | + https://{{ getIpAddress() }}:8443/v1/ | |
| 169 | + jq . |
| 170 | + </openwb-base-copy-to-clipboard> |
171 | 171 | </li>
|
172 | 172 | </ul>
|
173 | 173 | <p>
|
174 | 174 | Die zurückgegebenen Daten sind im JSON-Format.
|
175 | 175 | Der Inhalt ist nach folgendem Schema aufgebaut:
|
176 | 176 | </p>
|
177 |
| - <pre> |
178 |
| -{ |
179 |
| - "topic": "openWB/system/time", |
180 |
| - "value": 1721287000.646975, |
181 |
| - "status": "success" |
182 |
| -} |
183 |
| - </pre> |
| 177 | + <pre class="border border-info w-100 p-1">{{ |
| 178 | + JSON.stringify( |
| 179 | + { |
| 180 | + status: "success", |
| 181 | + topic: "openWB/system/time", |
| 182 | + message: 1721287000.646975, |
| 183 | + }, |
| 184 | + null, |
| 185 | + 4, |
| 186 | + ) |
| 187 | + }}</pre> |
184 | 188 | <p>
|
185 |
| - Im Fehlerfall wird der Status auf "error" |
| 189 | + Im Fehlerfall wird der Status auf "failed" |
186 | 190 | gesetzt und eine Fehlermeldung zurückgegeben.
|
187 | 191 | </p>
|
188 |
| - <pre> |
189 |
| -{ |
190 |
| - "topic": "openWB/unbekanntes/topic", |
191 |
| - "value": null, |
192 |
| - "status": "error", |
193 |
| - "error": "Topic not found" |
194 |
| -} |
195 |
| - </pre> |
| 192 | + <p>Beispiel 2: integriertes Display abschalten</p> |
| 193 | + <ul> |
| 194 | + <li> |
| 195 | + POST-Request über 'curl' mit privatem |
| 196 | + SSL-Zertifikat und Verarbeitung durch |
| 197 | + 'jq':<br /> |
| 198 | + <openwb-base-copy-to-clipboard |
| 199 | + class="text-info" |
| 200 | + tooltip="Befehl kopieren" |
| 201 | + > |
| 202 | + curl -k -s -X POST --data '{"topic": |
| 203 | + "openWB/set/optional/int_display/active", |
| 204 | + "message": false}' https://{{ |
| 205 | + getIpAddress() |
| 206 | + }}:8443/v1/ | jq . |
| 207 | + </openwb-base-copy-to-clipboard> |
| 208 | + </li> |
| 209 | + </ul> |
| 210 | + <p> |
| 211 | + Die zurückgegebenen Daten sind im JSON-Format. |
| 212 | + Der Inhalt ist nach folgendem Schema aufgebaut: |
| 213 | + </p> |
| 214 | + <pre class="border border-info w-100 p-1">{{ |
| 215 | + JSON.stringify( |
| 216 | + { |
| 217 | + status: "success", |
| 218 | + topic: "openWB/set/optional/int_display/active", |
| 219 | + message: false, |
| 220 | + }, |
| 221 | + null, |
| 222 | + 4, |
| 223 | + ) |
| 224 | + }}</pre> |
196 | 225 | </template>
|
197 | 226 | </openwb-base-button-group-input>
|
198 | 227 | </div>
|
|
0 commit comments