access_from_lua_to_webhmi_itself
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
access_from_lua_to_webhmi_itself [2023/03/02 10:34] – created emozolyak | access_from_lua_to_webhmi_itself [2023/03/02 10:56] (current) – [Getting meter data example] emozolyak | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Access from WebHMI itself ====== | ====== Access from WebHMI itself ====== | ||
+ | |||
+ | To access the WebHMI DB data via API, you have to generate API key in the setup menu and use it in your requests. | ||
+ | You can use // | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ===== Getting meter data example ===== | ||
<code lua> | <code lua> | ||
- | function getMeterData(meterId, | + | function getMeterData(startTime, |
| | ||
local c = cURL.easy_init() | local c = cURL.easy_init() | ||
c : setopt{ url = ' | c : setopt{ url = ' | ||
timeout = 15, | timeout = 15, | ||
- | httpheader = {' | + | httpheader = { ' |
' | ' | ||
' | ' | ||
- | -- ' | + | |
- | -- ' | + | |
- | | + | |
' | ' | ||
' | ' | ||
Line 34: | Line 41: | ||
end | end | ||
</ | </ | ||
+ | |||
+ | ===== Getting graph data example | ||
+ | <code lua> | ||
+ | function getGraphData(regId, | ||
+ | | ||
+ | local c = cURL.easy_init() | ||
+ | c : setopt{ url = ' | ||
+ | timeout = 15, | ||
+ | | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | } | ||
+ | |||
+ | local res = "" | ||
+ | c: | ||
+ | res = res .. str | ||
+ | end} | ||
+ | c : close() | ||
+ | |||
+ | if (res == '' | ||
+ | ERROR(' | ||
+ | return false | ||
+ | else | ||
+ | return res | ||
+ | end | ||
+ | | ||
+ | end | ||
+ | </ | ||
+ | |||
access_from_lua_to_webhmi_itself.1677753296.txt.gz · Last modified: 2023/03/02 10:34 by emozolyak