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

Lua code with + and -


Question

Posted

I'm a beginner in Lua code and was trying to get data form another system. It is working but with two types it isn't working.

Output from the homewizard system (Solar measurement) is:

"s1":{"po":476,"dayTotal":5.56,"po+":3290,"po+t":"13:07","po-":0,"po-t":"00:01"},

Lua code I have used:

-- assign Homewizard data to Labels 1,2, 3, 4 of virtual device

fibaro:call(163,"setProperty","ui.Label1.value",result.response.energylinks[1].s1.po)

fibaro:call(163,"setProperty","ui.Label2.value",result.response.energylinks[1].s1.dayTotal)

fibaro:call(163,"setProperty","ui.Label3.value",result.response.energylinks[1].s1.po-)

fibaro:call(163,"setProperty","ui.Label4.value",result.response.energylinks[1].s1.po+)

The po and dayTotal are working fine but the po- and the po+ are giving this error:

[ERROR] 22:18:15: line 39: unexpected symbol near ')'

Any suggestions......many thanks

9 answers to this question

Recommended Posts

  • 0
Posted

i am no coder but i reckon try putting a % after the - and + as i think they are special characters

[ Added: 2014-02-17, 22:06 ]

or maybe -- or ++ i can only make suggestions but i have a feeling i might be right about them characters just not 100% sure of the solution

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" />

  • 0
  • Inquirer
  • Posted

    Thanks. Did this with same error as result:

    fibaro:call(163,"setProperty","ui.Label3.value",result.response.energylinks[1].s1.po-%)

    fibaro:call(163,"setProperty","ui.Label3.value",result.response.energylinks[1].s1.%po-)

    And several other options. Any suggestions...

    • 0
    Posted

    I was wondering the same to. Hope somebody knows the solution

    Please login or register to see this image.

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

    • 0
    Posted
    i am no coder but i reckon try putting a % after the - and + as i think they are special characters

    [ Added: 2014-02-17, 22:06 ]

    or maybe -- or ++ i can only make suggestions but i have a feeling i might be right about them characters just not 100% sure of the solution

    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" />

    % would go before

    + and - are used as special chars in string patterns so you do need to escape

    • 0
    Posted

    % would go before

    + and - are used as special chars in string patterns so you do need to escape

    The % before the + or - does not work unfortunately.

    • 0
    Posted

    I'm using this function to update a label. It works well for me but I haven't tested with your strings. Give it a go:

    Please login or register to see this code.

    • 0
    Posted

    It looks impressing but i really don't have a clue where to put the code.

    Can you point me out into the right direction? here is my code:

    Please login or register to see this code.

    • 0
    Posted
    It looks impressing but i really don't have a clue where to put the code.

    Can you point me out into the right direction? here is my code:

    Please login or register to see this code.

    might be closer

    • 0
    Posted

    See now that you also need to escape a plus sign (which is allowed in URLs). You mentioned you already tried escaping it but give robmacs code a go. I think it should work.

    Also check if you get any debug messages. Is it the assigning of the labels that fail?

    Otherwise try using the local vars when updating the globals and/or labels.

    Inspect the local vars. fibaro:debug()

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