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

Creating scene without using browser


Question

Posted

Hi guys,

 

Want to ask that if I setup a web server on raspberry pi, want to ask that is it possible to use only coding and http command to create new scene in Fibaro?

Or we must create scene in Fibaro platform first, then only we can use the api to communicate?

11 answers to this question

Recommended Posts

  • 0
Posted

its possible create scene via API. The command is:

HTTP POST on adres http://HC2IP/api/scenes

Authentication BASIC

Response Content Type: application/json 

and in body you send this:

Scene {
id (integer, optional),
name (string),
type (string, optional),
roomID (integer, optional),
iconID (integer, optional),
enabled (bool, optional),
autostart (bool, optional),
protectedByPIN (bool, optional),
killable (bool, optional),
runningInstances (integer, optional),
visible (bool, optional),
isLua (bool, optional),
lua (string, optional),
properties (string, optional),
liliStartCommand (string, optional),
liliStopCommand (string, optional),
html (string, optional),
triggers (Triggers, optional),
sortOrder (integer, optional)
}
Triggers {
properties (array, optional),
globals (array, optional)
}

 

Note: triggers is written two time in 'triggers'  and on begin of  lua code --[ [ %%

 

example of most importants position in body:

Please login or register to see this code.

 

 

for check creation of scene via api use http://HC2IP/docs or any REST client.

Of course after this is possible to modify scen by api put, by sending body with modified contents of data in {}. All standard operation via api is described in /docs

 

 

  • 0
  • Inquirer
  • Posted

    @drboss

    Thanks drboss! that's very helpful. I'll try that out.

    Since it is using LUA, I guess it is not possible to create scene using API with HCL then?

    • 0
    Posted

    @jamietang, it is the same. Just property "isLua" has to be set to false and "html" property has to be empty. 

     

    But then you can edit that scene only via API.

    • 0
    Posted

    I am very much interested to know the background for this way of creating a scene.

    @jamietangcan you elaborate some more on the reason, why you intend to do it that way?

    • 0
    Posted

    This "workarround" is best if you need adjust scene to works as you need. I would not recommend big scenes in LUA to run in HCL, it could broke. But some little adjusments f block scenes are ok.

    Examples:

    You cannot add in condition if shutter level is below or above some level. So you create a scene and through API you "adjust" it.

    Or you cannot write global variable value into Label through block scene.

    • 0
  • Inquirer
  • Posted
    6 hours ago, jakub.jezek said:

    @jamietang, it is the same. Just property "isLua" has to be set to false and "html" property has to be empty. 

     

    But then you can edit that scene only via API.

    Thanks Jakub! glad to know that it is possible =)

     

    5 hours ago, kunoch said:

    I am very much interested to know the background for this way of creating a scene.

    @jamietangcan you elaborate some more on the reason, why you intend to do it that way?

    It might not be a very common need, I'm trying to create a custom solution/interface so that it is possible to create scene in mobile apps

     

    1 hour ago, jakub.jezek said:

    This "workarround" is best if you need adjust scene to works as you need. I would not recommend big scenes in LUA to run in HCL, it could broke. But some little adjusments f block scenes are ok.

    Examples:

    You cannot add in condition if shutter level is below or above some level. So you create a scene and through API you "adjust" it.

    Or you cannot write global variable value into Label through block scene.

    Is there any limitation like how many scenes created in this way is likely to overload HCL?

    I didnt have time to try it yet, probably will try it during the weekend. Thanks alot for all your input, will update after I tested =)

    • 0
    Posted
    26 minutes ago, jamietang said:

    Is there any limitation like how many scenes created in this way is likely to overload HCL?

    I didnt have time to try it yet, probably will try it during the weekend. Thanks alot for all your input, will update after I tested =)

    I did not found any limitation, yet. But i do not intend to find one. I want my testing HCL to be alive and kicking this heating season.

    • 0
  • Inquirer
  • Posted
    3 hours ago, jakub.jezek said:

    I did not found any limitation, yet. But i do not intend to find one. I want my testing HCL to be alive and kicking this heating season.

    hahaha.. yea of course i would not want to brick my HCL too. May I know how many of these scenes that you have created on your HCL so I can take it as a reference?

    Thanks!

    • 0
    Posted
    2 hours ago, jamietang said:

    hahaha.. yea of course i would not want to brick my HCL too. May I know how many of these scenes that you have created on your HCL so I can take it as a reference?

    Thanks!

    I changed about 20 - 30 scenes in one customers project, because because Fibaro did not have condition for blind level (less than or greater than). 

     

    Allof it was adjustment for blinds to fully close or fully open and to make it on one click of the device via UI.

    • 0
    Posted

    @jakub.jezek I use too this method to personalize and do administration of HCL's  (ex. send log message to remote SQL databases). Its work well with http request without problem.

    • 0
    Posted

    @drboss, if it works it works. But i think some scenes posted on the forum would crush it :D.

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