---
title: Pobieranie danych z serwisu OpenWeatherMap
description: "Jeśli chcemy wykorzystać w systemie informacje na temat pogody, wschodu lub zachodu słońca, możemy użyć do tego celu zewnętrznego serwisu, np.: https://openweathermap.org/ Według przykładu na stronie"
---

[Przejdź do treści](https://knowledgebase.grenton.com/pl/gate-http-pobieranie-danych-z-serwisu-openweathermap#main-content)

- [Polski](https://knowledgebase.grenton.com/pl/gate-http-pobieranie-danych-z-serwisu-openweathermap)
- [English](https://knowledgebase.grenton.com/en/gate-http-receiving-information-from-the-openweathermap-website)

Polski

Pokaż podmenu do tłumaczenia

[Nowe zgłoszenie](https://knowledgebase.grenton.com/pl/kb-tickets/new?hsLang=pl) [Portal klienta](https://knowledgebase.grenton.com/wsparcie?hsLang=pl)

![Logo\_Grenton\_Main\_2020\_RGB\_v1.0-1.png\]](https://knowledgebase.grenton.com/hs-fs/hubfs/Logo_Grenton_Main_2020_RGB_v1.0-1.png?width=200&height=94&name=Logo_Grenton_Main_2020_RGB_v1.0-1.png)

Otwórz główne menu nawigacji

Zamknij główne menu nawigacji

- - [Polski](https://knowledgebase.grenton.com/pl/gate-http-pobieranie-danych-z-serwisu-openweathermap)
    - [English](https://knowledgebase.grenton.com/en/gate-http-receiving-information-from-the-openweathermap-website)

  Polski
  
  Pokaż podmenu do tłumaczenia
- [Nowe zgłoszenie](https://knowledgebase.grenton.com/pl/kb-tickets/new)
- [Portal klienta](https://knowledgebase.grenton.com/wsparcie)
- [Szkolenia](https://szkolenia.grenton.pl/)

[Szkolenia](https://szkolenia.grenton.pl/)

 Witaj. Jak możemy Ci pomóc?

- Brak sugerowanych wyników, ponieważ pole wyszukiwania jest puste.

1. [Baza wiedzy](https://knowledgebase.grenton.com/pl?hsLang=pl)
2. [Konfiguracja i Integracje](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl)
3. [Gate HTTP](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#gate-http)

# Pobieranie danych z serwisu OpenWeatherMap

### Gate HTTP - pobieranie danych z serwisu OpenWeatherMap

Jeśli chcemy wykorzystać w systemie informacje na temat pogody, wschodu lub zachodu słońca, możemy użyć do tego celu zewnętrznego serwisu, np.: [https://openweathermap.org/](https://openweathermap.org/)

Według przykładu na stronie <https://sunrise-sunset.org/api>[https://openweathermap.org/current](https://openweathermap.org/current), zapytanie API wygląda następująco:  
API call: **api.openweathermap.org/data/2.5/weather?q={city name}&appid={your api key}**

Poniżej opisujemy, jak w prosty sposób można uzyskać wspomniane informacje:

- Należy utworzyć obiekt wirtualny HttpRequest:  
  ![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35095147823originalsCdNpM0YMNY0vrCXIk5dl9vE-Lvt2KBkjg-Dec-05-2022-09-28-30-8282-AM.png)
- W obiekcie HttpRequest należy ustawić następujące parametry:  
  ![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35095147876original9omsZPqXzNDDFJ5juo8S38vNZDCzmIivXQ-2.png)  
  Gdzie:  
  **Host:** <https://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400%E2%80%8B>[**api.openweathermap.org**](https://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400)  
  **Path:** <https://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400%E2%80%8B>[**/data/2.5/weather**](https://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400)  
  **QueryStringParams:** <https://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400%E2%80%8B>[**q=Krakow&appid={your api key}**](https://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400)
  
  **Uwaga!** Klucz api otrzymuje się po założeniu konta na stronie [https://home.openweathermap.org/users/sign\_up](https://home.openweathermap.org/users/sign_up)
- W kolejnym kroku należy utworzyć cechy użytkownika typu string oraz number:  
  ![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35096742764originalpRW_MXqbvSqwTYv3mzT8VmVx7ykReCNAYw-2.png)
- Następnie należy przygotować skrypt:
  
  ```
  if(GATE_HTTP->open_weather_map->StatusCode==200) thenlocal resp = GATE_HTTP->open_weather_map->ResponseBodyGATE_HTTP->owm_lon = resp.coord.lonGATE_HTTP->owm_lat = resp.coord.latGATE_HTTP->owm_weather_main = resp.weather[1].mainGATE_HTTP->owm_weather_desc = resp.weather[1].descriptionGATE_HTTP->owm_weather_base = resp.baseGATE_HTTP->owm_temp = resp.main.tempGATE_HTTP->owm_temp_min = resp.main.temp_minGATE_HTTP->owm_temp_max = resp.main.temp_maxGATE_HTTP->owm_pressure = resp.main.pressureGATE_HTTP->owm_humidity = resp.main.humidityGATE_HTTP->owm_visibility = resp.visibilityGATE_HTTP->owm_wind_speed = resp.wind.speedGATE_HTTP->owm_wind_deg = resp.wind.degGATE_HTTP->owm_cloud_all = resp.clouds.allGATE_HTTP->owm_country = resp.sys.countryGATE_HTTP->owm_sunrise = resp.sys.sunriseGATE_HTTP->owm_sunset = resp.sys.sunsetGATE_HTTP->owm_timezone = resp.timezoneGATE_HTTP->owm_city = resp.nameend
  ```
- Utworzony skrypt należy przypisać do zdarzenia **OnResponse** w obiekcie wirtualnym HttpRequest:  
  ![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35095149575originalBXxZ98R7c8b21mfZSHINtHAXNE_un9hcdQ-2.png)
- Następnie należy przesłać konfigurację do CLU.
- Po poprawnym przesłaniu konfiguracji, w zakładce sterowanie obiektu wirtualnego HttpRequest należy wywołać metodę **SendRequest:**  
  ![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35095149873originalhja8-frKKO__L4PnBV1qjTVU0UazCpuiug-2.png)
- Po wywołaniu metody cecha **StatusCode** powinna przyjąć wartość 200:  
  ![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35095150147originalNN3IUTrJ4KiDj6BL76-RGvVE375TEZNQEg-2.png)
- Wartości cech użytkownika powinny przyjąć odpowiednie wartości:  
  ![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35096743260originaljsCSM5woS_shqr3TIqp1Pr09b8LWSeYw0Q-2.png)
- Dla porównania - odpowiedź na zapytanie wklejone w oknie przeglądarki internetowej:  
  ![](https://knowledgebase.grenton.com/hubfs/Knowledge%20Base%20Import/s3.amazonaws.comcdn.freshdesk.comdatahelpdeskattachmentsproduction35096743378originalfjlG4gIWQH8FfWCfhGDr68QnMImmkfia3Q-2.png)
- Uzyskane dane można wyświetlić w aplikacji mobilnej, na Smart Panelu lub wykorzystać do tworzenia logiki w systemie.

- [Wytyczne instalacyjne](https://knowledgebase.grenton.com/pl/wytyczne-instalacyjne?hsLang=pl#main-content)

    - [Jak Wykonać Instalację Elektryczną](https://knowledgebase.grenton.com/pl/wytyczne-instalacyjne?hsLang=pl#jak-wykona%C4%87-instalacj%C4%99-elektryczn%C4%85)
- [Urządzenia referencyjne](https://knowledgebase.grenton.com/pl/urz%C4%85dzenia-referencyjne?hsLang=pl#main-content)

    - [Zintegrowane urządzenia](https://knowledgebase.grenton.com/pl/urz%C4%85dzenia-referencyjne?hsLang=pl#zintegrowane-urz%C4%85dzenia)
- [Najczęstsze Błędy](https://knowledgebase.grenton.com/pl/najcz%C4%99stsze-b%C5%82%C4%99dy?hsLang=pl)
- [Instalacja Elektryczna](https://knowledgebase.grenton.com/pl/instalacja-elektryczna?hsLang=pl)
- [Konfiguracja i Integracje](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#main-content)

    - [Gate Modbus](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#gate-modbus)
    - [Videoszkolenia](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#videoszkolenia)
    - [Aplikacje](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#aplikacje)
    - [Gate HTTP](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#gate-http)
    - [Smart Panel](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#smart-panel)
    - [Konfiguracja](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#konfiguracja)
    - [Interfejsy myGrenton](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#interfejsy-mygrenton)
    - [Obiekty wirtualne](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#obiekty-wirtualne)
    - [Gate Alarm](https://knowledgebase.grenton.com/pl/konfiguracja-i-integracje?hsLang=pl#gate-alarm)
- [Domofon](https://knowledgebase.grenton.com/pl/domofon?hsLang=pl)
- [Najczęściej Zadawane Pytania](https://knowledgebase.grenton.com/pl/najcz%C4%99%C5%9Bciej-zadawane-pytania?hsLang=pl#main-content)

    - [FAQ](https://knowledgebase.grenton.com/pl/najcz%C4%99%C5%9Bciej-zadawane-pytania?hsLang=pl#faq)
    - [O Grenton](https://knowledgebase.grenton.com/pl/najcz%C4%99%C5%9Bciej-zadawane-pytania?hsLang=pl#o-grenton)
- [Cenniki i dokumenty](https://knowledgebase.grenton.com/pl/cenniki-i-dokumenty?hsLang=pl)

[![Grenton logo](https://knowledgebase.grenton.com/hs-fs/hubfs/Logo_Grenton_variants_BIG_2020_plus_RGB_v0.2-02.png?width=400&height=100&name=Logo_Grenton_variants_BIG_2020_plus_RGB_v0.2-02.png "Grenton logo")](http://grenton.com)

<https://www.facebook.com/grenton.smart.home> <https://www.instagram.com/grenton_smart_home/> <https://www.youtube.com/channel/UCFNNI-dgO1cm81kCrSr1bzg> <https://www.linkedin.com/company/grenton>

Copyright © 2026, Grenton Sp.z o.o.