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

[SOLVED] How to change caption text of buttons and labels in virtual devices


Sankotronic

Question

Hello everyone!

 

I'm working on solution that should bring easier sharing and installation of scenes and virtual devices for users. What I'm missing is a way how to change button and label 'Name' or 'caption' using LUA code and/or REST API. See picture bellow:

 

 

 

@T.Konopka,

 

Please if you know answer to this question can you share it, or of it is not possible with latest version 4.120 can this be added to the todo list for some future release?

Really appreciate your help!

 

Sincerely Sankotronic

 

EDIT

 

This is solution to the question provided by @A.Socha:

Please login or register to see this code.

After changing label, slider or button caption please refresh HC web GUI interface page and do Refresh Network data on mobile devices to make change visible!

 

Edited by Sankotronic
Attachment quota filled up / deleting older stuff sorry :-(
Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

install jsonView

enter to api that VD for example Hc2_ip/api/30

 

on label and button you got property caption, you can use "setproperty" action for that

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • 1 hour ago, A.Socha said:

    install jsonView

    enter to api that VD for example Hc2_ip/api/30

     

    on label and button you got property caption, you can use "setproperty" action for that

     

     

    Hi @A.Socha,

     

    Thank you for the answer but I still don't get it. Is jsonView a computer program? I just have problem with getting syntax for rows and elements. An example would be highly appreciated.

    Link to comment
    Share on other sites

    • 0

    addon for browser who foramat and color json

    Please login or register to see this image.

    firefox

    Please login or register to see this link.

    chrome

    Please login or register to see this link.

     

    how to use setproperty

    setProperty

    Applies to: virtual_device

     

    Description:

    Sets value of the elements of a virtual device (labels and sliders).

     

    Usage:

    This action takes two arguments.

    • The name of the element.
    • The value to set the element to.

     

    Example:

    Please login or register to see this code.

     

     

    Please login or register to see this link.

     

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 4/19/2017 at 5:55 PM, A.Socha said:

    Example:

    Please login or register to see this code.

     

     

    Thank you @A.Socha for quick answer, but I know how to change value of the label. What I need is to change caption (label) of the label and button that is entered here:

     

     

     

    but I need to do that runtime from LUA! Is that even possible to do? I'm trying all day today but no success.

    Edited by Sankotronic
    Attachment quota filled up / deleting older stuff sorry :-(
    Link to comment
    Share on other sites

    • 0

    paste here you json

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • This is json of simple virtual device:

    Please login or register to see this code.

    So, what I need is to change "caption" of label and button. I try to do that with this code:

    Please login or register to see this code.

    but that doesn't work. I need to change buttons and labels caption depending on language selection on HC.

    Link to comment
    Share on other sites

    • 0

    Please login or register to see this code.

    after that refresh page

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thank you @A.Socha very much!

     

    This code works nice! Since I will use it only to setup proper language and that will be done only at first run needing to refresh page or network data in app is not a big deal. But if it could be displayed immediately after changing caption without needing to refresh page or data would be great because that would open some more interesting possibilities.

     

    Link to comment
    Share on other sites

    • 0

    Does someone know how to get # rows in a VD in example belowm

     

    Please login or register to see this code.

    Please login or register to see this code.

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