- 3rd party, edge device, or another system provides Web Service.
{% hint style="info" %} The API method of URL from the Government Open Data Platform can get from the website https://data.gov.tw/en {% endhint %}
// code in GetData
var CWBData=msg.payload;
var locationdata=CWBData.records.location;
var data=locationdata[0].weatherElement;
var msg1={};
var msg2={};
var msg3={};
var q;
try {
q=parseInt(data[1].elementValue);
}
catch (err) {
q=0;
}
if (q<0) {
q=0;
}
msg.payload=Number(q).toFixed(1);
msg.topic="hour Rainfall";
try {
q=parseInt(data[3].elementValue);
}
catch (err) {
q=0;
}
if (q<0) {
q=0;
}
msg1.payload=Number(q).toFixed(1);
msg1.topic="3hr Rainfall";
try {
q=parseInt(data[7].elementValue);
}
catch (err) {
q=0;
}
if (q<0) {
q=0;
}
msg2.payload=Number(q).toFixed(1);
msg2.topic="Total Today";
msg3.payload=locationdata[0].time.obsTime;
msg3.topic="CWB Time:";
return [msg,msg1,msg2,msg3];