logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

[Solved] OpenWeatherMap integration for BK7231 testing on Windows Simulator

XJ_ 1149 18
ADVERTISEMENT
  • #1 21335041
    XJ_
    Level 12  
    p.kaczmarek2 wrote:
    I also did a OpenWeatherMap integration


    Hi, I cannot get it to work. OBK log:

    Info:CMD:[WebApp Cmd 'owm_setup xx.2826381 yy.0207111 a0......f4' Result] OK
    Error:HTTP:GET /data/2.5/weather?lat=xx.2826381&lon=yy.0207111&appid=a0......f4&units=metric HTTP/1.1
    Host: api.openweathermap.org
    Connection: close


    Internet is ok, for the first hour the api returned a 401 json error (should wait for the API key to be activated), and it was visible in the OBK log.

    If I try it in the browser, result is ok
    https://api.openweathermap.org/data/2.5/weather?lat=xx.2826381&lon=yy.0207111&appid=a0......f4&units=metric%20HTTP/1.1


    {
        "coord": {
     ...
       "weather": [
            {
                "id": 802,
                "main": "Clouds",
    ...
        ],
        "base": "stations",
        "main": {
            "temp": 272.05,
            "feels_like": 268.78,
            "temp_min": 271.02,
            "temp_max": 273.66,
            "pressure": 1023,
            "humidity": 99,
            "sea_level": 1023,
            "grnd_level": 981
        },
        "visibility": 10000,
        "wind": {
            "speed": 2.54,
            "deg": 188,
            "gust": 5.17
        },
        "clouds": {
            "all": 26
        },
        "dt": 1733437954,
    ...
    
  • ADVERTISEMENT
  • #4 21335335
    p.kaczmarek2
    Moderator Smart Home
    That's very strange. It works on my side.
    Webpage displaying OpenWeatherMap integration test results.
    Screenshot of a command console showing weather information and debugging data from the OpenBeken program.
    My LittleFS content, autoexec.bat:
    
    startDriver OpenWeatherMap
    owm_setup 40.7128 -74.0060 d6fae53c4278ffb3fe4c17c23fc6a7c6 
    setChannelType 3 Temperature_div10
    setChannelType 4 Humidity
    setChannelType 5 Pressure_div100
    // temperature humidity pressure
    owm_channels 3 4 5
    owm_request
    

    Note: this will NOT WORK on physical device without adding a DELAY or WAITFOR to wait for WiFi connection
    Helpful post? Buy me a coffee.
  • #5 21335339
    XJ_
    Level 12  
    >>21335335
    ok, can I check it with your apiid - (just for the test, i've my own)?
  • ADVERTISEMENT
  • #6 21335343
    p.kaczmarek2
    Moderator Smart Home
    sure, use it anyway you want. In a meantime, I will separate Weather discussion to separate topic
    Helpful post? Buy me a coffee.
  • #7 21335637
    XJ_
    Level 12  
    p.kaczmarek2 wrote:
    use it anyway you want.

    It's some kind of "free" APIID, because the free APIID has a limit of, as far as I know, 1000 requests, after which it's paid.

    Added after 13 [minutes]:

    p.kaczmarek2 wrote:
    That's very strange. It works on my side


    I found the reason, I didn't count on this not being an error:

    Error:HTTP:GET /data/2.5/weather?lat=40.7128&lon=-74.0060&appid=d6..........6&units=metric HTTP/1.1


    I saw the error, and I didn't try anything else. The error is here below too, but it's OK.
    Error: HTTP/1.1 200 OK helped me find it. ;-)

    Info:CMD:[WebApp Cmd 'owm_request' Result] OK
    Error:HTTP:Resolved IP address: 57.129.2.123
    Error:HTTP:Rec 858
    Error:HTTP:HTTP/1.1 200 OK
    Server: openresty
    Date: Fri, 06 Dec 2024 13:24:54 GMT
    Content-Type: application/json; charset=utf-
  • #8 21335676
    p.kaczmarek2
    Moderator Smart Home
    That's a key made with throwaway mail.

    So what was the error? Or... you took the log message as error, I see. I need to comment out that logging or move it to EXTRADEBUG
    Helpful post? Buy me a coffee.
  • #9 21335677
    XJ_
    Level 12  
    p.kaczmarek2 wrote:
    40.7128 -74.0060

    Btw, You're in New York?
    Anyway, this is strange for New York - same sunrise and sunset
    Timezone: -18000, Sunrise: 12:06:12, Sunset: 12:06:12
  • #10 21448875
    cijoml
    Level 9  
    Just upgraded to the latest 1.18.43 and tried OpenWeather driver but getting:
    Info:MAIN:Driver OpenWeatherMap is not known in this build.

    What do I do wrong or when it will be enabled by default?
  • ADVERTISEMENT
  • Helpful post
    #11 21448888
    p.kaczmarek2
    Moderator Smart Home
    You need to enable it manually in obk_config.h. Then you can use online builds to get binary
    https://www.elektroda.com/rtvforum/topic4033833.html#20946719
    Helpful post? Buy me a coffee.
  • #12 21538766
    cijoml
    Level 9  
    >>21448888 Hello there is a bug managing weather plugin. I setup it without support within firmware, then removed it, however I still see remains in the UI
    Screenshot of OpenBK7231N control panel showing temperature, humidity, pressure readings, and a Toggle Light button.
  • #13 21538771
    p.kaczmarek2
    Moderator Smart Home
    This is not a bug, you just have still set channel types. You can change them back to Default in the Web App.
    Helpful post? Buy me a coffee.
  • #14 21539199
    cijoml
    Level 9  
    Where are those channels defined? I went through all settings and didn't find any. My autoexec.bat is free of those options
  • ADVERTISEMENT
  • #16 21540489
    cijoml
    Level 9  
    thank you it is removed now :). however I still think that there should be check whether functionality is present within fw and if not do not show it
  • #17 21540493
    p.kaczmarek2
    Moderator Smart Home
    I'm afraid it's not really possible to do this, with a current design... channel types are totally separate from drivers. There are many drivers which can "write temperature" to given channel, or "write humidity", etc, etc. This is designed in such a way because we needed a common storage for data like that temperature and humidity so we can create scripts easily. Now also with Berry Scripting Language.
    Helpful post? Buy me a coffee.
  • #19 21756875
    p.kaczmarek2
    Moderator Smart Home
    OBK has now Berry scripting support, and Berry can parse JSON. I am adding OWM data access:
    Code: C / C++
    Log in, to see the code
    Helpful post? Buy me a coffee.

Topic summary

✨ The discussion addresses issues integrating the OpenWeatherMap (OWM) API with the BK7231 platform using a Windows Simulator. Initial problems included HTTP 401 errors due to API key activation delay and confusion over log messages indicating errors that were actually successful HTTP 200 responses. The OWM driver requires manual enabling in the obk_config.h file, as it is not included by default in some firmware builds. Users shared example configurations for LittleFS and autoexec.bat scripts, emphasizing the need for delays to ensure WiFi connectivity before API requests. The separation of channel types from drivers in the firmware design can cause UI remnants after driver removal, which can be resolved by resetting channel types to default in the Web App. The discussion also highlights limitations in the firmware design regarding dynamic UI updates based on driver presence. Links to online builds and configuration guides were provided for enabling the OWM driver. The platform used is BK7231 with Windows Simulator, and the API key management and firmware configuration are critical for successful integration.
Generated by the language model.

FAQ

TL;DR: OpenBK OpenWeatherMap works once the key activates; free keys allow ~1000 requests, and “HTTP/1.1 200 OK helped me find it.” If you see 'Error: HTTP' lines, the request may still succeed. [Elektroda, XJ_, post #21335637]

Why it matters: For BK7231 Windows Simulator and device users, this FAQ shows how to enable, configure, and troubleshoot OWM so logs and UI behave as expected.

Quick Facts

How do I enable the OpenWeatherMap driver in OpenBK firmware?

The driver is not enabled by default in some builds. Edit obk_config.h and enable the OpenWeatherMap driver. Then use the online builder to produce a binary and flash it. “You need to enable it manually in obk_config.h.” Use the linked builder from that post. [Elektroda, p.kaczmarek2, post #21448888]

What commands should I use to set up OWM quickly (How‑To)?

Use this minimal flow in autoexec.bat:
  1. startDriver OpenWeatherMap, then owm_setup .
  2. setChannelType 3 Temperature_div10; setChannelType 4 Humidity; setChannelType 5 Pressure_div100.
  3. owm_channels 3 4 5, then owm_request to fetch data. [Elektroda, p.kaczmarek2, post #21335335]

Why do I see “Error: HTTP” lines even when the request worked?

Those lines come from logging severity, not a real failure. A successful response can appear as “Error: HTTP/1.1 200 OK” in logs. The developer noted, “I need to comment out that logging or move it to EXTRADEBUG.” Treat it as informational, not critical. [Elektroda, p.kaczmarek2, post #21335676]

I’m getting HTTP 401 right after creating my API key—how long should activation take?

OpenWeatherMap may return 401 until the key activates. One user saw 401 for about the first hour, then normal 200 JSON appeared in logs and browser. Wait and retry before changing settings or keys. [Elektroda, XJ_, post #21335041]

Do I need a delay on physical BK7231 devices?

Yes. On physical devices, wait for WiFi before calling owm_request. Add a DELAY or a WAITFOR that confirms WiFi is connected. Otherwise, the request will fail because networking is not ready yet. [Elektroda, p.kaczmarek2, post #21335335]

How can I verify my API call outside OBK?

Paste your full API URL into a browser and check the JSON response. Use the same lat, lon, appid, and units as in OBK. If the browser returns weather JSON, your key and coordinates are valid. [Elektroda, XJ_, post #21335041]

What does “Driver OpenWeatherMap is not known in this build” mean?

That message means your firmware was built without the OpenWeatherMap driver. Enable it in obk_config.h and rebuild using the online builder, then flash the new binary. [Elektroda, p.kaczmarek2, post #21448888]

How do I map temperature, humidity, and pressure channels?

Define channel types and mapping before requests. Set channel 3 to Temperature_div10, 4 to Humidity, and 5 to Pressure_div100. Then run owm_channels 3 4 5 so the driver writes values to those channels. [Elektroda, p.kaczmarek2, post #21335335]

I see identical sunrise and sunset—bug or data issue?

If sunrise and sunset show the same time, note it as an edge case. It was observed with timezone −18000 for New York: Sunrise 12:06:12, Sunset 12:06:12. Refresh later or report the sample to the developer. [Elektroda, XJ_, post #21335677]

After removing the driver, why do weather fields still appear in the UI?

Those UI remnants are channel types you previously set. Open the Web App and change those channels’ types back to Default. The UI will stop showing weather-specific formatting once channel types reset. [Elektroda, p.kaczmarek2, post #21538771]

Where exactly do I reset channel types in the Web App?

Go to the Channels page in the Web App and change each affected channel’s Type dropdown to Default. The screenshot in the thread shows the exact place to adjust. [Elektroda, p.kaczmarek2, post #21539231]

Can I use someone else’s API key for quick testing?

Yes, with permission. The author confirmed, “sure, use it anyway you want.” Use your own key for ongoing use to avoid limits or revocation. [Elektroda, p.kaczmarek2, post #21335343]

How big is the OpenWeather response OBK receives?

OBK logged a current‑weather response size of 858 bytes in one example. That indicates the call succeeded and data arrived despite the misleading “Error:” prefix in the log line. [Elektroda, XJ_, post #21335637]

Can the UI hide weather fields if the firmware lacks the driver?

No, not with the current design. “Channel types are totally separate from drivers.” Multiple drivers can write temperature or humidity, so the UI stays channel‑driven, not driver‑driven. [Elektroda, p.kaczmarek2, post #21540493]
Generated by the language model.
ADVERTISEMENT