Skip to content

Various

Name Input Params Return Data Description
resiot_sleep Integer Empty Sleep for N Milliseconds
resiot_runscene String, ... Boolean, String Start another Scene alongside this one
resiot_runscenewithcallback String, String, String, ... String, String Starts another Scene with an input parameter and waits for it to return a value
resiot_setreturnvalue String String If you're running a scene from api or via other methods, you might want your scene to return a value, this is how you set it
resiot_time Integer Integer, Integer, Integer, Integer, Integer, Integer Get the actual date of your organization
resiot_timeutc Integer Integer, Integer, Integer, Integer, Integer, Integer Get the actual date of UTC
resiot_timefromunix Integer, Integer Integer, Integer, Integer, Integer, Integer, Integer Get the date of your organization from a Unix time
resiot_weeknumber Integer Integer Get the week number of the year of your organization from a Unix time
resiot_strtime Integer String Get the date of your organization in string format from a Unix time
resiot_strtimewoffset Integer String Get the date and offset of your organization in string format from a Unix time
resiot_timetounix String, String Integer, String Get the Unix time from a date string
resiot_raiseevent String, String, String String Trigger the input Event of a Node
resiot_regex String, String, Integer String Check if the string val respect the regex pattern
resiot_subregex String, String, Integer, Integer String Check if the string val respect the regex pattern
resiot_getsunrise String, String Integer Get the time of sunrise, in minutes, of a node
resiot_getsunset String, String Integer Get the time of sunset, in minutes, of a node
resiot_dayoftheweek Integer String Get the day of the week of a date
resiot_curl String String, String Send a HTTP request via web server APIs
resiot_getram String, String Get the used percentage of RAM used by the system
resiot_getcpu String, String Get the used percentage of CPU used by the system
resiot_certvalidity Integer, String Get the number of hours of validity of your webserver SSL certificate
resiot_distance Float, Float, Float, Float Float Calculates the great-circle distance in meters between two gps coordinates
resiot_urldecode String String Decode an URL encoded string into readable string
resiot_urlencode String String Encode a string into an URL encoded string
resiot_getlanguage String, String Get the language in ISO and extended format of the user who executes the scene
resiot_getlanguagefromuser String String, String Get the language in ISO and extended format of the user with the given email
resiot_gethtml_widget String, Integer, String, String, String, Bool, String, String, String, String, Integer, Integer, Integer String, String Get the HTML code to show a widget based on a Node Field
resiot_gethtml_linearwidget String, String, String, String, Bool, String, String, String, String, Integer, Integer, Integer String, String Get the HTML code to show a linear widget based on a Node Field

resiot_sleep(Integer)

Sleep for N Milliseconds.
Example
resiot_sleep(Milliseconds)
Input Parameters
 - Milliseconds (Integer): * The time in milliseconds.
Returns
 - * The function doesn't have nothing to return.

Milliseconds = 1000         -- The time in milliseconds
resiot_sleep(Milliseconds)
-- 
-- In This case:
-- 
-- The scene sleep for 1000 milliseconds, or 1 second
-- 

Return to index


resiot_runscene(String, ...)

Start another Scene alongside this one. The Scene is identified by his Hexadecimal ID and the parameters that are needed are written next to the ID
Example
AllWorked, Error = resiot_runscene(HexID)
Input Parameters
 - HexID (String): * The Hexadecimal ID that identify the scene.
 - Parameters (String/Integer/Float): * If the scene that need some parameters to run, then thery are insert here, each separated by a comma.

Returns
 - AllWorked (Bool): * "true" if the scene started successfully, and "false" in the other case.
 - Error (String): * If the Result is false, it return the error.

HexID = "69643d31"      -- The Hexadecimal ID that identify the scene
Parameters = 12         -- If the scene needs some parameters to run, then thery are insert here, each separated by a comma
AllWorked, Error = resiot_runscene(HexID,Parameters)
if Error ~= "" then
    -- error 
    resiot_debug(Error)
else
    -- bool value successfull call
    resiot_debug(AllWorked)
end

Return to index


resiot_runscenewithcallback(String, String, String, ...)

Starts another Scene with an input parameter and waits for it to return a value. This means the script is run in synchronous manner. The Scene is identified by its Hexadecimal ID or its Tag. If both are declared and valid, the HexID will be used.
Example
ret, Error = resiot_runscenewithcallback("abcdef", "", "")
Input Parameters
 - HexID (String): * The Hexadecimal ID that identifies the scene to be run.
 - Tag (String): * The scene Tag of that identifies the scene to be run.
 - Input (String): * An input parameter that can be retrieved in the scene you want to run via resiot_comm_getparam("input"). Use a json along with json functions if you need to pass complex data.
 - Parameters (String/Integer/Float): * Just like the function resiot_runscene, additional parameters can be passed here and then be retrieved via the resiot_getparam function.
Returns*
 - ReturnValue (String): * the returned value from the scene you're running.
 - Error (String): * If the scene failed to run, the reason will be reported here.

HexID = "69643d31"          -- The Hexadecimal ID that identifies the scene to be run
Tag = ""                    -- The scene Tag of that identifies the scene to be run
Input = "aninputparameter"  -- An input parameter that can be retrieved in the scene you want to run
ret, err = resiot_runscenewithcallback(HexID, Tag, Input)
if err ~= "" then
  -- error
  resiot_debug(err)
else
  -- value read correctly
  resiot_debug(ret)
end

Return to index


resiot_setreturnvalue(String)

If you're running a scene with a mechanism that's going to read the output of your scene, you will need this function to set this value.
Please notice this is not the equivalent of a return in standard programming languages, this is a non-blocking method.
Example
resiot_setreturnvalue("done")
Input Parameters
 - Input (String): * There are no limits in terms of length, your returned text (usually a json) can be as long as you want *

resiot_setreturnvalue("I'm finally done!")
resiot_debug("hey! I'm still alive") -- this part of code WILL be reached

Return to index


resiot_time(Integer)

Get the actual date of your organization.
Example
Year, Month, Day, Hour, Minute, Second = resiot_time(YearFormat)
Input Parameters
 - YearFormat (Integer): * The type of the year that is returned, 0 will return the year in a 4 digit format (2017), 1 will return the year in a 2 digit format (17).
Returns
 - Year (Integer): * The year in a 4 or 2 digit format.

 - Month (Integer): * The number of the month (1-12).
 - Day (Integer): * The number of the day of the month (1-31).

 - Hour (Integer): * The number of the hour (0-23).
 - Minute (Integer): * The number of the minute (0-59).

 - Second (Integer): * The number of the second (0-59). *

YearFormat = 1      -- The type of the year that is returned, 0 will be in a 4 digit format (2017), 1 will be in a 2 digit format (17)
Year, Month, Day, Hour, Minute, Second = resiot_time(YearFormat)
resiot_debug(Year.."/"..Month.."/"..Day.." "..Hour..":"..Minute..":"..Second)
-- 
-- Result Example:
-- 
-- If YearFormat is 1:
-- 
-- Year = 17
-- 
-- Else:
-- 
-- Year = 2017
-- 
-- Month = 4
-- Day = 20
-- Hour = 16
-- Minute = 3
-- Second = 26
-- 

Return to index


resiot_timeutc(Integer)

Get the actual date of UTC.
Example
Year, Month, Day, Hour, Minute, Second = resiot_timeutc(YearFormat)
Input Parameters
 - YearFormat (Integer): * The type of the year that is returned, 0 will return the year in a 4 digit format (2017), 1 will return the year in a 2 digit format (17).
Returns
 - Year (Integer): * The year in a 4 or 2 digit format.

 - Month (Integer): * The number of the month (1-12).
 - Day (Integer): * The number of the day of the month (1-31).

 - Hour (Integer): * The number of the hour (0-23).
 - Minute (Integer): * The number of the minute (0-59).

 - Second (Integer): * The number of the second (0-59). *

YearFormat = 1      -- The type of the year that is returned, 0 will be in a 4 digit format (2017), 1 will be in a 2 digit format (17)
Year, Month, Day, Hour, Minute, Second = resiot_timeutc(YearFormat)
resiot_debug(Year.."/"..Month.."/"..Day.." "..Hour..":"..Minute..":"..Second)
-- 
-- Result Example:
-- 
-- If YearFormat is 1:
-- 
-- Year = 17
-- 
-- Else:
-- 
-- Year = 2017
-- 
-- Month = 4
-- Day = 20
-- Hour = 16
-- Minute = 3
-- Second = 26
-- 

Return to index


resiot_timefromunix(Integer, Integer)

Get the date of your organization from a Unix time.
Example
Year, Month, Day, Hour, Minute, Second = resiot_timefromunix(TimeUnix, YearFormat)
Input Parameters
 - TimeUnix (Integer): * The time in Unix format.
 - YearFormat (Integer): * The type of the year that is returned, 0 will return the year in a 4 digit format (2017), 1 will return the year in a 2 digit format (17).

Returns
 - Year (Integer): * The year in a 4 or 2 digit format.
 - Month (Integer): * The number of the month (1-12).

 - Day (Integer): * The number of the day of the month (1-31).
 - Hour (Integer): * The number of the hour (0-23).

 - Minute (Integer): * The number of the minute (0-59).
 - Second (Integer): * The number of the second (0-59).

TimeUnix = os.time()
YearFormat = 1      -- The type of the year that is returned, 0 will be in a 4 digit format (2017), 1 will be in a 2 digit format (17)
Year, Month, Day, Hour, Minute, Second = resiot_timefromunix(TimeUnix, YearFormat)
resiot_debug(Year.."/"..Month.."/"..Day.." "..Hour..":"..Minute..":"..Second)
-- 
-- Result Example:
-- 
-- If YearFormat is 1:
-- 
-- Year = 17
-- 
-- Else:
-- 
-- Year = 2017
-- 
-- Month = 4
-- Day = 20
-- Hour = 16
-- Minute = 3
-- Second = 26
-- 

Return to index


resiot_weeknumber(Integer, Integer)

Get the week number of the year of your organization from a Unix time.
Example
WeekNumber = resiot_weeknumber(TimeUnix)
Input Parameters
 - TimeUnix (Integer): * The time in Unix format.
Returns
 - WeekNumber (Integer): * The week number of the year.

TimeUnix = os.time()
WeekNumber = resiot_weeknumber(TimeUnix)
resiot_debug(WeekNumber)

Return to index


resiot_strtime(Integer)

Get the date of your organization in string format from a Unix time.
Example
dateString = resiot_strtime(TimeUnix)
Input Parameters
 - TimeUnix (Integer): * The time in Unix format.
Returns
 - dateString (String): * The date of your organization in string format.

TimeUnix = os.time()
dateString = resiot_strtime(TimeUnix)
resiot_debug(dateString)
-- 
-- Result Example:
-- 
-- Jul 16 2021, 10:42:21
-- 

Return to index


resiot_strtimewoffset(Integer)

Get the date and offset of your organization in string format from a Unix time.
Example
dateString = resiot_strtimewoffset(TimeUnix)
Input Parameters
 - TimeUnix (Integer): * The time in Unix format.
Returns
 - dateString (String): * The date and offset of your organization in string format.

TimeUnix = os.time()
dateString = resiot_strtimewoffset(TimeUnix)
resiot_debug(dateString)

Return to index


resiot_timetounix(String, String)

Get the Unix time from a date string.
Example
UnixTime, Err = resiot_timetounix(DateString, DateFormat)
Input Parameters
 - DateString (String): * The date in string format.
 - DateFormat (String): * The format of the date in input.

Returns
 - UnixTime (Integer): * The time in Unix format.
 - Err (String): * The error description.

DateString = "22/05/2021 09:24:31 +01"
DateFormat = "GG/MM/YYYY hh:mm:ss TZ"
UnixTime, Err = resiot_timetounix(DateString, DateFormat)
resiot_debug(UnixTime)
resiot_debug(Err)

Return to index


resiot_raiseevent(String, String)

Trigger the input Event of a Node.
Example
Error = resiot_raiseevent(AppEUI, DevEUI, EventName)
Input Parameters
 - AppEUI (String): * The AppEUI of the Node.
 - DevEUI (String): * The DevEUI of the Node.

 - EventName (String): * The designed Event.
Returns
 - Error (String): * The occurred error.

AppEUI = "8811abbc8271fbAF"     -- The AppEUI of the Node
DevEUI = "aa32131bc12afcb2"     -- The DevEUI of the Node
EventName = "Start_cleanup"     -- The designed Event
Error = resiot_raiseevent(AppEUI, DevEUI, EventName)
if Error ~= "" then
    -- error 
    resiot_debug(Error)
end

Return to index


resiot_regex(String, String, Integer)

Check if the string val respect the regex pattern.
If Index is bigger than 0, you'll have in return the string that is specified in the parenthesis.
Example
Variable = resiot_regex(Pattern, Value, Index)
Input Parameters
 - Pattern (String): * The pattern that the string must comply to. It must be written in golang language.
 - Value (String): * The string that is checked.

 - Index (Integer): * If 0, return all the string; meanwhile if it is bigger than 0, it return the section of the string specified by the Index.
Returns
 - Variable (String): * It return the whole string if index is 0; elsewhere it return a determined section of the same string specified by the Index.

Pattern = "^([a-zA-Z0-9]+)@([a-zA-Z0-9]+\\.[a-zA-Z]+)$"     -- The pattern that the string must comply to. It must be written in golang language
-- ([a-zA-Z0-9]+) is returned with index 1
-- ([a-zA-Z]+\\.[a-zA-Z]+) is returned with index 2
Value = "email@email.com"       -- The string that is checked
-- 
-- Examples:
-- 
Index = 0       -- It return the whole string if index is 0; elsewhere it return a determined section of the same string specified by the Index
Variable = resiot_regex(Pattern, Value, Index)
resiot_debug(Variable)
-- Variable = "email@email.com"
-- 
Index = 1
Variable = resiot_regex(Pattern, Value, Index)
resiot_debug(Variable)
-- Variable = "email"
-- 
Index = 2
Variable = resiot_regex(Pattern, Value, Index)
resiot_debug(Variable)
-- Variable = "email.com"
-- 

Return to index


resiot_subregex(String, String, Integer, Integer)

Check if the string val respect the regex pattern.
If Index is bigger than 0, you'll have in return the string that is specified in the parenthesis.
Example
Variable = resiot_subregex(Pattern, Value, Index1, Index2)
Input Parameters
 - Pattern (String): * The pattern that the string must comply to. It must be written in golang language.
 - Value (String): * The string that is checked.

 - Index1 (Integer): * Select the match which you want to retrive the data.
 - Index2 (Integer): * If 0, return all the match; meanwhile if it is bigger than 0, it return the section of the string specified by the Index.

Returns
 - Variable (String): * It return the whole string if index is 0; elsewhere it return a determined section of the same string specified by the Index. *

Pattern = "([a-zA-Z0-9]+)@([a-zA-Z0-9]+\\.[a-zA-Z]+)"   -- The pattern that the string must comply to. It must be written in golang language
-- ([a-zA-Z0-9]+) is returned with index2 1
-- ([a-zA-Z]+\\.[a-zA-Z]+) is returned with index2 2
Value = "email1@email1.com email2@email2.com"           -- The string that is checked
-- 
-- Examples:
-- 
Index1 = 0      -- Select the match which you want to retrive the data
-- 
Index2 = 0      -- If 0, return all the match; meanwhile if it is bigger than 0, it return the section of the string specified by the Index
Variable = resiot_subregex(Pattern,Value,Index1,Index2)
resiot_debug(Variable)
-- Variable = "email1@email1.com"
-- 
Index2 = 1
Variable = resiot_subregex(Pattern,Value,Index1,Index2)
resiot_debug(Variable)
-- Variable = "email1"
-- 
Index1 = 1
-- 
Index2 = 0
Variable = resiot_subregex(Pattern,Value,Index1,Index2)
resiot_debug(Variable)
-- Variable = "email2@email2.com"
-- 
Index2 = 2
Variable = resiot_subregex(Pattern,Value,Index1,Index2)
resiot_debug(Variable)
-- Variable = "email2.com"
-- 

Return to index


resiot_getsunrise(String, String)

Get the time of sunrise, in minutes, of a node.
The output are the minutes of sunrise after the midnight.
Example
Sunrise = resiot_getsunrise(AppEUI, DevEUI)
Input Parameters
 - AppEUI (String): * The AppEUI of the Node.
 - DevEUI (String): * The DevEUI of the Node.

Returns
 - Sunrise (Integer): * It return the minutes from midnight to the sunrise of the current day. *

AppEUI = "8811abbc8271fbAF"     -- The AppEUI of the Node
DevEUI = "aa32131bc12afcb2"     -- The DevEUI of the Node
Sunrise = resiot_getsunrise(AppEUI, DevEUI)
resiot_debug(Sunrise)
-- 
-- Result Example:
-- 
-- If there aren't any errors:
-- 
-- Sunrise = 336    It return the minutes from midnight to the sunrise of the current day
-- 
-- Else:
-- 
-- Sunrise = -1
-- 

Return to index


resiot_getsunset(String, String)

Get the time of sunset, in minutes, of a node.
The output are the minutes of sunset before the midnight.
Example
Sunset = resiot_getsunrise(AppEUI, DevEUI)
Input Parameters
 - AppEUI (String): * The AppEUI of the Node.
 - DevEUI (String): * The DevEUI of the Node.

Returns
 - Sunset (Integer): * It return the minutes from the sunset of the current day, to midnight. *

AppEUI = "8811abbc8271fbAF"     -- The AppEUI of the Node
DevEUI = "aa32131bc12afcb2"     -- The DevEUI of the Node
Sunset = resiot_getsunset(AppEUI, DevEUI)
resiot_debug(Sunset)
-- 
-- Result Example:
-- 
-- If there aren't any errors:
-- 
-- Sunset = 188     It return the minutes from the sunset of the current day, to midnight
-- 
-- Else:
-- 
-- Sunset = -1
-- 

Return to index


resiot_dayoftheweek(Integer)

Get the day of the week of a date.
Example
Day = resiot_dayoftheweek(Date)
Input Parameters
 - Date (Integer): * The date in seconds.
Returns
 - Day (String): * It return the name of the day of the date.

Date = os.time()        -- The date in seconds
Day = resiot_dayoftheweek(Date)
resiot_debug(Day)
-- 
-- Result Example:
-- 
-- Day = "Tuesday"
-- 

Return to index


resiot_curl(String)

Send a HTTP request via web server APIs.
The curl need a json string as imput, the fields are "method", "url", "headers", "data", "authLogin", "authPw".
Field "method" is get or post, the "url" is the url of the page you want to request with the curl, "headers" are custom headers that can be added for the selection of specific parts of the page, the headers have two sub-field "name" and "value", these are used to specify what type of header you are searching and the value that you want, "data" contains the data that are sent to the page in POST mode like a form submit, "authLogin" & "authPw" contains the eventual login and password for the website page you are trying to request via curl.
Example
CurlData = '{"method": "get","url" : "http://www.google.com/robots.txt", "headers":[{"name": "", "value": ""}], "data": "", "authLogin": "", "authPw": ""}'
Json = resiot_curl(CurlData)

Input Parameters
 - CurlData (String) : * The body of the HTTP request.
Returns
 - Json (String) : * It return the response of the curl in a Json valid format.

CurlData = '{"method": "get","url" : "http://www.google.com/robots.txt", "headers":[{"name": "", "value": ""}], "data": "", "authLogin": "", "authPw": ""}'
        -- The body of the HTTP request
Json, err = resiot_curl(CurlData)
if err ~= "" then
    -- error 
    resiot_debug(err)
else
    -- value read correctly
    resiot_debug(Json)
end

CurlData = '{"method": "post","url" : "https://api.digitalocean.com/v2/domains/example.com/records", "headers":[{"name":"Content-Type", "value": "application/json"}, {"name":"Authorization", "value": "Bearer b7d03a6947b217efb6f3ec3bd3504582"}], "data":"{\\"type\\":\\"A\\",\\"name\\":\\"www\\",\\"data\\":\\"162.10.66.0\\",\\"priority\\":null,\\"port\\":null,\\"weight\\":null}\\"}", "authLogin": "", "authPw": ""}'
Json, err = resiot_curl(CurlData)
if err ~= "" then
    -- error 
    resiot_debug(err)
else
    -- value read correctly
    resiot_debug(Json)
end

StringPost = 'email=email@test.com&password=testpassword'
StringPost = resiot_urlencode(StringPost)
CurlData = '{"method": "post", "url": "https://api.digitalocean.com/v2/domains/example.com/records", "headers":[{"name":"Content-Type", "value": "application/x-www-form-urlencoded"}], "data": "'..StringPost..'", "authLogin": "", "authPw": ""}'
Json, err = resiot_curl(CurlData)
if err ~= "" then
    -- error 
    resiot_debug(err)
else
    -- value read correctly
    resiot_debug(Json)
end

Return to index


resiot_getram()

Get the ram usage.
Example
ram = resiot_getram()
Returns
 - Ram (String): * It returns the ram usage. *

r, err = resiot_getram()
if err ~= "" then
  resiot_debugf("error: %%v"..err)
else
  resiot_debugf("Used ram: %%v percent!", r)
end 
-- 
-- Output Example: "Used ram: 60.02 percent!"
-- 

Return to index


resiot_getcpu()

Get the cpu usage.
Example
cpu = resiot_getcpu()
Returns
 - Day (String): * It returns the cpu usage. *

r, err = resiot_getcpu()
if err ~= "" then
  resiot_debugf("error: %%v"..err)
else
  resiot_debugf("Used CPU: %%v percent!", r)
end 
-- 
-- Output Example: "Used CPU: 60.02 percent!"
-- 

Return to index


resiot_certvalidity()

Get the number of hours of validity of your webserver SSL certificate.
Only the platform admins have access to this function which will eventually return an error if you do not have admin rights.
Example
hours, err = resiot_certvalidity()
Returns
 - Hours (Integer): * The number of hours until your SSL expires. Please note this can be negative if your certificate has expired already.
 - Err (String): * A non empty string if something went wrong.

r, err = resiot_certvalidity()
if err ~= "" then
  resiot_debugf("Error: %%v"..err)
else
  resiot_debugf("Validity: %%v hours!", r)
end 

Return to index


resiot_distance(Float,Float,Float,Float)

Calculates the great-circle distance in meters between two gps coordinates using the []Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula)
Example
distance = resiot_distance(Lat1,Lon2,Lat2,Lon2)
Input Parameters
 - Lat1 (Float): * The latitude of the first coordinate.
 - Lon2 (Float): * The longitude of the first coordinate.

 - Lat2 (Float): * The latitude of the second coordinate.
 - Lon2 (Float): * The longitude of the second coordinate.

Returns
 - distance (Float): * The distance in meters between the two coordinates considering Earth's curvature *

lat1 = 45.534060    -- The coordinates of the two points
lon1 = 10.011074
lat2 = 45.555812
lon2 = 10.075685

resiot_debug(resiot_distance(lat1, lon1, lat2, lon2))

Return to index


resiot_urldecode(String)

Decode an URL encoded string into readable string.
Example
decodedStr, Error = resiot_urldecode(EncodedURL)
Input Parameters
 - EncodedURL (String): * The encoded string you want to decode.
Returns
 - decodedStr (String): * The output is a readable string.

 - Error (String): * Error string. *

EncodedURL = "20%2F08%2F2020%2012%3A35%3A22.741%20mail%40server.it"

decodedStr, Error = resiot_urldecode(EncodedURL)
if Error ~= "" then
    -- error 
    resiot_debug(Error)
else
    -- value read correctly
    resiot_debug(decodedStr)
end

Return to index


resiot_urlencode(String)

Encode a readable string into an URL encoded string.
Example
encodedStr = resiot_urlencode(DecodedURL)
Input Parameters
 - DecodedURL (String): * The readable string you want to encode.
Returns
 - encodedStr (String): * The output is an encoded string.

DecodedURL = "20/08/2020 12:35:22.741 mail@server.it"

encodedStr = resiot_urlencode(DecodedURL)
resiot_debug(encodedStr)

Return to index


resiot_getlanguage()

Get the language in ISO and extended format of the user who executes the scene.
Example
langISO, langName = resiot_getlanguage()
Returns
 - langISO (String): * The language in ISO format.
 - langName (String): * The language name.

langISO, langName = resiot_getlanguage()
resiot_debug(langISO)
resiot_debug(langName)

Return to index


resiot_getlanguagefromuser(String)

Get the language in ISO and extended format of the user with the given email.
Example
langISO, langName = resiot_getlanguagefromuser(userEmail)
Input Parameters
 - userEmail (String): * The email of the user you want to get the language.
Returns
 - langISO (String): * The language in ISO format.

 - langName (String): * The language name. *

userEmail = "mail@server.com"

langISO, langName = resiot_getlanguagefromuser(userEmail)
resiot_debug(langISO)
resiot_debug(langName)

Return to index


resiot_gethtml_widget(String, Integer, String, String, String, Bool, String, String, String, String, Integer, Integer, Integer)

Get the HTML code to show a widget based on a Node Field.
Example
resultHTML, err = resiot_gethtml_widget(Reference, WidgetType, AppEUI, DevEUI, Field, CustomSearch, width, height, label, color, hourSel, timeSince, timeTo)
Input Parameters
 - Reference (String): * A unique name you can choose, used to identify widgets, when creating more than one widget per page it is strongly recommended to use different References for each widget.
 - WidgetType (Integer): * A numeric code which identifies the type of widget you want to create. Currently only linear widgets are supported. Linear widget code: 10.

 - AppEUI (String): * The AppEUI of the Node you want to get the Field from.
 - DevEUI (String): * The DevEUI of the Node you want to get the Field from.

 - Field (String): * The name of the Node Field you want to use in the widget.
 - CustomSearch (Bool): * When true it allows to use the custom date filter for the widget, otherwise only default time filters are available.

 - width (String): * The HTML width of the widget, if empty string the width will be set to "100%".
 - height (String): * The HTML height of the widget.

 - label (String): * The label you want to display for the line in the widget.
 - color (String): * The color of the line in the widget.

 - hourSel (Integer): * The default value of the time filter (always expressed in hours). For "Custom" use -1. For "Last values" use -2.
 - timeSince (Integer): * The starting time in Unix of the interval you want to search in. Used only when hourSel is -1 (Custom)

 - timeTo (Integer): * The ending time in Unix of the interval you want to search in. Used only when hourSel is -1 (Custom)
Returns
 - resultHTML (String): * The HTML code of the widget to display.

 - err (String): * The error of the function, if no error this will contain an empty string. *

Reference = "ref1"
WidgetType = 10
AppEUI = "1234123412341234"
DevEUI = "2759847589624783"
Field = "Temperature"
CustomSearch = true
width = ""
height = "150"
label = "Temp (°C)"
color = "#8B0000"
hourSel = -1
timeSince = os.time()-3600
timeTo = os.time()-1800

resultHTML, err = resiot_gethtml_widget(Reference, WidgetType, AppEUI, DevEUI, Field, CustomSearch, width, height, label, color, hourSel, timeSince, timeTo)
resiot_debug(resultHTML)
resiot_debug(err)

Return to index


resiot_gethtml_linearwidget(String, String, String, String, Bool, String, String, String, String, Integer, Integer, Integer)

Get the HTML code to show a linear widget based on a Node Field.
Example
resultHTML, err = resiot_gethtml_linearwidget(Reference, AppEUI, DevEUI, Field, CustomSearch, width, height, label, color, hourSel, timeSince, timeTo)
Input Parameters
 - Reference (String): * A unique name you can choose, used to identify widgets, when creating more than one widget per page it is strongly recommended to use different References for each widget.
 - AppEUI (String): * The AppEUI of the Node you want to get the Field from.

 - DevEUI (String): * The DevEUI of the Node you want to get the Field from.
 - Field (String): * The name of the Node Field you want to use in the widget.

 - CustomSearch (Bool): * When true it allows to use the custom date filter for the widget, otherwise only default time filters are available.
 - width (String): * The HTML width of the widget, if empty string the width will be set to "100%".

 - height (String): * The HTML height of the widget.
 - label (String): * The label you want to display for the line in the widget.

 - color (String): * The color of the line in the widget.
 - hourSel (Integer): * The default value of the time filter (always expressed in hours). For "Custom" use -1. For "Last values" use -2.

 - timeSince (Integer): * The starting time in Unix of the interval you want to search in. Used only when hourSel is -1 (Custom)
 - timeTo (Integer): * The ending time in Unix of the interval you want to search in. Used only when hourSel is -1 (Custom)

Returns
 - resultHTML (String): * The HTML code of the widget to display.
 - err (String): * The error of the function, if no error this will contain an empty string.

Reference = "ref1"
AppEUI = "1234123412341234"
DevEUI = "2759847589624783"
Field = "Temperature"
CustomSearch = true
width = ""
height = "150"
label = "Temp (°C)"
color = "#8B0000"
hourSel = -1
timeSince = os.time()-3600
timeTo = os.time()-1800

resultHTML, err = resiot_gethtml_linearwidget(Reference, AppEUI, DevEUI, Field, CustomSearch, width, height, label, color, hourSel, timeSince, timeTo)
resiot_debug(resultHTML)
resiot_debug(err)

Return to index