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


HC3 send data to url on trigger


GJ Niewenhuijse

Recommended Posts

My goal is to send device changes from +- 20 fibaro devices to another api system. My devices are motion sensors, door sensors, smoke sensors and wallplugs.

 

I started to make a lua script:

Please login or register to see this code.

How to make this script more generic, for example a script that triggers on every change in a range of devices? is that possible.

For example for device 1, 2, 7 and 10 a http request must be send when data changed for motion, light or temperature?

 

In the action i started a Quickapp, because i can't find a way to send direct http commands here:

Please login or register to see this code.

How to get the ID and the VALUE this scripts is triggered from?

 

After that i make a Quickapp:

Please login or register to see this code.

But now i get a http 401, how to solve this?

 

Anyone a better or more generic way to send data to another system with a api request?

Edited by GJ Niewenhuijse
Link to comment
Share on other sites

Here is a QA that could inspire you. It sends all events to external systems subscribing to events. Like webhook.

you could filter the events on your list of devices before pushing them.

 

Link to comment
Share on other sites

2 hours ago, GJ Niewenhuijse said:

How to make this script more generic, for example a script that triggers on every change in a range of devices? is that possible.

For example for device 1, 2, 7 and 10 a http request must be send when data changed for motion, light or temperature?

 

a multitigger with scene (power and state from dev 885, state from 939, any button click with centralscene dev, any button from sceneactivation dev, autostart after reboot and manually started)

 

Please login or register to see this code.

 

Quote

How to get the ID and the VALUE this scripts is triggered from?

 

of course one need later in scene code check the trigger

 

Please login or register to see this code.

 

of course there is limitation with scene instances, so the code need to be fast or async to not miss events ...

 

Quote

Anyone a better or more generic way to send data to another system with a api request?

 

the idea @jgab posted is actually much better, than a scene, because it does change with single instance any change. The same is being used in e.g. InitialState plugin, and it works very well, so for small integration one can work with scene, with larger of course with more scenes - or single QA.

 

Quote

Please login or register to see this code.

 

 

KNX ?

Edited by tinman
Link to comment
Share on other sites

  • Topic Author
  • 17 hours ago, jgab said:

    Here is a QA that could inspire you. It sends all events to external systems subscribing to events. Like webhook.

    you could filter the events on your list of devices before pushing them.

     

    Thanks, that looks like the solution. But how to easely filter events?

     

    For example i like to get value changes for device 21 and 24 and battery changes for devices 21:

    deviceEvents = 
    {
       [21] = {'value','battery'}, 
       [24] = {'value'}
    }
    Edited by GJ Niewenhuijse
    Link to comment
    Share on other sites

    • 8 months later...

    l'Hi,

     

    having issue getting this to work. I have only one goal - to trigger url from HC3 after tripple click of the button. I get all good, scene is triggered but url has not been sent. Tested in browser and url itself works. http://192.168.1.110/fcgi/do?action=OpenDoor&admin=&DoorNum=1

    Link to comment
    Share on other sites

    • 1 month later...

    Hi Mart wellcome to the club,

     

    I have exacly the same problem using a Akuvox intercom. Let's hope together that someone will find out what's wrong with the HC3 

    Link to comment
    Share on other sites

    • 3 months later...

    I`m not into LUA, all I want is to send a simple http (works with just putting it in the web browser), would be handy if something so simple was avaible to use in block scenes ?

    example of what I want to send: http://192.168.10.241/api/app/com.internet/test
     

    Link to comment
    Share on other sites

    • 9 months later...
    On 5/21/2021 at 6:01 PM, mart said:

    l'Hi,

     

    having issue getting this to work. I have only one goal - to trigger url from HC3 after tripple click of the button. I get all good, scene is triggered but url has not been sent. Tested in browser and url itself works. http://192.168.1.110/fcgi/do?action=OpenDoor&admin=&DoorNum=1

     

    Hi,

    this works now for me. I created a virtual device with this code:

     

    function QuickApp:turnOn()
        self:debug("binary switch turned on")
        self:updateProperty("value"true)
        fibaro.setTimeout(1000function() self:Open() end)
        fibaro.setTimeout(3000function() self:turnOff() end)
    end
     
    function QuickApp:turnOff()
        self:debug("binary switch turned off")
        self:updateProperty("value"false)    
    end
     
    function QuickApp:Open(description)
        self.http:request("http://192.168.1.29/fcgi/do?action=OpenDoor&DoorNum=1", {
            options = {
                method = "GET",
                headers = {
                   }
            },
            success = function(response) 
                self:debug(response.status)
                self:debug(response.data)
                self:updateProperty("value"true)
            end,
            error = function(message)
                self:debug("error:", message)
            end
        })
    end
     
    function QuickApp:onInit()
        self.http = net.HTTPClient({timeout=3000})
        self:debug("Clear")
    end
    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
    Reply to this topic...

    ×   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.

    ×
    ×
    • Create New...