muesli / beehive

A flexible event/agent & automation system with lots of bees 🐝
GNU Affero General Public License v3.0
6.32k stars 325 forks source link

openweathermap: Handle multiple locations in context #312

Closed rubiojr closed 4 years ago

rubiojr commented 4 years ago

Extends https://github.com/muesli/beehive/pull/311 by adding support to store multiple locations in the Bee context, at the expense of making it a bit more complex to retrieve the info from a template.

Something like:

"Weather in {{(index .context.weather.current 3128760).Name}}: ..."

Where 3128760 is the OpenWeatherMap ID corresponding to one of the locations stored in the context while retrieving the weather.

rubiojr commented 4 years ago

Kinda torn about this one. Makes it possible to retrieve the weather of multiple locations from the context but also makes it uglier to use it from a template.

The alternative would be to create multiple weather bees for each location, which is already supported by the previously merged PR, https://github.com/muesli/beehive/pull/311

muesli commented 4 years ago

I agree: our typical approach here would be to initialize multiple instances of the OpenWeatherMapBee, unless there are other advantages to sharing a single instance.