Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onReceive(responseCode as Lang.Number, data as Lang.Dictionary or Lang.String or Null) as Void {
- System.println("onReceive: response code: " + responseCode + ", data: " + data);
- if (responseCode == 200) {
- var dict = data as Dictionary;
- var payload = dict["payload"] as Lang.Array<Lang.Dictionary>;
- var val = payload[0]["val"] as Lang.Float;
- Background.exit(val);
- }
- Background.exit(null);
- }
- public function onTemporalEvent() as Void {
- Communications.makeWebRequest(
- "https://api.existenz.ch/apiv1/hydro/latest",
- {
- "locations" => "2030",
- "version" => "1.042",
- "parameters" => "temperature"
- },
- {
- :method => Communications.HTTP_REQUEST_METHOD_GET,
- :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
- },
- method(:onReceive)
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement