Skip to content

[sendtohttp] Add Open-Meteo events + JSON event#5207

Merged
TD-er merged 40 commits intoletscontrolit:megafrom
chromoxdor:openmeteo-events
Jun 23, 2025
Merged

[sendtohttp] Add Open-Meteo events + JSON event#5207
TD-er merged 40 commits intoletscontrolit:megafrom
chromoxdor:openmeteo-events

Conversation

@chromoxdor
Copy link
Contributor

@chromoxdor chromoxdor commented Jan 2, 2025

To-do:

  • Lots of documentation and examples
  • Some more annotation in the code probably

As being asked here: https://www.letscontrolit.com/forum/viewtopic.php?p=72083#p72083 i do a PR for Open-Meteo events

  1. It parses url for the variable type (current,hourly, daily)
  2. Contrains the response and parses this for the variables
  3. depending on the variable type it generates an event (e.g. On OpenMeteo#current Do... )

It works but responses can get quite long, especially for hourly variables and also when all types combined together.
But for now it was working fine on an esp32 classic even with very long resonses > 6kb

I tried to kind of create a size check but i am no expert for memory constraint systems. Maybe you can help out here with some recommendations.

I guess when calling this it is already to late 🙂 :

 if (uri.length() > 5000) {
        addLog(LOG_LEVEL_ERROR, F("Response exceeds 5000 characters"));
      }
      else {

How to use:

  1. visit https://open-meteo.com/en/docs
  2. click together what you need and scroll down to the API Response section where you find this:
Bildschirmfoto 2025-01-02 um 14 59 15
  1. usesendtohttp api.open-meteo.com,80,/v1/forecast?...

Issues:

  1. ESPEasy throws a "Too many arguments" error but it still works fine
  2. In the log only 25 eventvalues are displayed. But you can still access all of them with rules. I wonder where the limit is?

@chromoxdor
Copy link
Contributor Author

chromoxdor commented Jan 2, 2025

Command:
sendtohttp api.open-meteo.com,80,"/v1/forecast?latitude=52.5244&longitude=13.4105&current=temperature_2m,relative_humidity_2m&daily=temperature_2m_max,temperature_2m_min,uv_index_max&timezone=Europe%2FLondon&forecast_days=3"

Response:

2580494: EVENT: OpenMeteo#current=4.3,76
2580503: EVENT: OpenMeteo#daily=7.5,2.4,1.2,1.5,-1.0,-1.1,1.00,0.95,0.70

@tonhuisman
Copy link
Contributor

tonhuisman commented Jan 2, 2025

  1. ESPEasy throws a "Too many arguments" error but it still works fine

Wrap the (long) url, that contains several commas, in quotes, and this issue should be resolved 😉
Alternative: url-encode the commas to %2C so ESPEasy doesn't see them as commas

@chromoxdor
Copy link
Contributor Author

Wrap the (long) url, that contains several commas, in quotes, and this issue should be resolved 😉

I tried that and it didn't work...but now i think i know what happend. I have this auto correction plugin in my browser. Disabling it helped :)

- added FEATURE_OPENMETEO_EVENT to Custom-sample.h
- disabled FEATURE_THINGSPEAK_EVENT and FEATURE_OPENMETEO_EVENT on default
- both got the same structure in define_plugin_sets.h
@chromoxdor
Copy link
Contributor Author

Thanks for helping me...

@chromoxdor
Copy link
Contributor Author

I combined the two functions because there is actually no need for that

@chromoxdor
Copy link
Contributor Author

What needs to be done to get this merged?

@TD-er
Copy link
Member

TD-er commented Jun 23, 2025

What needs to be done to get this merged?

I will have a look at it now...

@TD-er
Copy link
Member

TD-er commented Jun 23, 2025

Well if you can do a last-minute check to make sure it is still working after these changes, I will merge it when no issues found.
So please let me know if you did a quick test.

@chromoxdor
Copy link
Contributor Author

Check completed.
Everything seems to work as expected...

@TD-er TD-er merged commit c3400e2 into letscontrolit:mega Jun 23, 2025
@chromoxdor chromoxdor deleted the openmeteo-events branch June 23, 2025 19:48
@chromoxdor
Copy link
Contributor Author

Thanks :)

@TD-er
Copy link
Member

TD-er commented Jun 23, 2025

Uploaded the build including this to the web flasher: https://td-er.nl/ESPEasy/latest/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants