...
Code Block | ||
---|---|---|
| ||
<script>
var stationLocation = "Meetstation De Bilt";
var attributes = ["rainFallLast24Hour", "temperature", "weatherdescription"];
fetch('https://data.buienradar.nl/2.0/feed/json').then(function (response) {
return response.json();
}).then(function (json) {
return getWeatherData(json);
});
function getWeatherData(wjson) {
var stations = wjson.actual.stationmeasurements;
var stationData = stations.find(function (station) {
return station.stationname == stationLocation;
});
if (stationData) {
var sqEvent = {};
sqEvent.event = "WeatherUpdate";
attributes.forEach(function (weatherattribute) {
if (stationData[weatherattribute] !== undefined) {
var sqAttribute = "custom_" + weatherattribute.toLowerCase();
sqEvent[sqAttribute] = stationData[weatherattribute];
}
});
window._sqzl.push(sqEvent);
}
}
</script> |
...
Code Block |
---|
let stationLocation = "Meetstation De Bilt";
let attributes = ["rainFallLast24Hour", "temperature", "weatherdescription"];
fetch('https://data.buienradar.nl/2.0/feed/json')
.then((response) => response.json())
.then((json) => getWeatherData(json));
function getWeatherData(wjson) {
let stations = wjson.actual.stationmeasurements;
let stationData = stations.find(station => station.stationname == stationLocation);
if (stationData) {
let sqEvent = {};
sqEvent.event = "WeatherUpdate";
attributes.forEach((weatherattribute) => {
if (stationData[weatherattribute] !== undefined) {
let sqAttribute = "custom_" + weatherattribute.toLowerCase();
sqEvent[sqAttribute] = stationData[weatherattribute];
}
});
window._sqzl.push(sqEvent); }
} |
...