I'm attempting to build a plug-in that will create a device and extract XML data from an internal web page...very similar to the NOAA plugin, which I'm using as a model. Although the XML data resides on an internal server, it's an embedded device* and I have no control over the data format. I've read the XML DOM documentation and am still lost, but I think I've identified the problem. The problem is that the XML data is formatted differently from the NOAA sites, and I can't figure out how to code the parsing.
I can access the data in two forms:
Code: Select all
<Devices>
<Device Name="Date" Value="12/17/2011"/>
<Device Name="Time" Value="08:37:45"/>
<Device Name="HP_Fan" Value="1.000000"/>
<Device Name="PropaneHeating" Value="0.000000"/>
<Device Name="HP_Defrost" Value="0.000000"/>
<Device Name="HP_VaporT" Value="132.574996"/>
<Device Name="HP_LiquidT" Value="69.912498"/>
<Device Name="HP_Cooling" Value="0.000000"/>
<Device Name="HP_Heating" Value="1.000000"/>
</Devices>Code: Select all
<devices>
<device>
<name>date</name>
<value>12/17/2011</value>
</device>
<device>
<name>time</name>
<value>10:24:54</value>
</device>
{....etc....]
</devices>Code: Select all
for state,fieldName in fields.iteritems():
try:
newValue = theDocTree.getElementsByTagName(fieldName)[0].childNodes[0].data
except IndexError:
newValue = "- data unavailable -"
self.updateDeviceState(device, state, newValue)* the device is a "Web Energy Logger" that provides 1-wire access to, among other things, thermostat "calls" beyond those that the Insteon/Venstar interface is capable of accessing. http://www.welserver.com/