How to extract data

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
HeinrichH
Member
Posts: 21
Joined: Mon Jan 12, 2009 4:40 am

How to extract data

Post by HeinrichH »

I have a file called all-sensors.xml generated by meteohub. I want to display some date of this file on a software remote screen

This is a part of the file:
<item sensor="wind0" cat="dir" unit="deg">238</item>
<item sensor="wind0" cat="dir" unit="de">WSW</item>
<item sensor="wind0" cat="dir" unit="nl">WZW</item>
<item sensor="wind0" cat="dir" unit="en">WSW</item>
<item sensor="wind0" cat="gustspeed" unit="ms">1.8</item>
<item sensor="wind0" cat="gustspeed" unit="kmh">6.5</item>
<item sensor="wind0" cat="gustspeed" unit="mph">4.0</item>
<item sensor="wind0" cat="gustspeed" unit="kn">3.5</item>
<item sensor="wind0" cat="gustspeed" unit="bft">1.7</item>
<item sensor="wind0" cat="gustspeed" unit="bftint">2</item>
<item sensor="wind0" cat="speed" unit="ms">2.2</item>
<item sensor="wind0" cat="speed" unit="kmh">7.9</item>
<item sensor="wind0" cat="speed" unit="mph">4.9</item>
<item sensor="wind0" cat="speed" unit="kn">4.3</item>
<item sensor="wind0" cat="speed" unit="bft">1.9</item>
<item sensor="wind0" cat="speed" unit="bftint">2</item>
<item sensor="wind0" cat="chill" unit="c">26.3</item>
<item sensor="wind0" cat="chill" unit="f">79.3</item>
<item sensor="rain0" cat="rate" unit="mm">0.0</item>
<item sensor="rain0" cat="rate" unit="in">0.00</item>
<item sensor="rain0" cat="total" unit="mm">429.4</item>
<item sensor="rain0" cat="total" unit="in">16.91</item>

The text in red and underlined I want to extract to use.

Anybody a idea how to do that?

Henk
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: How to extract data

Post by Richard Naninck »

You can use regular expressions to filer out the labels you want to display or in case of XML you could look at:
the vbscript option CreateObject("Microsoft.XMLDOM") and go from there. In any case you need to do some programming. Once you get your hands on the correct info, store them in NULL Device Properties and display them in your theme.
You can also look at RFXCom in combination with Oregon Scientific weather sensors. This is supported by HouseBot and you get all the data you want readily in properties.
HeinrichH
Member
Posts: 21
Joined: Mon Jan 12, 2009 4:40 am

Re: How to extract data

Post by HeinrichH »

Richard,

Thanks for the info.
About the RFXcom and OS sensors, I am using those but the rain sensor has a resolution of 1mm and my Davis station has a resolution of 0.2 mm. The OS wind sensor gives only a numeric value for the wind direction in the Housebot device.
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: How to extract data

Post by Richard Naninck »

I fixed it like this:

Code: Select all

WindDirection = GetPropertyValue("Wind meter.Wind Direction")
			WindSpeed     = Round(GetPropertyValue("Wind meter.Wind Speed") * 3600 / 1000, 1)
			WindAverageMS = Round(GetPropertyValue("Wind meter.Average Wind Speed"), 1)
			WindAverage   = Round(WindAverageMS * 3600 / 1000, 1)
			ZonTemp       = GetPropertyValue("TH meter.Temperature")
			GevoelsTemp   = Round(13.12 + 0.6215 * ZonTemp - 11.37 * (3.6 * WindAverageMS) ^ 0.16 + 0.3965 * ZonTemp * (3.6 * WindAverageMS) ^ 0.16, 1)
			TotalRain     = CDbl(GetPropertyValue("Regen meter.Total Rainfall")) - CDbl(GetPropertyValue("Now Playing Server PC.Weather Rain Midnight"))
			
			If TotalRain < 0 Then
				TotalRain = "???"
			End If

			Select Case WindDirection
				Case 0  : WindDirection = "N"
				Case 23 : WindDirection = "NNO"
				Case 45 : WindDirection = "NO"
				Case 68 : WindDirection = "ONO"
				Case 90 : WindDirection = "O"
				Case 113: WindDirection = "OZO"
				Case 135: WindDirection = "ZO"
				Case 158: WindDirection = "ZZO"
				Case 180: WindDirection = "Z"
				Case 203: WindDirection = "ZZW"
				Case 225: WindDirection = "ZW"
				Case 248: WindDirection = "WZW"
				Case 270: WindDirection = "W"
				Case 293: WindDirection = "WNW"
				Case 315: WindDirection = "NW"
				Case 338: WindDirection = "NNW"
			End Select
			
			Select Case True
				Case WindAverage >= 0   And WindAverage < 1  : WindKracht = "0 - Windstil"
				Case WindAverage >= 1   And WindAverage < 6  : WindKracht = "1 - Zwak"
				Case WindAverage >= 6   And WindAverage < 12 : WindKracht = "2 - Zwak"
				Case WindAverage >= 12  And WindAverage < 20 : WindKracht = "3 - Matig"
				Case WindAverage >= 20  And WindAverage < 29 : WindKracht = "4 - Matig"
				Case WindAverage >= 29  And WindAverage < 39 : WindKracht = "5 - Vrij krachtig"
				Case WindAverage >= 39  And WindAverage < 50 : WindKracht = "6 - Krachtig"
				Case WindAverage >= 50  And WindAverage < 62 : WindKracht = "7 - Hard"
				Case WindAverage >= 62  And WindAverage < 75 : WindKracht = "8 - Stormachtig"
				Case WindAverage >= 75  And WindAverage < 89 : WindKracht = "9 - Storm"
				Case WindAverage >= 89  And WindAverage < 103: WindKracht = "10 - Zware storm"
				Case WindAverage >= 103 And WindAverage < 117: WindKracht = "11 - Zeer zware storm"
				Case WindAverage >= 117                      : WindKracht = "12 - Orkaan"
			End Select
			
			If ZonTemp <= 10 And WindAverageMS >= 1.3 Then
				Temperature = ZonTemp & "ºC  Gev: " & GevoelsTemp & "ºC"
			Else
				Temperature = ZonTemp & "ºC"
			End If

			SetpropertyValue "Now Playing Server PC.Weather Description", Get_Item(objRow, 1, tagDesc)
			SetpropertyValue "Now Playing Server PC.Weather Wind", WindDirection & " - " & WindSpeed & "  (~" & WindAverage & ") km/u"
			SetpropertyValue "Now Playing Server PC.Weather Wind Kracht", WindKracht
			SetpropertyValue "Now Playing Server PC.Weather Humidity", GetPropertyValue("TH meter.Humidity") & "%     " & GetPropertyValue("THB meter.Humidity") & "%"
			SetpropertyValue "Now Playing Server PC.Weather Rain", Round(GetPropertyValue("Regen meter.Rainfall Rate") / 1000, 1) & " mm/u (" & Round(TotalRain, 1) & " mm)"
			SetpropertyValue "Now Playing Server PC.Weather Temperature", Temperature
			SetPropertyValue "Now Playing Server PC.Weather Image", Image_Path & objRow(1)("item_image") & ".png"			
			SetpropertyValue "Now Playing Server PC.Weather Pressure", GetPropertyValue("THB meter.Barometric Pressure") & " mb"
		End If
Post Reply