Jump to content

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


  • 0

URL commands to Domoticz (HC3)


Firepeet
 Share

Question

I'm really a noob with QA, and I've spent already hours and hours looking for a solution of my problem.

Because HC3 does not yet support Somfy RTS, I want to control my Somfy roller shutters using Domoticz. I can easily operate them from Domoticz, and I can operate them also by an URL like 

http://192.168.1.138:8080/json.htm?type=command&param=switchlight&idx=52&switchcmd=(On, Off or stop)

 

How can I integrate this in  the standard QuickApp for the roller shutters?

This QA has the following code:

Please login or register to see this code.

 


I found a step by step tutorial, but only for the HC2:

Please login or register to see this image.

/applications/core/interface/file/attachment.php?id=14911" />

Edited by Firepeet
Link to comment
Share on other sites

19 answers to this question

Recommended Posts

  • 0

@Firepeet

You are missing any calls to the specified URL in QA.
I will say: In your example you have a link to the manual for QA. Look for the paragraph - net.HTTPClient and HTTPClient: request (address, params).
There are beautiful examples of use.
You have more ways to reach the goal:
1) In each function (up, down, stop ..) you add the appropriate lines of code with HTTPclient and you will have a done but gigantic code. Always add the correct code to the string:
local address = "http://192.168.1.138:8080/json.htm?type=command&param=switchlight&idx=52&switchcmd=On"
= Off "
= stop "

2) create another function

function QuickApp: fcCommands(cmd)

--... all from before example for one cmd...

end

 

that will contain variables and parameters (up, down, stop, On, Off ..) embedded in the string local address = "http://192.168.1.138:8080/json.htm?type=command&param=switchlight&idx=52&switchcmd=" ..cmd

The command variable will then take the value of the passed parameter from the function.
You add functions with a parameter to the function. For example:
function QuickApp: open ()
    -- self: debug ("roller shutter opened")
    --  self: updateProperty ("value", 99)
fibaro.call (self.id, "fcCommands", "On")
end

 

Note:

Delete lines 18-22 from the example QA manual. Alternatively, you can change them if you want to read the information that will be returned when sending an http string. The same goes for the header.
This information can be used for debugging, whether the command was executed, reading the state of the state, etc. The result may be returned in JSON format, then the rest of the example with decoding the result will be useful.
Test the crucial http view in the browser of what is written after submission.

 

Have fun coding. It will take you to the next level.

eM.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi @Martin_N, thanks for your answer. You have reopened for me the door to programming with QA? 

     

    I added the following code for opened (i did also for closed and stopped), but it's still not working.

    (The shutters are moving when i follow the link by ctrl + click, so the links are correct)

     

    Please login or register to see this code.

     

    Then i get the following debug messages:

     

    Please login or register to see this code.

     

    Edited by Firepeet
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Problem solved, i forgot to put the extra line

    Please login or register to see this code.

    ?

     

     

    Edited by Firepeet
    Link to comment
    Share on other sites

    • 0
    Guest rafal_ll

    Hello, can you share the finished device?
    I have a similar problem only with Dooya blinds

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 11 minutes ago, rafal_ll said:

    Hello, can you share the finished device?
    I have a similar problem only with Dooya blinds

     

    This one is working for me:

    Please login or register to see this code.

     

    • Like 1
    Link to comment
    Share on other sites

    • 0

    Just wonder what can’t HC3 what can Domoticz

    Well

    as I can see api easy can be portable to HC3 

    Please login or register to see this link.

    no, ;) I am not interesting for this device but as fact implementation for HC3 not difficult as for me 

    Link to comment
    Share on other sites

    • 0
    47 minutes ago, Firepeet said:

    fibaro.call (self.id, "fcCommands", "Off")

    Do not call a local function via RPC.

    just for your info

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 33 minutes ago, 10der said:

    Do not call a local function via RPC.

    just for your info

     

    Please can you explain what you mean?

    Link to comment
    Share on other sites

    • 0
    11 hours ago, Firepeet said:

    fibaro.call (self.id, "fcCommands", "Off")


    should be simplest as 

    self:fcCommands(“Off”)

    instead of RPC call via fibaro.call

     

    11 hours ago, Firepeet said:

    function QuickApp: fcCommands(cmd)

     

    • Like 1
    Link to comment
    Share on other sites

    • 0

    Hi

     

    I want to use my old lua code to control a status with https login who can help me to convert it to Lua 3 

    made a new topic

    Edited by stefke
    Link to comment
    Share on other sites

    • 0
    Guest rafal_ll

    Can the roller blind be used in a block scene?
    It only moves the slider and the blind does nothing.

    -------------------------------------------------------------------------------------------

    I activated the slider. You can probably do better.
    This is the only way I can. It works

     

    function QuickApp:open()
       self: debug ("roller shutter opened")
       self: updateProperty ("value", 99) 
    fibaro.call (self.id, "fcCommands", "Off")
    end
     
    function QuickApp:close()
       self: debug ("roller shutter closed")
       self: updateProperty ("value", 0) 
    fibaro.call (self.id, "fcCommands", "On")
    end
     
    function QuickApp:stopLevelChange()
       self: debug ("roller shutter stopped")
       self: updateProperty ("value", 50) 
    fibaro.call (self.id, "fcCommands", "Stop")
    end
     
    function QuickApp: fcCommands(cmd)
    local address = "http://192.168.1.107:8084/json.htm?type=command&param=switchlight&idx=827&switchcmd=" ..cmd
     
        self.http:request(address, {
            options={
                headers = { 
                    Accept = "application/json"
                },
                checkCertificate = true,
                method = 'GET'
            },
            success = function(response)
                self:debug("response status:", response.status) 
                self:debug("headers:", response.headers["Content-Type"]) 
                local data = json.decode(response.data)
            end,
            error = function(error)
                self:debug('error: ' .. json.encode(error))
            end
        }) 
    end
     
    -- Wartość jest typem liczby całkowitej (0-99)
    function QuickApp:setValue(value)
        self:debug("roller shutter set to: " .. tostring(value))
        self:updateProperty("value", value)  
     
        if value >= 80 then
        self: debug ("Roleta otwarta")
        self: updateProperty ("value", 99 )
        fibaro.call (self.id, "fcCommands", "Off")
        elseif (value >=40 and value <=60) then
        self: debug ("Roleta zatrzymana")
        self: updateProperty ("value", 50)
        fibaro.call (self.id, "fcCommands", "Stop")
        elseif value <= 20 then
        self: debug ("Roleta zamknięta")
        self: updateProperty ("value", 0)
        fibaro.call (self.id, "fcCommands", "On")
        end
    end
     
    function QuickApp:setValueVar(value)
        self:debug("roller shutter set to: " .. tostring(value))
        self:updateProperty("value", value)  
    end
     
    function QuickApp:onInit()
        self:debug("onInit")
         self.http = net.HTTPClient({timeout=3000})
    end
    Edited by rafal_ll
    Link to comment
    Share on other sites

    • 0

    I Changed the code a bit for the next reasons.

    1) Like 10der said, do not perform internally a RPC call via fibaro.

    2) As soon as you call an updateProperty twice in a row, you must give the 'code behind' the possibility to execute the update.

         This can be done with a timeout of 200. but 300 is safer.

    3) I aslo change the values, so there are no blind spots..

     

    Please Check if it works...

    and let me know.

     

    Please login or register to see this code.

     

    Edited by NLWaard
    ​?​ add ) at the end fibaro.setTimeout(
    Link to comment
    Share on other sites

    • 0
    5 hours ago, NLWaard said:

    function fcCommands(self,cmd)

    just wonder why.

     

    vs

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0

    Nice noticed 10der..

    28 minutes ago, 10der said:

    just wonder why.

     

    Not really a command that you call with an external QA or scene.

    Then I prefer to make such a function local, I think it's cleaner.

     

    But both functions work properly!

    Edited by NLWaard
    Link to comment
    Share on other sites

    • 0
    Guest rafal_ll
    19 godzin temu, NLWaard napisał:

    I Changed the code a bit for the next reasons.

    1) Like 10der said, do not perform internally a RPC call via fibaro.

    2) As soon as you call an updateProperty twice in a row, you must give the 'code behind' the possibility to execute the update.

         This can be done with a timeout of 200. but 300 is safer.

    3) I aslo change the values, so there are no blind spots..

     

    Please Check if it works...

    and let me know.

     

    Please login or register to see this code.

     

     

    This code is not working. I get a message
    [17/09/2020] [09:48:01] [09:48:01] [ERROR] [QUICKAPP88]: QuickApp crash
    [09/17/2020] [09:48:01] [ERROR] [QUICKAPP88]: main.lua: 1: syntax error near "QuickApp"

    Link to comment
    Share on other sites

    • 0
    7 hours ago, rafal_ll said:

     

    This code is not working. I get a message
    [17/09/2020] [09:48:01] [09:48:01] [ERROR] [QUICKAPP88]: QuickApp crash
    [09/17/2020] [09:48:01] [ERROR] [QUICKAPP88]: main.lua: 1: syntax error near "QuickApp"

    Hmmm. sorry.

    I see, there was a closing ')' missing at the end of the timeout function..

    My code above updated.

     

    thanks.. 

    Link to comment
    Share on other sites

    • 0
    Guest rafal_ll

    I needed a simple way to update the shutter state while using the remote.

    Domoticz easily sends variables to Fibaro HC3.

    Please login or register to see this attachment.

     


    I created the variables.

     

    Please login or register to see this attachment.

     

    And the QA update scene from the blinds.

    Please login or register to see this attachment.

     

     

    There is probably a better way, it works fine for me and doesn't burden the switchboard

    sorry for the English
    (translator)

     

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

     Share

    ×
    ×
    • Create New...