Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team
All Activity
- Past hour
-
is it possible to do http post in LUA Scene?
jgab replied to fuser99's question in Scenes and Interface
This works in a scene local function urlencode (str) return str and string.gsub(str ,"([^% w])",function(c) return string.format("%%% 02X",string.byte(c)) end ) end local function doTest(url) net.HTTPClient():request(url, { options = { method = 'POST', checkCertificate = false, timeout = 1000, headers= { ['Content-Type'] = 'application/json', ['accept'] = '*/*' } }, success = function(response) fibaro.debug(tag,response.status .. " " .. response.data) end, error = function(message) fibaro.debug(tag,"HTTPClient error: " .. message) end }) end doTest("https://httpbin.org/post"..urlencode("?event=e1&tag=t2")) if the parameter part is not urlencoded it's stripped away by the HC3/Scene -
is it possible to do http post in LUA Scene?
fuser99 replied to fuser99's question in Scenes and Interface
Unfortunately, It doesn't work. - Yesterday
-
olekjell joined the community
-
Same problem here. Did you find a solution?
-
The third-part magnetic contact is good idea. Please consider, that even if you assemble the contacts and will know the gate position (open, close, partially open) you will probably need some programming to handle the gate. maybe your drive allows to force close or open, but I don't think so. I think that you can only do a sequence: move one direction, stop, move other direction by shortcut proper pins. And when o.e. you need to open the gate it may first start to close or - when closing - spot an obstacle and do not finish movement. It depends on the last operation before. This will need LUA scene to handle - to ensure that action was done to the very end. Also, there are extension cards for some gate drives (o.e. Hormann, quite popular in Poland), which provides info about gate status and can send specific command to the drive (open, close). Worth checking if there's any for CAME.
-
is it possible to do http post in LUA Scene?
Joep replied to fuser99's question in Scenes and Interface
For me that didn’t work. -
is it possible to do http post in LUA Scene?
jgab replied to fuser99's question in Scenes and Interface
If you urlencode the parameters? -
Anders Dragoy joined the community
-
Rosadimontagna joined the community
-
is it possible to do http post in LUA Scene?
Joep replied to fuser99's question in Scenes and Interface
I answered that question twice. -
is it possible to do http post in LUA Scene?
fuser99 replied to fuser99's question in Scenes and Interface
I also noticed that. is there a workaround on this? -
is it possible to do http post in LUA Scene?
Joep replied to fuser99's question in Scenes and Interface
Ah, you are doing a POST. Normally you have a data payload with the parameters then. What I said. Parameters in the URL don't work in a HTTP scene. I don't know why. I tested this with an own HTTP endpoint to see what the HC3 sends, and from a scene the parameters are gone and with a QA they are still there. -
is it possible to do http post in LUA Scene?
fuser99 replied to fuser99's question in Scenes and Interface
Here is the full code that works great with QA: -- Binary switch type should handle actions turnOn, turnOff -- To update binary switch state, update property "value" with boolean function QuickApp:doTest(url) net.HTTPClient():request(url, { options = { method = 'POST', checkCertificate = false, timeout = 1000, headers= { ['Content-Type'] = 'application/json', ['accept'] = '*/*' } }, success = function(response) self:debug(response.status .. " " .. response.data) end, error = function(message) self:debug("HTTPClient error: " .. message) end }) end function QuickApp:turnOn() self:debug("binary switch turned on") QuickApp:doTest("http://10.254.5.254/webhook?event=e1&tag=t2") self:updateProperty("value", true) end function QuickApp:turnOff() self:debug("binary switch turned off") QuickApp:doTest("http://10.254.5.254/webhook?event=e2&tag=t2") self:updateProperty("value", false) end -- To update controls you can use method self:updateView(<component ID>, <component property>, <desired value>). Eg: -- self:updateView("slider", "value", "55") -- self:updateView("button1", "text", "MUTE") -- self:updateView("label", "text", "TURNED ON") -- This is QuickApp inital method. It is called right after your QuickApp starts (after each save or on gateway startup). -- Here you can set some default values, setup http connection or get QuickApp variables. -- To learn more, please visit: -- * https://manuals.fibaro.com/home-center-3/ -- * https://manuals.fibaro.com/home-center-3-quick-apps/ function QuickApp:onInit() self:debug("onInit") end also QA works with "GET" as method. -
This is somfy engine (GLYDEA ULTRA 35 DCT) connection scheme. I use FGS-224 to run (switch on) Open (1) and Close (6) contacts with (3) Ground/Common. There is https://community.smartthings.com/t/somfy-glydea-35e/57415/3 a more details description. And it's working fine. I only want to add this device as "Blind" to see it in the "Blinds list".
-
Yes, it would be too inefficient to traverse any nested json structure looking for time values…
- 996 replies
-
- 1
-
- rule engine
- eventrunner4
-
(and 1 more)
Tagged with:
-
Ahh okay, so ER5 probably has some inbuilt mechanism to convert simple LUA global variables, if they have time format. Thats why it works when using simple global variable without having us to convert it before using..thanks
- 996 replies
-
- rule engine
- eventrunner4
-
(and 1 more)
Tagged with:
-
SuporteLegado joined the community
-
is it possible to do http post in LUA Scene?
Joep replied to fuser99's question in Scenes and Interface
Yes, he’s doing a GET request with the parameters in the URL. -
is it possible to do http post in LUA Scene?
jgab replied to fuser99's question in Scenes and Interface
Can you show us the full request code that works in a QA? You can encode parameters in the URL of a POST... I guess you don't have a body for the POST? ...I believe that there is something else going on here -
Some network requests not working
Alex de Bruin replied to SMGhost's question in Scenes and Interface
Your URL doesn't work in a LUA scene but it's no problem in a quickApp (different HTTPclient) -
Yes, because it's a string "06:15", you need to convert it to the number of seconds. The constant 06:15 in the rule rule("@06:15 => ...") is just a short for the number of seconds (6*3600+60*15) In ER4 there used to be a function time(str) that converted a time string to number of seconds but it seems to have gone missing when I converted it to ER5. You can define it with rule("time = fibaro.toTime") and then do rule("@time(HOUSECHECKTIME) => do somethinkg...") Alternatively you convert it to seconds when you define it in Lua HOUSECHECKDATA = json.decode(hub.getGlobalvariable(HOUSECHECKDATA)) HOUSECHECKTIME = fibaro.toTime(HOUSECHECKDATA.housechecktime) -- now is number of seconds rule("@HOUSECHECKTIME => do somethinkg...")
- 996 replies
-
- rule engine
- eventrunner4
-
(and 1 more)
Tagged with:
-
Imre TF AS joined the community
-
gcoupe joined the community
-
@Nevicare @Hakon @Langedijk I have uploaded a version of the quickapp (in the first post). Please let me know it this works.
-
is it possible to do http post in LUA Scene?
Joep replied to fuser99's question in Scenes and Interface
You're example is not working in a Lua scene. Write a QA that does it and let the scene trigger the QA as a workaround. It's not nice, I know. -
@jgab Jan i am storing table data in a global variable HOUSECHECKDATA like this {housechecktime = '06:15', housecheckmode = enabled} however when i want to use that table data in a rule HOUSECHECKDATA = json.decode(hub.getGlobalvariable(HOUSECHECKDATA)) HOUSECHECKTIME = HOUSECHECKDATA.housechecktime --and when using in a rule rule("@HOUSECHECKTIME => do somethinkg...") -- i am getting this error Rule: Invalid daily time: 06:15 HOUSECHECKTIME is a regular string value, what am i missing?
- 996 replies
-
- rule engine
- eventrunner4
-
(and 1 more)
Tagged with:
-
is it possible to do http post in LUA Scene?
fuser99 replied to fuser99's question in Scenes and Interface
Is there a way to do what I need? Thank you. -
lincstar joined the community
-
removed
-
is it possible to do http post in LUA Scene?
Joep replied to fuser99's question in Scenes and Interface
This is a GET request with the parameters into the link. This is not a POST request. Yes, get request with application/x-www-form-urlencoded data (data in the url) is not supported in the HTTP:request implementationin a scene. I found that out the hard way. It's stupid, but the HTTP implementation of the scene and Quick App parts is different. Why FIBARO? -
is it possible to do http post in LUA Scene?
fuser99 replied to fuser99's question in Scenes and Interface
Thank you. It works on QuickApp, but it doesn't work on LUA Scene. I get 200 status respone but doesn't work. What I actually want is to do a request to http://10.254.5.254/webhook?event=e1&tag=t1 But it seems it does a request to http://10.254.2.254/webhook instead of the full url (http://10.254.5.254/webhook?event=e1&tag=t1) I even tried with GET and still the same issue, what can I do? If I do it via QuickApp the same way it works, but it doesn't work in LUA Scene.