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

Simple xml readout


Question

Posted

Hi all, i basicly want some value's from an xml output into a virtual device. I've seen some examples here and there but most seem to be either to big or complex or it tells you to convert xml to json via another webserver (which i dont want)

In the end i get this back from the device:

Please login or register to see this code.

Which in xml terms is:

Please login or register to see this code.

The keyname can be different and/or have more lines like that. So i will only grab the lines i do have and say if "Toestelstatus" = "Klaar" then set other values to empty.

Does anybody have a simple example on how to get those things without getting to fancy?

Thanks,

Erik

Recommended Posts

  • 0
  • Inquirer
  • Posted

    Please login or register to see this code.

    In this example i check if the errorcode is not 0, also i check if the status of the http query is 200 to make sure it wont fail. I assume its just lua, but if you debug a null value it will just stop the complete routine. (no room for on error continue it seems)

    I created global variable, and now when the washing machine is finished it will set the virtual device to "Kreukbeveiliging" which means "no wrinkles protection" it will stay that way for some time, so the timer then starts adding +1 untill it reaches 600 (i assume it runs every second or so) which is 10 minutes.

    Anyways, now my wife gets a message on her phone after 10 minutes if she didn't hear/forgot to take out the laundry

    Please login or register to see this image.

    /emoticons/default_wink.png" alt=";)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    If you know a better way or see room for improvement in the current code then let me know since i also just started ;p

    • 0
    Posted

    Hi @riemers

     

    I came across your code while looking for a way to read xml from a website. I am a complete novice, so I hope you can help me a bit modifying your code.

    Basically I need to read lines from an xml that is called /Web0/data/werte8.xml, and has datalines like:

    <PARAMETER>
    <LANG>de</LANG>
    <ID>v00101</ID>
    <VA>0</VA>
    <ID>v00102</ID>
    <VA>2</VA>
    <ID>v00094</ID>
    <VA>1</VA>
    <ID>v00099</ID>
    <VA>0</VA>
     
    All I need is to find an ID and read the number. You can actually see the file at: 

    Please login or register to see this link.

    . This is a Helios air exchanger. They have a demo web at 

    Please login or register to see this link.

     
     
    I have copied your last code in a new virtual device, entered the IP, and I suppose I have to do this:
        response, status, errorCode = MIELE:GET("/Web0/data/werte8.xml")
    but after that I am pretty stuck. 
     
    if you can give any pointers i'd be grateful.
     
    • 0
  • Inquirer
  • Posted

    The part that does the matching is

    Please login or register to see this code.

    So in your case you could try and change "Toestelstatus" to "ID" but since you have multiple id's that might go bad too.

    • 0
    Posted

    Guys,

     

    reading this thread woth interest, maybe you can help me out.

    I have a webpage returning this: (from status.xml)

     

    <response>
    <relay0>0</relay0>
    <relay1>0</relay1>
    <relay2>0</relay2>
    <relay3>0</relay3>
    <relay4>0</relay4>
    <relay5>0</relay5>
    <relay6>0</relay6>
    <relay7>0</relay7>
    <volts>12</volts>
    </response>
     
    So I thought, easy, when reading thos thread to get the relay value, put it in a variable and display it on the VD.
    However, I don'd get it working (but also no errors) code is now:
     

    local _deviceIp = fibaro:get(fibaro:getSelfId(), "IPAddress");
    local _devicePort = fibaro:get(fibaro:getSelfId(), "TCPPort");
    HTTP = Net.FHttp(_deviceIp, _devicePort);
    HTTP:setBasicAuthentication("admin", "password") 

    --Schakel relais3 uit
    response, status, errorCode = HTTP:GET('/io.cgi?DOI3')

    --Zet zonewaarde op uit
    fibaro:call(1118,"setProperty","ui.zonestatus.value","Uit")

    --schakel pomp uit--

    fibaro:call(1114, "turnOff")


    --Test, probeer relais status uit te lezen....
    response, status, errorCode = HTTP:GET('/status.xml')
    local schakel5 = response:match([[name="relay5" value="(.-)"]])
    fibaro:call(1118, "setProperty", "ui.hoofdafsluiter.value", schakel5);
    fibaro:debug(schakel5);

     

     

    The name of the label is "hoofdafsluiter"

    Hope someone can help me out here....

     

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