There are several plugins here showing how to work with HTTP Lua module on Ezlo Plus and Ezlo Secure hubs.
All sources of the plugins have comments in the code.
In the first example, calling the script http_test/scripts/http_request results in the generation of a GET HTTP request with parameters to the postman-echo.com HTTP echo service, which generates a response with the same HTTP headers and parameters as the GET HTTP request. The plugin accepts this response and prints it to the console.
The second example is an advanced version of the first plugin and allows you to make a request to yahoo finance portal and get information about favorite stocks.
To run it on your Ezlo Plus or Ezlo Secure you need:
- unzip and copy the content of the archive into a
/home/data/custom_plugins/
directory - run
/opt/firmware/bin/ha-infocmd hub.extensions.custom_plugin.register http_test
to register the plugin - execute a
hub.extensions.plugin.run
request with ascript
parameter set to aHUB:http_test/scripts/http_request
- to see plugin results you may look at logs
/var/log/firmware/ha-luad.log
Sources of the plugins with comments in the code:
http_example_postman.zip (1.7 KB)
http_example_finance.zip (1.9 KB)