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

Set the value of a variable via API http command


goose2600

Question

Recommended Posts

  • 0

Yup, you definitely need to send it using a put http request. The http api is get only. What is it you want to change the variable? Is it a web page or a manual update of the value?

Link to comment
Share on other sites

  • 0

@dalle

That is interesting! Do you have an example? Let's say I'm in bash or similar and want to update SOME_VARIABLE on the Home Center; what curl command would you use?

Link to comment
Share on other sites

  • 0

Hi diderik,

You could try something like this:

Please login or register to see this code.

Now, I'm working in php and ofcause the script look different, so I'm not sure if this will work, but it SHOULD. And that is ofcause a PUT method, not a POST method. Sorry for the confusion! I've edited the posts above.

I can upload my php-code later today, if it could be of any help? That works simply by inputing the variable name and desired value as a get method in a browser (by means of a simple link), i.e.:

Please login or register to see this code.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi diderik,

    You could try something like this:

    Please login or register to see this code.

    Now, I'm working in php and ofcause the script look different, so I'm not sure if this will work, but it SHOULD. And that is ofcause a PUT method, not a POST method. Sorry for the confusion! I've edited the posts above.

    I can upload my php-code later today, if it could be of any help? That works simply by inputing the variable name and desired value as a get method in a browser (by means of a simple link), i.e.:

    Please login or register to see this code.

    Hi Dalle,

    I am thinking about using a php server in order to bypass the lack of LUA in HCL.

    I would be very grateful if you will upload your php-code.

    Furthermore, I would auto-disarm Fibaro alarm via Tasker for Android app (instead of using GPS) when arriving at home.

    Someone told me to use a scene to arm/disarm Fibaro alarm, but I can't find the way.

    I just found how to query alarm status via API (

    Please login or register to see this link.

    ) but don't know how to trigger... can you help me?

    Link to comment
    Share on other sites

    • 0

    I'll upload the php-code I'm using later today, but if you can't wait, it can be found in this thread in the zip-package. The file is called globaloutput.php:

    Please login or register to see this link.

    In that file, you can also find some code for how to interact with devices on your home center - both retrieving and sending data.

    Link to comment
    Share on other sites

    • 0

    Hi Goose,

    I also have and HCL so facing similar needs/problems.

    The route I have taken is to have Domoticz in a Raspberry. You can send http commands to it and then it has a module to send variables/commands to the HCL.

    Also with it you can manage RFXCoom compatible devices and link them with virtual devices in HCL.

    It has LUA available. Although I have not use it you could build the logic there and then just update a variable to sent to HCL so a scene is ran.

    Regarding locations I had big issues with Fibaro. Basically in my case it does not update. Only with the GPS itself so does not work indoors...

    What I am using here is Autolocatiin/Tasker and working very well.

    Link to comment
    Share on other sites

    • 0

    What I would like to do, and I think Goose2600 too, is to change a global variable (from the variable panel) with a virtual device. I have a HCL, so that kinda limits the possibilities. Is it possible and how?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi waveuk,

    tonight I installed Domoticz on my Raspberry Pi B+

    Please login or register to see this image.

    /emoticons/default_wink.png" alt=";)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    It looks like a good idea to configure Domoticz as "logic-server" and let it to update variables in HCL.

    @Dalle1985 Wow, I just download the zip file and... what a bunch of script!

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> Thank you.

    @rarev Due to the lack of LUA, it seems we cant execute command from a virtual device.

    Otherwise we could use the PUT method to set global variablese (take a look a this thread

    Please login or register to see this link.

    ).

    A solution to the problem could be to send "command" from a php-server, as Dalle1985 said.

    Anyway, now I know how to set global variables.

    The question is: how to arm/disarm the "Fibaro alarm panel" witch is not a global variable?

    I have not even seen any option among the logic scene "button".

    Link to comment
    Share on other sites

    • 0

    Anyway, now I know how to set global variables.

    The question is: how to arm/disarm the "Fibaro alarm panel" witch is not a global variable?

    I have not even seen any option among the logic scene "button".

    I think you are stuck with the Fibaro app or hack the http-request they use for their app. I've built my own alarm setup to avoid the Fibaro panel. It consists of a triggering scene, and an alarm scene. So basically, you could add as many trigger scenes as you please and then just activate the same alarm scene.

    I do it by changing a global whenever there is an alarm trigger to 1. Then my tablets throughout the house will go into alarm mode and give a high audible alarm and a warning display. The alarm tone will be different whether it be a smoke alarm, a heat alarm, a blackout or a motion/door sensor alarm. It will also inform you of where the alarm has been triggered (i.e. in case of a fire alarm, so you can avoid the dangerous area or approach with caution).

    It has a pin panel for arming/disarming the alarm, supports up to 9 individual users and you can set up custom alarm modes (i.e. one mode for when the dog is home and the motion sensors in the basement shouldn't react and one where all sensors are active). This is the sort of functionality I was expecting from Fibaro, but as they didn't deliver on that and they don't even make their panel easy to operate, I couldn't use it for anything. Only downside to my panel is, that it requires an external web server and a UPS (to avoid the "brains" to be knocked out - but the same is true for the HC2 though).

    [ Added: 2014-07-18, 07:01 ]

    What I would like to do, and I think Goose2600 too, is to change a global variable (from the variable panel) with a virtual device. I have a HCL, so that kinda limits the possibilities. Is it possible and how?

    Should be possible to send a http-request as a string from the virtual device to the scripting server (i.e. the script I suggested goose use) then that http-request will be fed back to your HCL as a PUT request to the global variable which will then update. You could in theory also use an external script as a substitute for the lack of Lua and then build your scenes in i.e. PHP, but a bit of lack must be anticipated compared to running the scenes as Lua on an HC2.

    Link to comment
    Share on other sites

    • 0

    I would like to do this on the hcl itself. Is it possible to run scenes with a virtual device. Then I can use the scenes to set the variable.

    Link to comment
    Share on other sites

    • 0
    I would like to do this on the hcl itself. Is it possible to run scenes with a virtual device. Then I can use the scenes to set the variable.

    Try to send a string using the VD to the ip of your HCL with the text:

    Please login or register to see this code.

    Replace YOURUSER, YOURPASSWORD and FIBARO_IP with the relevant value and the ** with the id of your variable scene. I'm not sure if that will work, but it is the only way to do it using the HCL i gather (the HTTP header might not be entirely correct, but that is my best suggestion).[/code]

    Link to comment
    Share on other sites

    • 0

    Thanks for your suggestion Dalle, but it's not working, i'm afraid. I wish Fibaro would do something about this, because the HCL has terrible software. The virtual device in HCL is useless. But the answer from Fibaro will probably be: "Just wait for the update to 4.0"...

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thanks for your suggestion Dalle, but it's not working, i'm afraid. I wish Fibaro would do something about this, because the HCL has terrible software. The virtual device in HCL is useless. But the answer from Fibaro will probably be: "Just wait for the update to 4.0"...

    It seems someone was able to start or stop scenes through virtual devices on HCL.

    We have to use GET method and Base64 authentication.

    I have not tried yet, but this is the code example for stating scene:

    GET /api/sceneControl?id=XX&action=start HTTP/1.1

    Host: 192.168.x.xxx

    Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxx

    0x0D0x0A0x0D0x0A

    This is the thread on the other forum:

    Please login or register to see this link.

    Link to comment
    Share on other sites

    • 0

    Got this working:

    Please login or register to see this code.

    The problem with the code I provided before was that the fibaro doesn't support public calls, so you need to use basic authentification. Therefore the message you send must include your credentials. Also, you must remember to include the ip in the ip field of the virtual device.

    *** EDIT ***

    Here is a working virtual Device using a GET method. It has a predefined authentification for password and username "admin" (as I gather that is what most is using). If you need another username and password, change the long string called "YWRtaW46YWRtaW4=" with the encoded user and password you'll get by inputting this it in this format:

    user:password

    (i.e. admin:admin) into a base64 encoder like this one:

    Please login or register to see this link.

    this device is set up to trigger scene 30 on ip 10.0.1.4 port 80. Change the values to correspond to your system

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Here is a working virtual Device using a GET method. It has a predefined authentification for password and username "admin" (as I gather that is what most is using). If you need another username and password, change the long string called "YWRtaW46YWRtaW4=" with the encoded user and password you'll get by inputting this it in this format:

    user:password

    (i.e. admin:admin) into a base64 encoder like this one:

    Please login or register to see this link.

    this device is set up to trigger scene 30 on ip 10.0.1.4 port 80. Change the values to correspond to your system

    Hi Dalle,

    usally I active scenes by curl from a Raspberry (curl -u admin:admin 'http://HCL/api/sceneControl?id=1&action=start') but might be useful to use a virtual device.

    I tried both the code and your virtual device export... it should work, but when I click on a button of the virtual device: nothing happens!

    Of course I changed HCL IP and sceneID (my password is admin too) and filled the ip field via web interface.

    Does not work even if I check "Wait for device response".

    Did I forgot something?

    Link to comment
    Share on other sites

    • 0

    And you changed the ip both in the button code and in the ip line in the start of the virtual device? Also check that port number is set at 80.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • And you changed the ip both in the button code and in the ip line in the start of the virtual device? Also check that port number is set at 80.

    Yes, I did it (img attached).

    It is very strange... Later I will try to route the request to an apache server, just to check what my HCL is sending out.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    This is strange indeed... Have you tried sending the same request from an http editor to check the response? It works flawlessly on my HC2...

    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.

    ×
    ×
    • Create New...