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

Possibility to interpret XML response


Question

Posted

Hello fellow community!

Want to ask question, maybe someone can point me to the right direction.

I have Trendcontol HVAC controller with possibility to respond to sensor status/value requests. The result is XML.

Let's say, i make GET request:

Please login or register to see this link.

as a result i got:

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- written by IQ4E32 Iss3.44 Jan 16 2017 Saved 2018-3-29T16:27:59TZD -->
<TrendProject>
  <Site CncAddress="9" TuaString="T/IQ3 - 00:10:70:XX:XX:XX/TCP,,,XX.XX.XX.XX,10009///1/1/">
    <Lan IsLocal="True" LanNumber="1">
      <Device DeviceNumber="1" VersionString="IQ4E32 Iss3.44 Jan 16 2017">
        <DeviceOverview DeviceType="q" MajorVersion="3" MinorVersion="4" HexEncoded="711B1B1B41333434" Revision="4"></DeviceOverview>
        <Module Name="S4" SubTypeNumber="-1">
          <Param Name="V" Type="1" Value="3.044735" />
        </Module>
      </Device>
    </Lan>
  </Site>
</TrendProject>

 

where i'm asking controller to give me S4 sensor value, which is outside temperature.

Is there are any possibility to decode this XML string with HC2? Any directions to dig about XML to JSON decoders written in LUA?

Any help will be appreciated!

5 answers to this question

Recommended Posts

  • 0
Posted

Hi!

 

Fibaro does not allow use external libs. Also, Fibaro not provides native XML lib for use.

for parsing simple XML I used: 

Please login or register to see this code.

 

for example

Please login or register to see this code.

 

but in your sample, we have value in the attribute.

it's hard. 

 

ok.

 

 

 

Please login or register to see this code.

here is result

Please login or register to see this image.

 

 

 

  • 0
Posted

UPDATE:

 

Please login or register to see this code.

Please login or register to see this code.

Please login or register to see this image.

  • 0
  • Inquirer
  • Posted

    Oho! You are my hero!

    Will spent weekend to parse you code in my head :)

    Thanks a lot!

    • 0
    Posted

    @AlexRiga welcome,

    Obraschaisa! Pomogu! :)

    • 0
    Posted (edited)

    Hi,

    I was trying to read values using your code, but I was unsuccessful could you please help me with this?

     

    from page: http://10.0.0.12/meas.xml

     

    <meas><I1><P>-0.57</P></I1><I2><P>-0.51</P></I2><I3><P>-0.40</P></I3><I4><P>0.59</P><E>1014.27</E></I4><I5><P>0.00</P><E>0.00</E></I5><I6><P>0.00</P><E>0.00</E></I6><I7><P>0.00</P><E>0.00</E></I7><O1><A>0</A><P>0.00</P><E>0.03</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O1><O2><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O2><O3><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O3><O4><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O4><O5><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O5><O6><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O6><O7><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O7><O8><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O8><O9><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O9><O10><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O10><O11><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O11><O12><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O12><O13><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O13><O14><A>0</A><P>0.00</P><E>0.00</E><HN>0</HN><HC>0</HC><HE>0</HE><HR>0</HR><T>0</T></O14><DQ1>0.0</DQ1><DQ2>0.0</DQ2><DQ3>0.0</DQ3><DQ4>0.0</DQ4><PPS>-1.48</PPS><VAC>230</VAC><DaR>20.3.2019</DaR><TiR>8:21:04</TiR><CW>6422</CW><FW>1.4</FW><SN>46000174</SN><EL1>0</EL1><ETS>0</ETS><ILT>0</ILT><ICW>0</ICW><ITS>0</ITS><IDST>0</IDST><ISC>0</ISC><SRT>6:03</SRT><DW>2</DW></meas>

     

    I need values

    <I1><P>-0.57

    <I2><P>-0.51

    <I3><P>-0.40

     

    Thank you

     

    Edited by atycz

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