-
-
Notifications
You must be signed in to change notification settings - Fork 101
Remote data
With TerrariumPI it is possible to retrieve remote sensor data. It will only able to process one value from the remote source.
This document describes the url format that is needed in order to get the remote data. For now only JSON data is supported.
This data will be pulled every 30 seconds! So make sure that there are no API limits and that the remote device can handle it.
The remote data url is a full url to the JSON output appended with a dash '#' and the JSON traversal path
http(s)://remote.server.com:portnumber/path_to_json_output#json/traversal/path
Remote source url: https://terrarium.theyosh.nl/api/sensors/f745feb874df5673e157ef8c69e586b4
json output:
{
"sensors": [
{ "alarm_min": 20.0,
"address": "26C04A8F01000042",
"id": "f745feb874df5673e157ef8c69e586b4",
"limit_max": 45.0,
"alarm_max": 30.0,
"name": "Top",
"alarm": false,
"hardwaretype": "owfs",
"current": 28.8125,
"limit_min": 10.0,
"type": "temperature"
}
]
}
json traversal path: sensors/0/current
Construct full url by combining the remote source url and the json traversal path joining by a dash '#'.
Full remote source url: https://terrarium.theyosh.nl/api/sensors/f745feb874df5673e157ef8c69e586b4#sensors/0/current
The 'json traversal path' is needed to get the right value from the JSON data. In the example above the JSON data starts with 'sensors' which is an array. Therefore the second value is '0' so we get the first item of the array. And the latest is 'current' because that holds the current value that we want. In this case 28.8125
Remote source url: https://samples.openweathermap.org/data/2.5/find?q=London&units=metric&appid=b6907d289e10d714a6e88b30761fae22
json output:
{
"message":"accurate",
"cod":"200",
"count":1,
"list":[
{
"id":2643743,
"name":"London",
"coord":{
"lat":51.5085,
"lon":-0.1258
},
"main":{
"temp":7,
"pressure":1012,
"humidity":81,
"temp_min":5,
"temp_max":8
},
"dt":1485791400,
"wind":{
"speed":4.6,
"deg":90
},
"sys":{
"country":"GB"
},
"rain":null,
"snow":null,
"clouds":{
"all":90
},
"weather":[
{
"id":701,
"main":"Mist",
"description":"mist",
"icon":"50d"
},
{
"id":300,
"main":"Drizzle",
"description":"light intensity drizzle",
"icon":"09d"
}
]
}
]
}
json traversal path: list/0/main/temp
Remote url for TerrariumPI: https://samples.openweathermap.org/data/2.5/find?q=London&units=metric&appid=b6907d289e10d714a6e88b30761fae22#list/0/main/temp