XPath weather data fetcher
Posted: Fri Mar 17, 2023 9:45 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:
For YR.no, use the following parameters:
Step 2 - Create a variable from the signal (integer provided)
In /admin/core, add a Global variable with the following properties:
After a few refresh, the following will appear if you have enabled signal debug.
Click on the link, give an appropriate name and replace Pattern with:
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:
Step 4 - Integer to Float
/Marcus
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:
- Fetch type: URL
- Parser Type: XPath
- URL:
- Path: /current/temperature/@value
Code: Select all
datafetcher,3,Openweathermap,fetched:-10
- Fetch type: URL
- Parser Type: XPath
- URL:
- Path: /weatherdata/forecast/tabular/time[1]/temperature/@value
Code: Select all
datafetcher,4,YR.no,fetched:6
In /admin/core, add a Global variable with the following properties:
- Data type: Integer
After a few refresh, the following will appear if you have enabled signal debug.
Code: Select all
datafetcher,3,Openweathermap,fetched:4
Code: Select all
datafetcher,3,Openweathermap,fetched:%d
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
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
/Marcus