DEV Community

Cover image for Get weather alerts using ClimaCell Zapier & PushBullet
Aviv Shafir
Aviv Shafir

Posted on

Get weather alerts using ClimaCell Zapier & PushBullet

Get weather alerts using ClimaCell (Tomorrow.io) Zapier & PushBullet

Small businesses around the world are starting to understand the severe impact of weather events on their revenue and on their employee's level of risk. Taking preventive measures is something I started researching for my uncle, who owns a small construction company.
For example, strong winds can increase the risk of accidents in a construction site.

I will show the simplicity of setting up a complete flow that will trigger push notifications when the wind speed is about a certain value we will define.

For implementing this, we will use *ClimaCell weather API, Zapier, and PushBullet.*

Using ClimaCell API we will be defining an alert that is triggered when some weather condition occurs.
Then we will connect the hook Zapier to PushBullet using the Zapier ClimaCell integration. PushBullet is installed on my phone and will get the push notification from ClimaCell.

Let's get started,

Create an account in ClimaCell by signing up to an API free account,
by clicking the “Sign up and start building ” button.
https://www.climacell.co/weather-api/

After you signed up you should be inside the ClimaCell app and should be able to view your newly created API key, copy it, and save this key, quite frequently in the following steps.

Now we need to create a location (for example the construction site location)
we need the coordinates of the location, one way to get those is by using google maps, by searching the location, and right-clicking on the marker.

After we got the coordinates lets to make an API call to ClimaCell to create our location:

I will be making the calls from the CLI using curl (remember to replace the “your_api_key” in the command with your API Key from ClimaCell)

curl --request POST \
--url 'https://data.climacell.co/v4/locations?apikey=<your_api_key>' \
--header 'Content-Type: application/json' \
--data '{"name":"Tel Aviv","geometry":{"coordinates":[34.77019,32.05252],"type":"Point"}}'
Enter fullscreen mode Exit fullscreen mode

using ClimaCell docs playground featureusing ClimaCell docs playground feature

Copy the Location ID returned in the response.

Now let's create the Insight. This is basically the weather condition we define.
Take a look here for a more detailed explanation https://docs.climacell.co/reference/insights-overview

In our case the Insight will look like this:

"conditions": {
        "type": "OPERATOR",
        "content": {
            "operator": "EQUAL"
        },
        "children": [
            {
                "type": "PARAMETER",
                "content": {
                    "parameter": "windSpeed"
                }
            },
            {
                "type": "CONST",
                "content": {
                    "const": 20
                }
            }
        ]
    }
Enter fullscreen mode Exit fullscreen mode

This insight has one condition, connecting this insight to an alert will trigger the alert when wind speed is above 20 Knots.

curl --request POST \
--url 'https://data.climacell.co/v4/insights?apikey=<your_api_key>' \
--header 'Content-Type: application/json' \
--data '{"conditions":{"type":"OPERATOR","content":{"operator":"EQUAL"},"children":[{"type":"PARAMETER","content":{"parameter":"windSpeed"}},{"type":"CONST","content":{"const":20}}]},"name":"Windy"}'
Enter fullscreen mode Exit fullscreen mode

remember to replace the api_key when running this command

Copy the Insight ID returned in the response.

Now we need to create an Alert attached to this insight

curl --request POST \
--url 'https://data.climacell.co/v4/alerts?apikey=<your_api_key>' \
--header 'Content-Type: application/json' \
--data '{"isActive":true,"name":"Strong wind alert","insight":"<the_insight_id>"}'
Enter fullscreen mode Exit fullscreen mode

remember to replace the api_key and the insight_id in this command with your values

Now we need to make the connection between the insight and the alert* (playground)

curl --request POST \
--url 'https://data.climacell.co/v4/alerts/<alert_id>/locations/link?apikey=<your_api_key>' \
--header 'Content-Type: application/json' \
--data '{"locations":["<location_id>"]}'
Enter fullscreen mode Exit fullscreen mode

remember to replace the api_key and the insight_id and location_id in this command with your values

After finishing setting up ClimaCell Location, Insight and Alert, and Linking the Alert with the Location we will move into setting up our ClimaCell Zapier integration.

Go to https://zapier.com/app/editor, (sign up) and create a new Zap,
search and connect the ClimaCell app into your account and select “New Notification” as the event type.

Now we want to set up the Action, lets search and connect to our PushBullet account

Now we need to customize the ClimaCell weather event message, we can use the variables that Zapier and ClimeCell provide

Clicking one of the Test buttons will send you your first notification to PushBullet!

I’m using the PushBullet android app, and it shows up like this:

ClimaCell’s development page shows our new Zapier integration enabledClimaCell’s development page shows our new Zapier integration enabled

That’s it, now every time the condition we set previously in the ClimaCell platform through their API, we will get a notification piped through Zapier, to PushBullet!

Photo by [Bill Jelen](https://unsplash.com/@billjelen?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)Photo by Bill Jelen on Unsplash

Top comments (0)