Skip to content

Commit 3ac437f

Browse files
committed
command
1 parent f07030c commit 3ac437f

File tree

1 file changed

+68
-44
lines changed

1 file changed

+68
-44
lines changed

src/views/GeneralConfig.vue

+68-44
Original file line numberDiff line numberDiff line change
@@ -128,53 +128,71 @@
128128
$store.state.mqtt['openWB/general/http_api']
129129
"
130130
@update:model-value="
131-
updateState('openWB/general/http_api', $event)
131+
sendSystemCommand('httpApi', {'active': $event})
132132
"
133133
>
134134
<template #help>
135-
Mit der HTTP-API kann man den Wert eines MQTT-Topics
136-
per HTTP GET oder POST abfragen. Ein Zugriff ist nur
137-
lesend möglich, nicht schreibend.<br />
138-
GET-Request:
139-
<a
140-
:href="`http://${getIpAddress()}:8080/?topic=openWB/system/time`"
141-
target="_blank"
142-
rel="noopener noreferrer"
143-
>
144-
http://{{
145-
getIpAddress()
146-
}}:8080/?topic=openWB/system/time </a
147-
><br />
148-
Verschlüsselter GET-Request:
149-
<a
150-
:href="`https://${getIpAddress()}:8443/?topic=openWB/system/time`"
151-
target="_blank"
152-
rel="noopener noreferrer"
153-
>
154-
https://{{
155-
getIpAddress()
156-
}}:8443/?topic=openWB/system/time
157-
</a>
158-
<br />
159-
POST-Request mit curl:
160-
<openwb-base-copy-to-clipboard
161-
class="text-info"
162-
tooltip="Topic kopieren"
163-
>curl -X POST --data "topic=openWB/system/time"
164-
http://{{
165-
getIpAddress()
166-
}}:8080/</openwb-base-copy-to-clipboard
167-
>
168-
Verschlüsselter POST-Request über curl mit privatem
169-
SSL-Zertifikat:
170-
<openwb-base-copy-to-clipboard
171-
class="text-info"
172-
tooltip="Topic kopieren"
173-
>curl -k -X POST --data
174-
"topic=openWB/system/time" https://{{
175-
getIpAddress()
176-
}}:8080/</openwb-base-copy-to-clipboard
177-
><br />
135+
<p>
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.
141+
</p>
142+
<p>
143+
Beispiel: Abfrage des aktuellen
144+
Systemzeitstempels
145+
</p>
146+
<ul>
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"
153+
>
154+
https://{{
155+
getIpAddress()
156+
}}:8443/?topic=openWB/system/time
157+
</a>
158+
</li>
159+
<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"
166+
>
167+
http://{{
168+
getIpAddress()
169+
}}:8080/?topic=openWB/system/time
170+
</a>
171+
</li>
172+
</ul>
173+
<p>
174+
Die zurückgegebenen Daten sind im JSON-Format.
175+
Der Inhalt ist nach folgendem Schema aufgebaut:
176+
</p>
177+
<pre>
178+
{
179+
"topic": "openWB/system/time",
180+
"value": 1721287000.646975,
181+
"status": "success"
182+
}
183+
</pre>
184+
<p>
185+
Im Fehlerfall wird der Status auf "error"
186+
gesetzt und eine Fehlermeldung zurückgegeben.
187+
</p>
188+
<pre>
189+
{
190+
"topic": "openWB/unbekanntes/topic",
191+
"value": null,
192+
"status": "error",
193+
"error": "Topic not found"
194+
}
195+
</pre>
178196
</template>
179197
</openwb-base-button-group-input>
180198
</div>
@@ -778,6 +796,12 @@ export default {
778796
this.getRippleControlReceiverDefaultConfiguration($event),
779797
);
780798
},
799+
sendSystemCommand(command, data = {}) {
800+
this.$emit("sendCommand", {
801+
command: command,
802+
data: data,
803+
});
804+
},
781805
},
782806
};
783807
</script>

0 commit comments

Comments
 (0)