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

Beta API - http Commands (3.341)


Question

Guest deraaij
Posted

Hi all,

Just to share for those who did not figure it out already, the following http commands work with the beta version:

Devices:

ID = device ID

name = action

arg1 = (e.g. value dimmer)

http:///api/callAction?deviceID=4&name=turnOff

http:///api/callAction?deviceID=7&name=setValue&arg1=39

Virtual Devices

ID = device ID

arg1 = button ID

arg2 = slider value (only for slider)

http:///api/callAction?deviceID=15&name=pressButton&arg1=2

http:///api/callAction?deviceID=51&name=setSlider&arg1=8&arg2=30

Notification

ID = Device (Iphone, e-mail et cetera)

arg1 = Notification template

http:///api/callActiondeviceID=9&name=sendDefinedPushNotification&arg1=1

Arm/Disarm devices

arg1 = 1 - Armed

arg1 = 0 - Disarmed

http:///api/callAction?deviceID=51&&name=setArmed&arg1=0

Scene

ID = SceneID

http:///api/sceneControl?id=14&action=start

http:///api/sceneControl?id=14&action=stop

Get json status from api:

http:///api/rooms

http:///api/scenes

http:///api/devices

http:///api/devices?id=316 # Specific value of a device

http:///api/virtualDevices

http:///api/globalVariables

http:///api/weather

http:///api/sections

http:///api/users

http:///api/energy/now-3600/now/single/devices/power/58

Updates used by mobile:

http:///api/mobile/interface/refreshStates?last=3058

Reboot:

Post --> http:///api/settings/reboot

etc.

change variabele example:

Unfortunately will not trigger scene (yet):

Please login or register to see this code.

Regards,

Mark

Recommended Posts

  • 0
Guest deraaij
  • Inquirer
  • Posted
    Ok, this documentation is fine and help a lot.

    Unfortunatly I'am trying to "set" a value for a property of a device (a everspring st814), but it does not work, if anyone has a idea, I would appreciate. Id 27 = temperature sensor

    What I'm trying :

    curl -X GET "http://admin:[email protected]/api/callAction?deviceid=27&name=setProperty&name=userDescription&value=test"

    doest not work, neither

    curl -X GET "http://admin:[email protected]/api/callAction?deviceid=27&name=setProperty&arg1=userDescription&arg2=test"

    If you know how to do it in LUA I will take also, it drive me mad !!!

    Thanks,

    You need to use:

    Please login or register to see this code.

    • 0
    Guest Charly86
  • Inquirer
  • Posted

    Mark,

    thank you, it works like a charm, thank !!!

    May I ask how to do the same thing in LUA ?

    Please login or register to see this image.

    /emoticons/default_icon_redface.gif" alt=":oops:" />

    regards,

    • 0
    Posted

    Not tested!

    Please login or register to see this code.

    • 0
    Guest deraaij
  • Inquirer
  • Posted

    Please login or register to see this code.

    updated: oops someone beat me too it.... (tested)

    • 0
    Guest Charly86
  • Inquirer
  • Posted

    Hi guys,

    thanks for your replies

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

    Does the code you just wrote is equivalent to this one ? (just to avoid http request)

    fibaro:call(27,"setProperty", "userDescription", "testing")

    • 0
    Guest deraaij
  • Inquirer
  • Posted

    I think that currently only works for user interface (ui) changes for virtual devices.

    • 0
    Posted

    Where does the user description get used?

    • 0
    Posted

    Anybody knows when changing a global variable using http API will be able to trigger a scene???

    Seems that only doing fibaro:setGlobal(varName, value) is able to trigger the scene

    • 0
    Posted

    Someone asked about updating global vars in C. Be sure to compile with curl. E.g.:

    Please login or register to see this code.

    Just got this snippet working:

    Please login or register to see this code.

    • 0
    Posted

    Main problem is how to create any BAT file or any other application which can send HTTP request towards FIbaro

    Try CURL for Windows.

    Download it here

    Please login or register to see this link.

    Then use bat file as following:

    Please login or register to see this code.

    [ Added: 2014-01-03, 02:53 ]

    ==============================================

    Could please anybody help me with bookmarklets?

    I am using Chrome (31 version) and want to send something like

    Please login or register to see this code.

    to turn on lights.

    I can do it from bookmark, I can do it from BAT file, I can do it from direct input URL in address line. But I can't get to work in JS, since Chrome forbids "basic authentication" in JS since 19 version.

    My code is

    Please login or register to see this code.

    But I get 405 response code and then message about

    Please login or register to see this code.

    They are try to prevent some "XSS" hack attacks, I assume

    The only page where this code is working good is fibaro HC2 page. (no XSS in such case).

    How can I overcome that? Or is it limits of HC2?

    • 0
    Posted

    I guess the problem is your browser, which is not allowing cross-domain request?

    Please login or register to see this link.

    • 0
    Posted

    rantta,

    Thanks, I've quite solved my problem.

    Please login or register to see this code.

    This code is working, by means it turns off lights.

    And does it on current page, as good bookmarklet do.

    " xmlHttp.withCredentials = true" is a key.

    But still kind of error exits: Last alert doesn't run, since there is an fatal error after line "xmlHttp.send()". "No 'Access-Control-Allow-Origin' header is present on the requested resource".

    • 0
    Guest merylion
  • Inquirer
  • Posted

    Hello,

    Someone before told that it is not possible to set global variable with http get request.

    Now I am playing with tasker and I see that POST is supported over there

    Does anyone know if it is possible in tasker?

    Thanks

    Marcin

    [ Added: 2014-03-12, 09:21 ]

    Hi,

    I am litle bit back on track,

    There is plugin in Tasker called RESTask which can perform PUT request allowing to change global variable value,

    In the first post there is link which sends back all global variables JSON data,

    http:///api/globalVariables

    Anyone knows how to get only one global variable status?

    http:///api/globalVariables?id="test" does not work

    Regards

    Marcin

    • 0
    Posted

    Did anyone solve how to set variables using api?

    Will they variables trigger a scene upon change?

    • 0
    Guest deraaij
  • Inquirer
  • Posted
    Did anyone solve how to set variables using api?

    Will they variables trigger a scene upon change?

    In the first post is an example on howto set variables. Unfortunatly there is still a bug which prevents scenes from triggering if they are updated via the api.

    Method: PUT

    URL:

    Please login or register to see this link.

    <>/api/globalVariables

    Content: {"name": "Test", "value": "122"}

    • 0
    Posted

    looking for an API equivalent of fibaro:log() for virtual devices to put a quick status line at the bottom of the device box. Anyone found that?

    btw these can be added to the front page:

    Retrieve short list of change/updates as the mobile app does

    GET /api/mobile/interface/refreshStates?last=3058

    Reboot

    POST /api/settings/reboot

    • 0
    Guest deraaij
  • Inquirer
  • Posted

    done

    • 0
    Posted

    Hi

    Posting this as may (or may not!) be help to someone.

    Got Javascript ajax calls working without error via jquery.

    Many thanks to Alex57 for starting the process and have been using his method.

    But after moving/adding jquery for other reasons found a standard jquery ajax PUT via jsonp completed without error. (Jsonp manages the cross-domain I believe)

    Probably could add headers to authorisation also - but have bothered as yet - (Edit:Nope JSOP doesnt do headers).

    Does help simplify the code as that previous error killing the function was annoying and needed to be worked around.

    Please login or register to see this code.

    • 0
    Posted
    Hi

    Posting this as may (or may not!) be help to someone.

    Got Javascript ajax calls working without error via jquery.

    Many thanks to Alex57 for starting the process and have been using his method.

    But after moving/adding jquery for other reasons found a standard jquery ajax PUT via jsonp completed without error. (Jsonp manages the cross-domain I believe)

    Probably could add headers to authorisation also - but have bothered as yet.

    Does help simply the code as that previous error killing the function was annoying and needed to be worked around.

    Please login or register to see this code.

    This will not work if you'er trying to get data from the API since it dosen't support JSONP.

    • 0
    Posted

    Thanks.

    Javascript Cross-domain issues are somewhat of a pain!

    None-the-less this JSOP does call the api across domains without problems or errors - so solves half the problems.

    Good to know re: data from API as would have wasted a lot of time.

    Probably will end up with server-side PHP via curl delivering data when get to that stage.

    Glenn

    Guest
    This topic is now closed to further replies.
    ×
    ×
    • Create New...