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

Can HC2 listen to GET request?


Question

Posted

Hi all,

I am very new to the whole scripting thing. Essentially I would like to run a scene when the Doorbell is rang. From the API doc (

Please login or register to see this link.

) I understand this should be possible.

 

I tried to listen to the monitoring.cgi in a virtual device. But this always returns doorbell=0. Apparently the loop is too slow to capture the event... 

 

The doorbird can also send notifications via http get. Can I use this as a trigger? And how?

 

Thanks!

12 answers to this question

Recommended Posts

  • 0
Posted

no. only via the own wrapper.

so, inner HTTP call (as I can understand this is 3th party soft device with the incompatible calling for HC2) ---> own wrapper to http://hc2_address/api ---> HC2 api (see also http://hc2_address/docs)

  • 0
  • Inquirer
  • Posted (edited)
    2 hours ago, 10der said:

    no. only via the own wrapper.

    so, inner HTTP call (as I can understand this is 3th party soft device with the incompatible calling for HC2) ---> own wrapper to http://hc2_address/api ---> HC2 api (see also http://hc2_address/docs)

     

    Thanks for tour reply! I think I understand what you are saying.

    Such a wrapper could e.g. be running on a raspberry pi or synology I guess? 

     

    Just a php script would suffice right? Or would you have easier suggestions?

     

    Edited by 3JL
    • 0
    Posted (edited)

    @3JL and @10der, DoorBird can run a scene in Fibaro, why not to use it?

     

    Loop in VD runs every 3 seconds. Tested on very small code.

     

    It can be done by following command (example for doorbell):

    http://<deviceip>/bha-api/notification.cgi?url=http:/HC_IP/api/scenes/ID_SCENE&user=username&password=password&event=doorbell&subscribe=1

    or

    http://<deviceip>/bha-api/notification.cgi?url=http:/username:password@HC_IP/api/scenes/ID_SCENE&user=&password=&event=doorbell&subscribe=1

    Edited by jakub.jezek
    • 0
    Posted
    2 hours ago, 3JL said:

     

    Thanks for tour reply! I think I understand what you are saying.

    Such a wrapper could e.g. be running on a raspberry pi or synology I guess? 

     

    Just a php script would suffice right? Or would you have easier suggestions?

     

    3

     

    or QNAP, 

     

    but yes, Jakub gave the right answer for your solution.

     

    • 0
  • Inquirer
  • Posted

    Thanks :) That works indeed!

    Another valuable lesson :)

    • 0
    Posted

    Can we turn this the other way?

    I have a Raspberry PI collecting data from a Zehnder WHR 930 Luxe ventilation unit.

    the PI has also to send setpoint data to the WHR 930.

     

    How to connect the PI to the HC2 and where to put the initiative.

    possibility 1. the HC2 is the master and retrieves data from and sends data to the PI

    Possibility 2. the PI is the master and sends data to global variables in the HC2 and reads another global variable from the HC2

     

    what is the easiest way to set this up?

    • 0
    Posted

    @robd,

    Well normaly it's done by possibility 1.

    I have experience with this from Fibaro, Control4 and Neets. PI is somethink in the middle of Ventilation or Controller. It same like with Global Cache (even if it's moreless 1-way control). You have something in the middle.

     

    For example some time ago i was with colleague supporting one project with Neets and Atrea ventilation unit.

    Neets sets setpoint with HTTP protocol to PI and PI converts it to Modbus TCP and sends it to ventilation unit.

    I would done same with Fibaro and it could even work with HCL.

    • 0
    Posted
    23 hours ago, jakub.jezek said:

    @robd,

    Well normaly it's done by possibility 1.

    I have experience with this from Fibaro, Control4 and Neets. PI is somethink in the middle of Ventilation or Controller. It same like with Global Cache (even if it's moreless 1-way control). You have something in the middle.

     

    For example some time ago i was with colleague supporting one project with Neets and Atrea ventilation unit.

    Neets sets setpoint with HTTP protocol to PI and PI converts it to Modbus TCP and sends it to ventilation unit.

    I would done same with Fibaro and it could even work with HCL.

    @jakub.jezek

    Thanks.

    Yes the PI is in between ventilation unit and HC2 controller.

    The ventilation unit only supports RS232 with its own protocol.

    HC2 does not support RS232 so I use the PI as level and protocol converter to HTTP

    • 0
    Posted

    @robd,

    For IP ro RS232, you can do it with Global Cache, that i think is more suitable for this.

    • 0
    Posted

    I have my PI running now and I want to check the connection between the PI and the HC2

    I am running the LUA code

    Please login or register to see this code.

    the result is:

    attempt to index global 'Net' (a nil value)

    apparently the Net.FHttp call returns a nil value

    do I have to install an API to run this?

    • 0
    Posted (edited)
    On 29.04.2017 at 5:10 PM, robd said:

    I have my PI running now and I want to check the connection between the PI and the HC2

    I am running the LUA code

    Please login or register to see this code.

    the result is:

    attempt to index global 'Net' (a nil value)

    apparently the Net.FHttp call returns a nil value

    do I have to install an API to run this?

     

    If honestly very strange as for me (when I was stared at first time develop LUA scripts for FIBARO), but please, remember some basic functions / methods in FIBARO LUA script have differen notation/ calls in Scenario and VIrtual Devices. 

     

    Please login or register to see this code.

    For VD
    And for scenes should look like 
    --[[
    %% properties


    %% globals
    --]]
    local http = net.HTTPClient()  
      http:request('https://maker.ifttt.com/trigger/{event}/with/key/{cencored}', {
          success = function(resp)
            if resp.status == 200 then
              fibaro:debug(resp.status)
              
            else
              fibaro:debug(resp.status)
           
            end
          end
        })
     
     
     
     
    Edited by 10der
    • 0
    Posted
    On ‎4‎/‎11‎/‎2017 at 9:57 PM, jakub.jezek said:

    @3JL and @10der, DoorBird can run a scene in Fibaro, why not to use it?

     

    Loop in VD runs every 3 seconds. Tested on very small code.

     

    It can be done by following command (example for doorbell):

    http://<deviceip>/bha-api/notification.cgi?url=http:/HC_IP/api/scenes/ID_SCENE&user=username&password=password&event=doorbell&subscribe=1

    or

    http://<deviceip>/bha-api/notification.cgi?url=http:/username:password@HC_IP/api/scenes/ID_SCENE&user=&password=&event=doorbell&subscribe=1

    Hi,

    I have followed your instruction to subscribe to the dooropen event using the Notification.cgi command. I can see the JSON content that the subscribe is already =1. When I click on the DoorOpen button in the DoorBird App, I can see the message OK but the door is not open. When I manually execute the subscribed url -

    Please login or register to see this link.

    Please login or register to see this link.

     in the browser, it works. Hope you are able to advise what went wrong?

    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.

    ×
    ×
    • Create New...