Automate Your Morning: Building a Weather-Based Clothing Recommendation in Huginn
Introduction
In the previous post we set up Huginn in Docker, giving you your own self-hosted automation platform. Now it’s time to do something fun with it! In this guide, we’ll walk through creating a Huginn Scenario that checks the daily weather forecast and tells you what to wear when heading outside. Scenarios are containers of agents, and have properties that we will make use of in future posts.
This scenario will:
-
Use a weather API to get your local forecast
-
Analyze temperature and conditions
-
Recommend clothing (e.g., "wear a jacket" or "shorts are fine today")
-
Send you the advice by email or another notification agent
Let’s get started!
Step 1: Create a New Scenario
In Huginn, a Scenario is a collection of agents that work together. After logging into your Huginn dashboard:
-
Click Scenarios on the top nav bar
-
Click New Scenario
- Choose an appropriate icon, such as the cloud
Name it something like
Weather Outfit Advisor
-
(Optional) Add a description
Leave it empty for now—we'll add agents in the next steps.
Step 2: Set Up the Weather Agent
You’ll need an API that provides weather forecasts. OpenWeatherMap is a good free option:
-
Go to openweathermap.org/api and sign up
-
Choose the Current Weather or One Call API and get your API key
Now create a new Website Agent (yes, it's called website, even if we are connecting to an API):
-
From inside the scenario, Click New Agent
-
Choose
Website Agent
-
Name it
Daily Weather Fetcher
-
Set the url parameter to:
"https://api.openweathermap.org/data/2.5/weather?lat=47.96&lon=-122.50&units=imperial&appid={% credential open_weathermap %}"
Set the type to "json"
Set the extract to:
{ "weaather": { "path": ".", } }
-
Set the schedule to
every_1h
orevery_day_at_7am
-
Set Keep Events to
1 day
-
Save it, and it will be added to your
Weather Outfit Advisor
scenario
Step 3: Process the Weather Data
Now let’s add a TriggerAgent to interpret the forecast and decide what to wear.
-
Create a new agent, choose
TriggerAgent
-
Name it
Clothing Recommender
-
In the options, use something like:
{
"expected_receive_period_in_days": "1",
"keep_event": "true",
"rules": [
{
"type": "field>=value",
"value": "20",
"path": "main.temp",
"message": "It's warm today ({{main.temp}} °C). T-shirt and shorts should be fine."
},
{
"type": "field<value",
"value": "10",
"path": "main.temp",
"message": "It's chilly ({{main.temp}} °C). Consider a jacket and long pants."
},
{
"type": "field<value",
"value": "0",
"path": "main.temp",
"message": "Freezing today ({{main.temp}} °C)! Bundle up!"
}
]
}
-
Save and connect it to the output of your weather fetcher
-
Add this agent to your scenario
Step 4: Send Yourself a Notification
Finally, create a EmailAgent or a SlackAgent, depending on your preference.
For EmailAgent:
-
Create a new agent, choose
EmailAgent
-
Name it
Outfit Email Notifier
-
Example options:
{
"expected_receive_period_in_days": "1",
"subject": "Today's Weather Advice",
"body": "{{message}}",
"recipients": ["your@email.com"]
}
-
Connect it to the
Clothing Recommender
agent -
Add it to the scenario
Step 5: Test and Tweak
-
Use Dry Run or Manual Event to test the weather agent
-
Watch the data flow in real-time between agents
-
Adjust the thresholds to suit your local climate or preferences
Conclusion
Congrats! You've just built a Huginn Scenario that checks the forecast and gives smart clothing suggestions. This is just the tip of the iceberg—try extending it with umbrella alerts for rain, sunscreen reminders on sunny days, or location-based triggers.
Stay tuned for more Huginn scenarios to make your day a little more automated and a lot more awesome!
Comments