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


Question

Posted

Hi

 

I have built an integration engine between DSC alarms and HC2. In later releases I have built in autocreation of needed global variables to make it easier to start using it and maintain the DSCengine integration VD service.

 

Question....

 

I have a presentation VD used in iOS devices and now wonder if it is possible to also autocreate VD labels from lua in any way. It seems it is not possible due to std docs and REST API. Any input regarding this appreciated.

 

Tnx

Peo

12 answers to this question

Recommended Posts

  • 0
Posted

Hi @pos,

 

What do you mean by auto creation of labels? Adding and deleting them on the go or changing their captions?

  • 0
  • Inquirer
  • Posted

    I was talking about creating and deleting the VD labels itself, and not the values you write to them.

     

    I also wanted to create whole VDs automatically from LUA. This is now accomplished as I posted here:

    Please login or register to see this link.

    I found that possible yesterday. Seems faulty documented by Fibaro. So I assume I also can create the labels I need automatically.

     

    I want my HC2 <-> DSC alarm integration engine to:

    Automatically create all global variables it need to function.  (Check ok since a week back in my DSCengine version 1.14)

    Automatically create all VDs in needs to function (I know how to do that now, but it was not documented. Vill be implemented soon)

    Automatically create all needed VD labels for the service to function (This is probably easy now with the current info I have. Vill be implemented soon)

     

    This will make it a lot easier to use this service as a better substitute for the existing DSC or Envisalink plugins. Today my DSCengine works great but requires a few manual steps to create VDs, labels etc first. But I want the DSCengine to setup itself and decrease the need for a huge documentation. 

     

    Peo

    • 0
    Posted

    Hi @pos,

     

    Label caption is one thing and value is another thing. Caption is fixed text or name that is given when label is created while value is something that it shows and can be changed with single line of Lua code.

     

    What I'm trying to achieve is to make distribution of VD easy. At the moment I achieved to make predefined global variables that can contain predefined values or table with help from members of this forum. Also I can translate them to 24 different languages on the go so users don't have to bother with making globals anymore. Also I manage to get VD label and button captions to be translated to selected language on HC. I have VD that can be used to set VD's icons, not only main icon, but all necessary icons for that VD if icons are used to show some different states.

     

    Next step is to make everything downloadable to HC from some internet server and that is something I have to work on in future. I have my website, but I need to learn how to set it up and manage it. Then hopefully I will be able to put everything there and find a way how to distribute VD's and scenes by downloading them directly to HC.

     

    So, if you are able to create new VD from LUA, then should not be difficult to get json for that VD, rearrange rows and columns of labels and buttons and then write it back?

     

    Can I kindly ask you to share code that you use to create new VD from LUA?

    • 0
  • Inquirer
  • Posted

    @Sankotronic

     

    As said.. I have auto creation of global variables ok already in my stable code for DSC alarm integration. Auto creating the VDs is something I am testing. Therefor I only have a few lab chunks of code for it. If I give it to you, you maybe can help me solve how to add labels through lua :).  That actually seems like a bigger problem than I thought... I can create labels as well, but the VD pick default names for the labels even though I have specified it myself. I will also in the long run try to download and install icons to the VDs automatically. If you have code for that, I would very much appreciate if you shared it... Then I  can maybe save some time...

     

     Note the code is just small lab/test pieces that can be pasted and run in an arbitrary VD. It work though....

    Please login or register to see this link.

     

     

    When I fully can handle auto creation of VDs and its labels and icons I will update my released DSC integration code that other people currently use.

     

    • 0
    Posted

    Hello @pos,

     

    I have good news for you. Attached code is adding VD with labels, sliders, buttons and even LUA code! I change code a bit so after VD is added you can still use same code to change VD. You can add, or delete labels, sliders and buttons when changing VD, you can change captions. LUA code that you want to add with VD you can copy/paste from HC docs, also label, slider or button formatting you can copy from there but then you need to change formatting as it is in attached example!

     

    Code that you use I already get from A.Socha and I use it to change captions of labels, sliders and buttons, but it can be also used to add VD or change its configuration! Just remember, you have to refresh web GUI interface page or network data on mobile applications after adding or changing VD to see it.

     

    Here is experimental code that is working:

     

    Please login or register to see this attachment.

     

    I didn't clean code so there is one label, one slider with code from Philips HUE VD and one button that has some short code just for test.

     

    Enjoy coding! :-) 

    • 0
  • Inquirer
  • Posted
    13 hours ago, Sankotronic said:

    Hello @pos,

     

    I have good news for you. Attached code is adding VD with labels, sliders, buttons and even LUA code! I change code a bit so after VD is added you can still use same code to change VD. You can add, or delete labels, sliders and buttons when changing VD, you can change captions. LUA code that you want to add with VD you can copy/paste from HC docs, also label, slider or button formatting you can copy from there but then you need to change formatting as it is in attached example!

     

    Code that you use I already get from A.Socha and I use it to change captions of labels, sliders and buttons, but it can be also used to add VD or change its configuration! Just remember, you have to refresh web GUI interface page or network data on mobile applications after adding or changing VD to see it.

     

    Here is experimental code that is working:

     

    Please login or register to see this attachment.

     

    I didn't clean code so there is one label, one slider with code from Philips HUE VD and one button that has some short code just for test.

     

    Enjoy coding! :-) 

     

     

    Now I have tested parts of it... :D Indeed it works!! Now I can automate the last part in my DSC <-> HC2 integration engine. This now means I can create not only global variables and VDs, but also labels from LUA. The missing piece for me (and not documented as most Fibaro stuff)... So within a few days all pieces are in place.

     

    Fibaro has good stuff but the devel docs really s u c k s!

     

    I lift my hat off and say multiple thanks "Sankotronic" !

     

    Peo

    • 0
    Posted
    6 hours ago, pos said:

    Fibaro has good stuff but the devel docs really s u c k s!

     

    Hi @pos,

     

    I totally agree with you. They made really good gateway, but what's use when you have to struggle for over a year time to find out just part of the possibilities. I'm sure there is more to find out, but it is like playing some game, I tell you if you guess it first :-P 

     

    6 hours ago, pos said:

    I lift my hat off and say multiple thanks "Sankotronic" !

     

    I thank you for asking i sharing code that was almost done and needed just little modification! Team work! I like that! Thanks!

     

    Enjoy coding! :-) 

    • 0
  • Inquirer
  • Posted (edited)

    @Sankotronic While we are on the VD and label subject...

     

    You do not happen do know if it is possible to put a status icon instead of a value on al label to present on the VD in the webb/app gui. Asking as I think of a possibility to present two different icons in the gui instead of two different text values (breached restored, ON OFF, TRUE FALSE).... 

     

    If I for example have:

     

    fibaro:call(PRESENTERDEVICE, "setProperty", "ui.STATUS.value", arm_data)

     

    And want arm_data to actually show a "disarmed" icon instead of a DISARMED text as I have now. This is what is looks like today so it is easier to understand what I think of...

    Please login or register to see this image.

     

    Peo

    Edited by pos
    • 0
    Posted

    @Sankotronic

     

    do you know how to create empty virtual device in scene?

     

    I have tried:

      local result = api.post('/virtualDevices', '{"name":"'..vd_name..'","type":"virtual_device"}')

     

    but it doesn't work ...

     

     

     

    • 0
    Posted (edited)
    2 hours ago, petrkl12 said:

    @Sankotronic

     

    do you know how to create empty virtual device in scene?

     

    I have tried:

      local result = api.post('/virtualDevices', '{"name":"'..vd_name..'","type":"virtual_device"}')

     

    but it doesn't work ...

     

    api.post takes a table, not a json-string

    This works for me. Note that you get an id assigned to it. (and it doesn't work in the emulator yet)

    Please login or register to see this code.

     

    Edited by jgab
    • 0
    Posted

    Thanks, This works after small correction:

     

    Please login or register to see this code.

     

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