logo elektroda
logo elektroda
X
logo elektroda

[Solved] OpenWeatherMap integration for BK7231 testing on Windows Simulator

XJ_ 591 17
ADVERTISEMENT
  • #1 21335041
    XJ_
    Level 11  
    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
  • 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 11  
    >>21335335
    ok, can I check it with your apiid - (just for the test, i've my own)?
  • #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.
  • ADVERTISEMENT
  • #7 21335637
    XJ_
    Level 11  
    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.
  • ADVERTISEMENT
  • #9 21335677
    XJ_
    Level 11  
    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 7  
    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?
  • 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 7  
    >>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 7  
    Where are those channels defined? I went through all settings and didn't find any. My autoexec.bat is free of those options
  • #16 21540489
    cijoml
    Level 7  
    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.

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.
Summary generated by the language model.
ADVERTISEMENT