From 81ad0217b339815e86394734bea20fa6055b015a Mon Sep 17 00:00:00 2001 From: mburakov Date: Mon, 1 Nov 2021 15:10:55 +0100 Subject: Add few curl samples to readme --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 28a5c3e..50b3314 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,63 @@ export HTTP_ADDR=0.0.0.0 During the start up, MQhTTp sources all the lua files in the current directory (if any). +## Usage + +You can use HTTP GET requests to browse through the topics known to your mosquitto server, and get their last received payloads, i.e.: +``` +# curl -v rock:8080/ +* Trying 192.168.8.6:8080... +* Connected to rock (192.168.8.6) port 8080 (#0) +> GET / HTTP/1.1 +> Host: rock:8080 +> User-Agent: curl/7.79.1 +> Accept: */* +> +* Mark bundle as not supporting multiuse +< HTTP/1.1 200 OK +< Content-Type: text/html +< Content-Length: 1770 +< +* Connection #0 to host rock left intact +MQhTTp/cmnd/bedroom/Color
/cmnd/torsh/Color
/stat/bedroom/RESULT
/stat/torsh/RESULT
/tasmota/discovery/3C71BF25D0EE/config
/tasmota/discovery/3C71BF25D0EE/sensors
/tasmota/discovery/68C63AEC65D0/config
/tasmota/discovery/68C63AEC65D0/sensors
/tele/bedroom/LWT
/tele/bedroom/STATE
/tele/torsh/LWT
/tele/torsh/STATE
/zigbee2mqtt/bridge/config
/zigbee2mqtt/bridge/devices
/zigbee2mqtt/bridge/extensions
/zigbee2mqtt/bridge/groups
/zigbee2mqtt/bridge/info
/zigbee2mqtt/bridge/log
/zigbee2mqtt/bridge/logging
/zigbee2mqtt/bridge/state
/zigbee2mqtt/kitchen
/zigbee2mqtt/kitchen/set
/zigbee2mqtt/lamps
/zigbee2mqtt/lamps/set
/zigbee2mqtt/leds
/zigbee2mqtt/leds/set
/zigbee2mqtt/switch
+``` +``` +# curl -v http://rock:8080/tele/torsh/STATE +* Trying 192.168.8.6:8080... +* Connected to rock (192.168.8.6) port 8080 (#0) +> GET /tele/torsh/STATE HTTP/1.1 +> Host: rock:8080 +> User-Agent: curl/7.79.1 +> Accept: */* +> +* Mark bundle as not supporting multiuse +< HTTP/1.1 200 OK +< Content-Type: application/json +< Content-Length: 435 +< +* Connection #0 to host rock left intact +{"Time":"2021-11-01T15:07:51","Uptime":"28T17:32:14","UptimeSec":2482334,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":8,"POWER":"OFF","Dimmer":0,"Color":"0,0,0,0","HSBColor":"0,0,0","White":0,"Channel":[0,0,0,0],"Scheme":0,"Fade":"OFF","Speed":1,"LedTable":"ON","Wifi":{"AP":1,"SSId":"UPCB84945E","BSSId":"C4:AD:34:7D:9C:73","Channel":3,"Mode":"11n","RSSI":70,"Signal":-65,"LinkCount":1,"Downtime":"0T00:00:03"}} +``` + +MQhTTp would publish to mosquitto anything that arrives as an HTTP POST request using URL as a topic (omitting leading slash) and request body as a payload, i.e.: +``` +# curl -d '#00000000' -v rock:8080/cmnd/torsh/Color +* Trying 192.168.8.6:8080... +* Connected to rock (192.168.8.6) port 8080 (#0) +> POST /cmnd/torsh/Color HTTP/1.1 +> Host: rock:8080 +> User-Agent: curl/7.79.1 +> Accept: */* +> Content-Length: 9 +> Content-Type: application/x-www-form-urlencoded +> +* Mark bundle as not supporting multiuse +< HTTP/1.1 200 OK +< Content-Length: 0 +< +* Connection #0 to host rock left intact +``` + ## Bugs Yes. -- cgit v1.2.3