Small API Projet : Meraki & Electricity provider

Small API Projet : Meraki & Electricity provider

Hi ! 

 

Just wanted to share with you guys a small project that I did couple weeks ago. 

 

We are based in Quebec, Canada and we are very lucky to have our electricity at a very cheap price. Not only it is very cheap but it is also a sustainable form of energy ( Hydro electricity ).  

 

 

Challenge : 

Being a large Meraki customer , we often have sites that go down at random moments. What is going on ?  Did the MX crash ? Did we lose both uplinks ? Is there an electricity outage ? 

 

Well , we don't have to guess no more !  All the electricity in Quebec is mainly provided by one provider : Hydro-Quebec. They also provide 2 set of APIs to help their customers which is mainly based on their official outage map : https://pannes.hydroquebec.com/pannes/

 

They can provide us the outages : 

 

  1. Obtain the list of outages that are currently on going.
  2. Obtain a json that contains the location ( centroid ) of the zones affected by the outage.
  3. Obtain a KMZ which contains all the coordonates of the zones affected by the outage.

 

And planned outages / maintenance :

 

  1. Obtain the list of the planned maintenances.
  2. Obtain a json that contains the location ( centroid ) of the zones affected by the planned maintenances.
  3. Obtain a KMZ which contains all the coordonates of the zones affected by the planned maintenances.

 

Solution : 

 

What if Meraki could provide us the GPS coordinates of a MX based on the adress provided from the dashboard ?? Oh well it is possible ! : getOrganizationDevices(productTypes[]=appliance) + getOrganizationDevicesStatuses(productTypes[]=appliance&statuses[]=offline)

 

Now I only have search the LAT,LNG provided by Meraki in all the polygons provided by Hydro-Quebec's KMZ.

 

Result : 

 

In about 5-15 seconds I can find all my MX that are currently down due to a power outage.

Same goes for the planned maintenance. I can now "mute" the alerts ahead in time because we know for sure that the whole site will be down due to a maintenance. 

 

Output : 

 

{'NetworkName': 'XXXX', 'Début': '2024-06-12 17:00:00', 'Fin': '2024-06-12 18:00:00', 'ReportDebut': '2024-06-12 17:00:00', 'ReportFin': '2024-06-12 18:00:00'}

Site XXXX is going to be down from 17h PM to 18h PM in 2 days. No need to bother with alerts during that period !

 

Simple as that  ! Many hours of troubleshooting can be avoided per year with a simple python script 🙂 

 

 

 

Cheers ,

Comments
DarrenOC
Kind of a big deal

Excellent piece of work @RaphaelL 

PhilipDAth
Kind of a big deal

Great coding!

Brash
Kind of a big deal

Very nice work!

van604
Building a reputation

Very nice, i wish all power companies provide a API to create stuff like this.