Advertisement
Guest User

Untitled

a guest
Oct 7th, 2023
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. function onReceive(responseCode as Lang.Number, data as Lang.Dictionary or Lang.String or Null) as Void {
  2. System.println("onReceive: response code: " + responseCode + ", data: " + data);
  3. if (responseCode == 200) {
  4. var dict = data as Dictionary;
  5. var payload = dict["payload"] as Lang.Array<Lang.Dictionary>;
  6. var val = payload[0]["val"] as Lang.Float;
  7. Background.exit(val);
  8. }
  9. Background.exit(null);
  10. }
  11.  
  12. public function onTemporalEvent() as Void {
  13. Communications.makeWebRequest(
  14. "https://api.existenz.ch/apiv1/hydro/latest",
  15. {
  16. "locations" => "2030",
  17. "version" => "1.042",
  18. "parameters" => "temperature"
  19. },
  20. {
  21. :method => Communications.HTTP_REQUEST_METHOD_GET,
  22. :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
  23. },
  24. method(:onReceive)
  25. );
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement