Hi, This is my first post so forgive me if I do not do this right.
Im trying to parce data retreived from a HTTP Get command to get the dayahead power prices.
The HTTP GET works fine and I retreive a Xml response similar to this:
<Publication_MarketDocument xmlns="urn:iec62325.351:tc57wg16:451-3:publicationdocument:7:0">
<mRID>2a46ebc6a7f64648b07161450e647378</mRID>
<revisionNumber>1</revisionNumber>
<type>A44</type>
<sender_MarketParticipant.mRID codingScheme="A01">10X1001A1001A450</sender_MarketParticipant.mRID>
<sender_MarketParticipant.marketRole.type>A32</sender_MarketParticipant.marketRole.type>
<receiver_MarketParticipant.mRID codingScheme="A01">10X1001A1001A450</receiver_MarketParticipant.mRID>
<receiver_MarketParticipant.marketRole.type>A33</receiver_MarketParticipant.marketRole.type>
<createdDateTime>2022-08-07T21:07:44Z</createdDateTime>
<period.timeInterval>
<start>2022-08-07T22:00Z</start>
<end>2022-08-08T22:00Z</end>
</period.timeInterval>
<TimeSeries>
<mRID>1</mRID>
<businessType>A62</businessType>
<in_Domain.mRID codingScheme="A01">10YNO-2--------T</in_Domain.mRID>
<out_Domain.mRID codingScheme="A01">10YNO-2--------T</out_Domain.mRID>
<currency_Unit.name>EUR</currency_Unit.name>
<price_Measure_Unit.name>MWH</price_Measure_Unit.name>
<curveType>A01</curveType>
<Period>
<timeInterval>
<start>2022-08-07T22:00Z</start>
<end>2022-08-08T22:00Z</end>
</timeInterval>
<resolution>PT60M</resolution>
<Point>
<position>1</position>
<price.amount>301.09</price.amount>
</Point>
<Point>
<position>2</position>
<price.amount>263.70</price.amount>
</Point>
<Point>
<position>3</position>
<price.amount>273.33</price.amount>
</Point>
<Point>
<position>4</position>
<price.amount>270.32</price.amount>
</Point>
<Point>
<position>5</position>
<price.amount>264.97</price.amount>
</Point>
<Point>
<position>6</position>
<price.amount>334.91</price.amount>
</Point>
<Point>
<position>7</position>
<price.amount>361.72</price.amount>
</Point>
<Point>
<position>8</position>
<price.amount>406.97</price.amount>
</Point>
<Point>
<position>9</position>
<price.amount>401.83</price.amount>
</Point>
<Point>
<position>10</position>
<price.amount>372.63</price.amount>
</Point>
<Point>
<position>11</position>
<price.amount>329.60</price.amount>
</Point>
<Point>
<position>12</position>
<price.amount>297.55</price.amount>
</Point>
<Point>
<position>13</position>
<price.amount>284.79</price.amount>
</Point>
<Point>
<position>14</position>
<price.amount>285.48</price.amount>
</Point>
<Point>
<position>15</position>
<price.amount>286.13</price.amount>
</Point>
<Point>
<position>16</position>
<price.amount>298.85</price.amount>
</Point>
<Point>
<position>17</position>
<price.amount>320.29</price.amount>
</Point>
<Point>
<position>18</position>
<price.amount>397.73</price.amount>
</Point>
<Point>
<position>19</position>
<price.amount>422.04</price.amount>
</Point>
<Point>
<position>20</position>
<price.amount>435.77</price.amount>
</Point>
<Point>
<position>21</position>
<price.amount>433.46</price.amount>
</Point>
<Point>
<position>22</position>
<price.amount>424.95</price.amount>
</Point>
<Point>
<position>23</position>
<price.amount>415.84</price.amount>
</Point>
<Point>
<position>24</position>
<price.amount>379.07</price.amount>
</Point>
</Period>
</TimeSeries>
</Publication_MarketDocument>
I need help to create a XPath expression to retreive any of the Price.Amount values. currently I have read tons of posts and have ended up trying two promissing methods.
Also, Xpath transformation is installed.
method1:
I have created a HTTP thing with a channel.
Thing http:url:powerPrices "Power Prices" [
baseURL="MYUrl",
refresh=3600] {
Channels:
Type string : text "Text" [ stateTransformation="XPath:/Publication_MarketDocument/TimeSeries/Period/Point[1]/price.amount/text()" ]
}
And a Item that correspond to this.
String PowerPrice1 "Pris Kl 1" {channel="http:url:powerPrices:text"}
the Items returns empty.
Additionally, the URL will need to change every day as there is a date attribute in the URL, so to my limited knowledge I do not see how I can use this method anyway to retreive the values?
Method 2:
I have created a Power.rules file:
rule "Test"
when
Item PowerTestSwitch received command
then
val String priceXml = sendHttpGetRequest("MYUrl")
logInfo("Mytest1", priceXml)
val String transxpath = transform("XPATH", "/Publication_MarketDocument/TimeSeries/Period/Point[1]/price.amount/text()", priceXml)
logInfo("Mytest2", transxpath)
loginfo Mytest1 returns the full Xml as expected.
the following is the error for logInfo Mytest2:
00:28:02.443 [ERROR] [.internal.handler.ScriptActionHandler] - Script execution of rule with UID 'power-1' failed: Text '<?xml version="1.0" encoding="UTF-8"?>
<Publication_MarketDocume...' could not be parsed at index 0 in power
Additionally, when loading the full xml into various online XPath expression testers and expression builders, some of them verifies the expression, and others returns nothing on the same expression.
Can someone point me in the right direction?