How to get HTTP module events

We are working on an Ezlo plugin, and are making an http request via the http module’s http.request() call. This is an asynchronous call we are making in the plugin to an external server, and we need to get the result of the request. The HTTP Module documentation talks about HTTP Module Events, and it looks like the http_connection_closed event gives us the info we need.

But the standard subscribe method doesn’t appear to work for the HTTP module. The call http.subscribe() generates the error:
Couldn’t run a Lua code: [string “HUB:our_plugin/scripts/startup”]:42: attempt to index a nil value (global ‘http’).

Has anyone gotten this to work? Anyone know how to get the http_connection_closed event?

Hi rich,

Maybe this helps https://github.com/reneboer/ezlo-SolarMeter

In the drivers folder you find the scripts per device type. The poll.lua sends the http.request. The update_http.lua receives the results.

Cheers Rene

1 Like

Thank you! That was quite helpful!

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules