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


Fibaro virtual device Xml read


pepijn

Recommended Posts

  • Topic Author
  • 3 minutes ago, jgab said:

    What kind of error? It still seems like what you get is not what you had in your first example. 

    Can you do this to print the xml data? 

    Please login or register to see this code.

     

    1

    This is what i get i have pasted the debug for line 34  but is'nt giving me any thing to show 

    Please login or register to see this image.

    /monthly_2019_02/image.png.d14c91288043c714a91d387cbff1597d.png" alt="image.png.d14c91288043c714a91d387cbff1597d.png" />

    Link to comment
    Share on other sites

    What error message did you get on line 33 the

    Please login or register to see this code.

    line?

    Link to comment
    Share on other sites

  • Topic Author
  • 3 minutes ago, jgab said:

    What error message did you get on line 33 the

    Please login or register to see this code.

    line?

    see picture above that is the error it is given me  back

     

    this is my code  what i have right now 

    Please login or register to see this code.

     

    Edited by pepijn
    Link to comment
    Share on other sites

    If I copy the code in the previous post and past it into a new post (inside code tags <>), I get a little red dot just before the 'repeat' command. Try to copy the previous post onto a new post and see for yourself. These are "invisible" characters that seems to sneak into the code when copied and pasted in the forum - they don't show but gives compile error - or even worse runtime error. I have tried to clean it in the code below. Try to copy it and see if it works. 

    Please login or register to see this code.

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • still the same error. 

    i know what you mean with the litle red dots . (which i always remove and than the code is still the same) 

    Link to comment
    Share on other sites

    But it's a compile time error (when you save the VD) or a runtime error when you run the code?

    The 'getSelfId()' seems to be related to your first line? Line numbers for error can be strange...

     

    Link to comment
    Share on other sites

  • Topic Author
  • Just now, jgab said:

    But it's a compile time error (when you save the VD) or a runtime error when you run the code?

    The 'getSelfId()' seems to be related to your first line? Line numbers for error can be strange...

     

    it is a runtime error only when i run the code i get that error.

    (when i removed  the function from the xml than the error is gone. the text getSelfId() is not the error because that is working perfectly 

    Link to comment
    Share on other sites

    We have a mystery. If I take exactly this code and paste it into a VD button and run it 

    Please login or register to see this code.

    I get this output (I don't have an IP address set)

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    14 minutes ago, jgab said:

    These are "invisible" characters that seems to sneak into the code when copied and pasted in the forum

    I think it started after a recent forum upgrade. If you look at it in HEX they'll probably show up as invalid UTF8

     

    I recently pasted one of my own code snippets from the forum in Zerobrane and got an error ending in:

     

        ... expected near '<\239>'

     

    \239 == 0xFE

     

    Otherwise this is pretty invisible. It's very annoying.

     

    The source of the code on my system is OK, It happens either when you paste code on the forum, or copy code from the forum to your system.

     

    @T.Konopka as a forum admin, would it be possible to check if the forum software could be the cause of those random invalid characters?

    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • 13 minutes ago, jgab said:

    We have a mystery. If I take exactly this code and paste it into a VD button and run it 

    Please login or register to see this code.

    I get this output (I don't have an IP address set)

    Please login or register to see this code.

     

    Same as you with this code i have no problems ....  there is something wrong by getting the XML...   and i don't know what it is..

    but i know right now that the error I have got was because it cant find ny xml or some thing like that..

    Edited by pepijn
    Link to comment
    Share on other sites

  • Topic Author
  • @jgab  do i have to specify anything in my get command for getting an XML.

    and when i try to read more data out of the XML (with your last code) "when the XML is in a Variable"  it isn't showing.

     

    lets say i wanted to read out the  TYPE and Preset 

    i would think i have to code it like this but it isn't showing

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    5 minutes ago, pepijn said:

    @jgab  do i have to specify anything in my get command for getting an XML.

    and when i try to read more data out of the XML (with your last code) "when the XML is in a Variable"  it isn't showing.

     

    lets say i wanted to read out the  TYPE and Preset 

    i would think i have to code it like this but it isn't showing

    Please login or register to see this code.

     

     

    Yes, you just need to add the extra formatting directives to the string.format

    Please login or register to see this code.

     

    Edited by jgab
    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • So i can set now  variables to it or is it not possible like this? because now NAAM is not printed out

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    1 minute ago, pepijn said:

    So i can set now  variables to it or is it not possible like this? because now NAAM is not printed out

     

    Please login or register to see this code.

     

     

    locals have scope only within the for loop,  declare them before and it works.

    So, the fibaro:debug in VDs is sensitive both to strings that look like html tags and very long strings (> 1300..).

    If I do like this I can dump the xml string in the VD debug console (have to exchange '<' with '@')

    It can be useful if you want to see what you get

    Please login or register to see this code.

     

    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this code.

    oke so i have found where it is going wrong but  i dont know how i can fix it.

    The code give a error on line 35   that is : txt = txt:sub(#st+1)

     

    Please login or register to see this code.

    Edited by pepijn
    Link to comment
    Share on other sites

    6 minutes ago, pepijn said:

    Please login or register to see this code.

    Please login or register to see this code.

    oke so i have found where it is going wrong but  i dont know how i can fix it.

     

    Good detective work! Change the debug line to this and we can see what we stumble on

    Please login or register to see this code.

     

    Can you also do this to log the whole xml text

    Please login or register to see this code.

     

    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • @jgab like this ?

    Please login or register to see this code.

     

    Edited by pepijn
    Link to comment
    Share on other sites

    Like this

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • I wil get than this :

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Ok, try this

    Please login or register to see this code.

    Two things changed - allow for both single quote and double quote as string delimiters in properties. Handles extra chars (spaces, crlf) at end of string. Hope there are no red dots...

    Edited by jgab
    Support for comments
    • Thanks 1
    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
    Reply to this topic...

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