XPath weather data fetcher


Moderators: davka003, Telldus

Post Reply
Posts: 163
Joined: Thu Jan 18, 2018 11:08 am

XPath weather data fetcher

Post by KHolm » Thu Jan 18, 2018 11:08 am

This is an instruction on how to use a Data Fetcher that parses an integer from XML response into a float variable.
It was previously posted on the Automagically blog in Swedish; though it made better use here in english.

STEP 1 - Set up the data fetcher
In /admin/core, add a data fetcher with the following properties: This will create the following signal in the system:

Code: Select all

For YR.no, use the following parameters: This will create the following signal in the system:

Code: Select all

Step 2 - Create a variable from the signal (integer provided)
In /admin/core, add a Global variable with the following properties:
  • Data type: Integer
Now, go to /signals/index (See signals and create handler or device from them)
After a few refresh, the following will appear if you have enabled signal debug.

Code: Select all

Click on the link, give an appropriate name and replace Pattern with:

Code: Select all

Test it all by clicking on Test and the value shall appear.
Now, click on "Store global variable" and then "Save"
On the next page you select your previously created variable in "Variable to update" and click "Save"
Now you have a data variable that is updated at your selected interval.

Step 2 - Add it to your remote
To get the variable in your remote, follow these steps.
In /admin/core, add a "Variable value" with the following properties:
  • X,Y: The location on the remote
  • Var: The above created variable selected in dropdown
So, now you have a variable appearing - but you don't have the option to see 24hrs history. Well, let's transform the variable into a Float to see if that cannot be done.

Step 4 - Integer to Float
  • Create a Float variable as desribed above
  • In /admine/signals create a transform:
    • Pattern to match: datafetcher,3,Openweathermap,fetched:%d
    • Send: changed_ow_temp:$1.0
  • In /admin/signals create a store global values:
    • Pattern to match: changed_ow_temp:%f
    • Var: Select your above created float variable
  • Throw it to your remote
Good luck and please post working combinations of URL/Xpath for other to re-use in Automagically.


Post Reply